From 03eadcebf1c636cb8a9d4c5945d33d5929c8f082 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 19 Jun 2017 12:25:00 +0200 Subject: [PATCH 001/109] FIX: User id correction on holiday request --- htdocs/holiday/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 8cae9592033..d9e651953c5 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2012-2015 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014-2017 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 @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; $myparam = GETPOST("myparam"); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); -$userid = GETPOST('userid')?GETPOST('userid'):$user->id; +$userID = GETPOST('userID')?GETPOST('userID'):$user->id; // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -57,6 +57,7 @@ if ($action == 'create') $cp = new Holiday($db); // If no right to create a request + $userid = GETPOST('userid'); if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all))) { $error++; @@ -82,7 +83,6 @@ if ($action == 'create') $valideur = GETPOST('valideur'); $description = trim(GETPOST('description')); - $userID = GETPOST('userID'); // If no type if ($type <= 0) @@ -112,7 +112,7 @@ if ($action == 'create') } // Check if there is already holiday for this period - $verifCP = $cp->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday); + $verifCP = $cp->verifDateHolidayCP($userid, $date_debut, $date_fin, $halfday); if (! $verifCP) { header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=alreadyCP'); @@ -762,7 +762,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create // Formulaire de demande print '
'."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; dol_fiche_head(); From c4546b6da6b7ca71b5f640184b22b3d0394b8139 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Mon, 19 Jun 2017 16:23:44 +0200 Subject: [PATCH 002/109] FIX: User id correction on holiday request --- htdocs/holiday/card.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index d9e651953c5..5789cf27180 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -39,7 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; $myparam = GETPOST("myparam"); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); -$userID = GETPOST('userID')?GETPOST('userID'):$user->id; // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -57,8 +56,8 @@ if ($action == 'create') $cp = new Holiday($db); // If no right to create a request - $userid = GETPOST('userid'); - if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all))) + $fuserid = GETPOST('fuserid'); + if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) { $error++; setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); @@ -112,7 +111,7 @@ if ($action == 'create') } // Check if there is already holiday for this period - $verifCP = $cp->verifDateHolidayCP($userid, $date_debut, $date_fin, $halfday); + $verifCP = $cp->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); if (! $verifCP) { header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=alreadyCP'); @@ -140,7 +139,7 @@ if ($action == 'create') if (! $error) { - $cp->fk_user = $userid; + $cp->fk_user = $fuserid; $cp->description = $description; $cp->date_debut = $date_debut; $cp->date_fin = $date_fin; @@ -682,7 +681,7 @@ llxHeader(array(),$langs->trans('CPTitreMenu')); if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create') { // Si l'utilisateur n'a pas le droit de faire une demande - if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all))) + if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) { $errors[]=$langs->trans('CantCreateCP'); } @@ -762,7 +761,6 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create // Formulaire de demande print ''."\n"; print ''."\n"; - print ''."\n"; dol_fiche_head(); @@ -793,10 +791,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; if (empty($user->rights->holiday->write_all)) { - print $form->select_dolusers($userid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print ''; + print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print ''; } - else print $form->select_dolusers(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0); + else print $form->select_dolusers(GETPOST('fuserid')?GETPOST('fuserid'):$user->id,'fuserid',0,'',0); print ''; print ''; From f694939fc74e81d823be4c56b51d66f64d793abb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Jun 2017 19:39:37 +0200 Subject: [PATCH 003/109] Fix migration with pgsql --- htdocs/install/mysql/migration/3.5.0-3.6.0.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index bd04766eebf..3d83d2a7af9 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -63,7 +63,7 @@ ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL; ALTER TABLE llx_bookmark MODIFY COLUMN url varchar(255) NOT NULL; -ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00'; +-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00'; -- Clean corrupted values for tms -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; @@ -74,7 +74,7 @@ ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01- -- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; -ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP; +-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP; ALTER TABLE llx_opensurvey_sondage ADD COLUMN entity integer DEFAULT 1 NOT NULL; @@ -204,9 +204,14 @@ CREATE TABLE llx_payment_salary ( fk_user_modif integer )ENGINE=innodb; + +DELETE FROM llx_product_batch where fk_product_stock NOT IN (SELECT rowid from llx_product_stock); + ALTER TABLE llx_product_batch ADD INDEX idx_fk_product_stock (fk_product_stock); ALTER TABLE llx_product_batch ADD CONSTRAINT fk_product_batch_fk_product_stock FOREIGN KEY (fk_product_stock) REFERENCES llx_product_stock (rowid); +DELETE FROM llx_expeditiondet_batch where fk_expeditiondet NOT IN (SELECT rowid from llx_expeditiondet); + ALTER TABLE llx_expeditiondet_batch ADD INDEX idx_fk_expeditiondet (fk_expeditiondet); ALTER TABLE llx_expeditiondet_batch ADD CONSTRAINT fk_expeditiondet_batch_fk_expeditiondet FOREIGN KEY (fk_expeditiondet) REFERENCES llx_expeditiondet(rowid); From 93477c102f725a449cc912dbc8b0ba168c9926e4 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 26 Jun 2017 15:44:04 +0200 Subject: [PATCH 004/109] FIX delete linked element on facture rec --- htdocs/compta/facture/class/facture-rec.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index ef23a30b878..e39a4a7b994 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -475,7 +475,13 @@ class FactureRec extends CommonInvoice { $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid; dol_syslog($sql); - if (! $this->db->query($sql)) + if ($this->db->query($sql)) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error=-3; + } + else { $this->error=$this->db->lasterror(); $error=-1; From 13e5c8ff7ac61bd3b22810d06a229f7c7d768166 Mon Sep 17 00:00:00 2001 From: fappels Date: Mon, 26 Jun 2017 22:44:56 +0200 Subject: [PATCH 005/109] Create patch Add Number of supplier prices and wap columns --- .../fourn/class/fournisseur.product.class.php | 28 ++++++++--- htdocs/langs/en_US/suppliers.lang | 1 + htdocs/product/list.php | 49 ++++++++++++++++++- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 4f576148099..e8a63e252d7 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,17 +699,33 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitle Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects to display in table format. * @return string String with supplier price */ - function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0) + function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { global $langs; + + $out = ''; $langs->load("suppliers"); - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + if (count($productFournList) > 0) { + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + foreach ($productFournList as $productFourn) { + $out.= ''; + $out.= ''; + $out.= ''; + } + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + } else { + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + } return $out; } diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index d84925d0676..079b588167f 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -43,3 +43,4 @@ NotTheGoodQualitySupplier=Wrong quality ReputationForThisProduct=Reputation BuyerName=Buyer name AllProductServicePrices=All product / service prices +BuyingPriceNumShort=Nbr of Buying prices diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 74f9c59cff3..fa0ee2cace7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -164,6 +164,8 @@ $arrayfields=array( 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), + 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), + 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), @@ -266,7 +268,7 @@ else $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy,'; - $sql.= ' p.datec as date_creation, p.tms as date_update,'; + $sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; //$sql.= ' pfp.ref_fourn as ref_supplier, '; $sql.= ' MIN(pfp.unitprice) as minsellprice'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { @@ -335,7 +337,7 @@ else $sql.=$hookmanager->resPrint; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; $sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; - $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy'; + $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy, p.pmp'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { $sql .= ', pac.rowid'; } @@ -563,6 +565,20 @@ else print ''; print ' '; print ''; + } + // Number buying Price + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + print ' '; + print ''; + } + // Number buying Price + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + print ' '; + print ''; } // Limit for alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) @@ -640,6 +656,8 @@ else if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); @@ -703,6 +721,7 @@ else $product_static->status_buy = $obj->tobuy; $product_static->status = $obj->tosell; $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) // To optimize call of load_stock { @@ -798,6 +817,32 @@ else print ''; } + // Number of buy prices + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + if ($obj->tobuy) + { + if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList),$htmltext); + } + } + print ''; + } + + // WAP + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + if ($obj->tobuy) + { + print price($product_static->pmp, 1, $langs, 1, 2, 1, 'auto'); + } + print ''; + } + // Limit alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { From 99c78675222640e1890c678ba0fbc13fc64ee4ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Jun 2017 12:06:01 +0200 Subject: [PATCH 006/109] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb6b774d9ab..60343805fcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ php: - '5.3' - '5.4' - '5.5' -- '5.6' +- '5.6.29' - '7.0' - nightly From 65b9b70ff8ad62147bf5186ac07a9e3ac3a67ee2 Mon Sep 17 00:00:00 2001 From: arnaud Date: Tue, 27 Jun 2017 15:23:51 +0200 Subject: [PATCH 007/109] FIX invoice page list --- htdocs/compta/facture/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 14a5c484e8c..e37f5b316fc 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -551,7 +551,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit,$offset); +$sql.= $db->plimit($limit + 1,$offset); //print $sql; $resql = $db->query($sql); @@ -591,7 +591,6 @@ if ($resql) $i = 0; print ''."\n"; - print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$massactionbutton,$num,$nbtotalofrecords,'title_accountancy.png'); if ($massaction == 'presend') From 3664956b8c98859e0f97b33cf219509889c208a4 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 28 Jun 2017 00:31:33 +0200 Subject: [PATCH 008/109] Update pdf_azur.modules.php --- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 972a75eecc8..3eb284ec7fc 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -120,7 +120,7 @@ class pdf_azur extends ModelePDFPropales } $this->posxdiscount=162; $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { From cef5c0b37514c38ed370d996abf541d1f5d2438d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 28 Jun 2017 00:38:24 +0200 Subject: [PATCH 009/109] Fix column position in PDF when VAT is hidden --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index d31ed238965..54c1f546903 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -122,7 +122,7 @@ class pdf_einstein extends ModelePDFCommandes } $this->posxdiscount=162; $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c1682c78087..7fb55b398bc 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -132,7 +132,7 @@ class pdf_crabe extends ModelePDFFactures $this->posxdiscount=162; $this->posxprogress=126; // Only displayed for situation invoices $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index c546aad91ad..10ea968c041 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -108,7 +108,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->posxqty=145; $this->posxdiscount=162; $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { From 4283b1ee30b294b975c34236897a0944a6901371 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 28 Jun 2017 18:31:37 +0200 Subject: [PATCH 010/109] FIX: User id correction on holiday request --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 5789cf27180..44ec0496f7b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -792,7 +792,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create if (empty($user->rights->holiday->write_all)) { print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print ''; + print ''; } else print $form->select_dolusers(GETPOST('fuserid')?GETPOST('fuserid'):$user->id,'fuserid',0,'',0); print ''; From a695fa9c6e448c3be77c55321f3584b6a95fc1d0 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 29 Jun 2017 14:36:10 +0200 Subject: [PATCH 011/109] FIX holidays with postgresql like on rowid integer --- htdocs/holiday/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 90db40fd2e7..53430f0b6e1 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -70,7 +70,6 @@ $type = GETPOST('type','int'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'cp.rowid'=>'Ref', 'cp.description'=>'Description', 'uu.lastname'=>'EmployeeLastname', 'uu.firstname'=>'EmployeeFirstname' @@ -124,7 +123,7 @@ $order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset); // WHERE if(!empty($search_ref)) { - $filter.= " AND cp.rowid LIKE '%".$db->escape($search_ref)."%'\n"; + $filter.= " AND cp.rowid = ".$db->escape($search_ref); } // DATE START From 58328d36b3e40534a78c0a6d36f28b6a8cf21aa9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Jun 2017 15:32:36 +0200 Subject: [PATCH 012/109] To provide solution to get thirdparty when name is not unique. --- htdocs/societe/class/societe.class.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 097537ac71a..1423b53b9da 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1004,21 +1004,22 @@ class Societe extends CommonObject * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) - * @param string $ref_int Internal reference of third party + * @param string $ref_int Internal reference of third party (not used by dolibarr) * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) + * @param string $email Email (Warning, this can return several records) * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='') + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') { global $langs; global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6)) return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; $sql .= ', s.status'; @@ -1062,6 +1063,7 @@ class Societe extends CommonObject else if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")"; else if ($idprof5) $sql .= " WHERE s.idprof5 = '".$this->db->escape($idprof5)."' AND s.entity IN (".getEntity($this->element, 1).")"; else if ($idprof6) $sql .= " WHERE s.idprof6 = '".$this->db->escape($idprof6)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($email) $sql .= " WHERE email = '".$this->db->escape($email)."' AND s.entity IN (".getEntity($this->element, 1).")"; $resql=$this->db->query($sql); dol_syslog(get_class($this)."::fetch ".$sql); @@ -1886,7 +1888,7 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowMargin") . ''; $linkstart = ''; @@ -1949,7 +1951,7 @@ class Societe extends CommonObject $linkstart=''; $linkend=''; } - + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$linkstart.($maxlen?dol_trunc($name,$maxlen):$name).$linkend; @@ -3449,9 +3451,9 @@ class Societe extends CommonObject return 0; } } - + $modelpath = "core/modules/societe/doc/"; - + $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } @@ -3472,7 +3474,7 @@ class Societe extends CommonObject public function setCategories($categories, $type) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - + // Decode type if ($type == 'customer') { $type_id = Categorie::TYPE_CUSTOMER; From 2f8c0bb555a089fe5b36065a0ca830709ecacb58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Jun 2017 15:36:39 +0200 Subject: [PATCH 013/109] Revert "To provide solution to get thirdparty when name is not unique." This reverts commit 58328d36b3e40534a78c0a6d36f28b6a8cf21aa9. --- htdocs/societe/class/societe.class.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1423b53b9da..097537ac71a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1004,22 +1004,21 @@ class Societe extends CommonObject * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) - * @param string $ref_int Internal reference of third party (not used by dolibarr) + * @param string $ref_int Internal reference of third party * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) - * @param string $email Email (Warning, this can return several records) * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='') { global $langs; global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6)) return -1; $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; $sql .= ', s.status'; @@ -1063,7 +1062,6 @@ class Societe extends CommonObject else if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")"; else if ($idprof5) $sql .= " WHERE s.idprof5 = '".$this->db->escape($idprof5)."' AND s.entity IN (".getEntity($this->element, 1).")"; else if ($idprof6) $sql .= " WHERE s.idprof6 = '".$this->db->escape($idprof6)."' AND s.entity IN (".getEntity($this->element, 1).")"; - else if ($email) $sql .= " WHERE email = '".$this->db->escape($email)."' AND s.entity IN (".getEntity($this->element, 1).")"; $resql=$this->db->query($sql); dol_syslog(get_class($this)."::fetch ".$sql); @@ -1888,7 +1886,7 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowMargin") . ''; $linkstart = ''; @@ -1951,7 +1949,7 @@ class Societe extends CommonObject $linkstart=''; $linkend=''; } - + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$linkstart.($maxlen?dol_trunc($name,$maxlen):$name).$linkend; @@ -3451,9 +3449,9 @@ class Societe extends CommonObject return 0; } } - + $modelpath = "core/modules/societe/doc/"; - + $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } @@ -3474,7 +3472,7 @@ class Societe extends CommonObject public function setCategories($categories, $type) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - + // Decode type if ($type == 'customer') { $type_id = Categorie::TYPE_CUSTOMER; From 6e8c83b2a960cc5f2c9e33a1e9ce7ba19c3eeb96 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 29 Jun 2017 15:47:33 +0200 Subject: [PATCH 014/109] fix class error (given by eclipse Oxygen version) --- .../accountancy/class/bookkeeping.class.php | 434 +++++++++--------- .../compta/paiement/class/cpaiement.class.php | 42 +- 2 files changed, 238 insertions(+), 238 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8f31b40bc54..c5f2e9d8696 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -53,19 +53,19 @@ class BookKeeping extends CommonObject * * @var string Name of table without prefix where object is stored */ - public $table_element = 'accounting_bookkeeping'; - - + public $table_element = 'accounting_bookkeeping'; + + public $entity = 1; - - + + /** * * @var BookKeepingLine[] Lines */ public $lines = array (); - - + + /** * * @var int ID @@ -89,10 +89,10 @@ class BookKeeping extends CommonObject public $import_key; public $code_journal; public $piece_num; - + /** */ - + /** * Constructor * @@ -101,7 +101,7 @@ class BookKeeping extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; } - + /** * Create object into database * @@ -111,11 +111,11 @@ class BookKeeping extends CommonObject */ public function create(User $user, $notrigger = false) { global $conf, $langs; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $error = 0; - + // Clean parameters if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); @@ -164,7 +164,7 @@ class BookKeeping extends CommonObject } if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; - + // Check parameters if (empty($this->numero_compte) || $this->numero_compte == '-1') { @@ -175,40 +175,40 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); } - + return -1; } - - + + $this->db->begin(); - + $this->piece_num = 0; - + // First check if line not yet already in bookkeeping $sql = "SELECT count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " AND fk_doc = " . $this->fk_doc; - $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $resql = $this->db->query($sql); - + if ($resql) { $row = $this->db->fetch_object($resql); - if ($row->nb == 0) + if ($row->nb == 0) { // Determine piece_num $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; // For example doc_type = 'bank' + $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; // For example doc_type = 'bank' $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; // ref of source object $sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -220,7 +220,7 @@ class BookKeeping extends CommonObject $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -232,12 +232,12 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $this->piece_num = 1; } - + $now = dol_now(); if (empty($this->date_create)) { $this->date_create = $now; } - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; $sql .= "doc_date"; $sql .= ", doc_type"; @@ -255,7 +255,7 @@ class BookKeeping extends CommonObject $sql .= ", import_key"; $sql .= ", code_journal"; $sql .= ", piece_num"; - $sql .= ', entity'; + $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($this->doc_date) . "'"; $sql .= ",'" . $this->doc_type . "'"; @@ -275,12 +275,12 @@ class BookKeeping extends CommonObject $sql .= "," . $this->piece_num; $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - + if ($id > 0) { $this->id = $id; $result = 0; @@ -308,20 +308,20 @@ class BookKeeping extends CommonObject $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + if (! $error) { - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_CREATE',$user); // if ($result < 0) $error++; // // End call triggers } } - + // Commit or rollback if ($error) { $this->db->rollback(); @@ -331,7 +331,7 @@ class BookKeeping extends CommonObject return $result; } } - + /** * Create object into database * @@ -341,11 +341,11 @@ class BookKeeping extends CommonObject */ public function createStd(User $user, $notrigger = false) { dol_syslog(__METHOD__, LOG_DEBUG); - + $error = 0; - + // Clean parameters - + if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -393,10 +393,10 @@ class BookKeeping extends CommonObject } if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql .= 'doc_date,'; @@ -435,55 +435,55 @@ class BookKeeping extends CommonObject $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).','; $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; - + $this->db->begin(); - + $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_CREATE',$user); // if ($result < 0) $error++; // // End call triggers } } - + // Commit or rollback if ($error) { $this->db->rollback(); - + return - 1 * $error; } else { $this->db->commit(); - + return $this->id; } } - + /** * Load object in memory from the database * * @param int $id Id object * @param string $ref Ref - * + * * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null) { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; @@ -510,15 +510,15 @@ class BookKeeping extends CommonObject } else { $sql .= ' AND t.rowid = ' . $id; } - + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); if ($numrows) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; - + $this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_type = $obj->doc_type; $this->doc_ref = $obj->doc_ref; @@ -537,7 +537,7 @@ class BookKeeping extends CommonObject $this->piece_num = $obj->piece_num; } $this->db->free($resql); - + if ($numrows) { return 1; } else { @@ -546,11 +546,11 @@ class BookKeeping extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Load object in memory from the database * @@ -560,14 +560,14 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) - * + * * @return int <0 if KO, >0 if OK */ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; @@ -620,18 +620,18 @@ class BookKeeping extends CommonObject } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); - } + } $this->lines = array (); - + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - + while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -648,21 +648,21 @@ class BookKeeping extends CommonObject $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->lines[] = $line; } $this->db->free($resql); - + return $num; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - - + + /** * Load object in memory from the database * @@ -672,14 +672,14 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) - * + * * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; @@ -723,7 +723,7 @@ class BookKeeping extends CommonObject if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } - + if (! empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } @@ -731,16 +731,16 @@ class BookKeeping extends CommonObject $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } $this->lines = array (); - + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - + while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -757,20 +757,20 @@ class BookKeeping extends CommonObject $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->lines[] = $line; } $this->db->free($resql); - + return $num; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Load object in memory from the database * @@ -785,9 +785,9 @@ class BookKeeping extends CommonObject */ public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= " t.numero_compte,"; $sql .= " SUM(t.debit) as debit,"; @@ -817,55 +817,55 @@ class BookKeeping extends CommonObject if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } - + $sql .= ' GROUP BY t.numero_compte'; - + if (! empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } $this->lines = array (); - + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - + while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->numero_compte = $obj->numero_compte; $line->debit = $obj->debit; $line->credit = $obj->credit; $this->lines[] = $line; } $this->db->free($resql); - + return $num; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Update object into database * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * * @return int <0 if KO, >0 if OK */ public function update(User $user, $notrigger = false) { $error = 0; - + dol_syslog(__METHOD__, LOG_DEBUG); - + // Clean parameters - + if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -911,10 +911,10 @@ class BookKeeping extends CommonObject if (isset($this->piece_num)) { $this->piece_num = trim($this->piece_num); } - + // Check parameters // Put here code to add a control on parameters values - + // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; @@ -934,69 +934,69 @@ class BookKeeping extends CommonObject $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); $sql .= ' WHERE rowid=' . $this->id; - + $this->db->begin(); - + $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + if (! $error && ! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} // // End call triggers } - + // Commit or rollback if ($error) { $this->db->rollback(); - + return - 1 * $error; } else { $this->db->commit(); - + return 1; } } - + /** * Delete object in database * * @param User $user User that deletes * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * * @return int <0 if KO, >0 if OK */ public function delete(User $user, $notrigger = false) { dol_syslog(__METHOD__, LOG_DEBUG); - + $error = 0; - + $this->db->begin(); - + if (! $error) { if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_DELETE',$user); // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} // // End call triggers } } - + if (! $error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql .= ' WHERE rowid=' . $this->id; - + $resql = $this->db->query($sql); if (! $resql) { $error ++; @@ -1004,19 +1004,19 @@ class BookKeeping extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } } - + // Commit or rollback if ($error) { $this->db->rollback(); - + return - 1 * $error; } else { $this->db->commit(); - + return 1; } } - + /** * Delete bookkepping by importkey * @@ -1025,25 +1025,25 @@ class BookKeeping extends CommonObject */ function deleteByImportkey($importkey) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE import_key = '" . $importkey . "'"; - + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR); $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } - + /** * Delete bookkepping by year * @@ -1053,14 +1053,14 @@ class BookKeeping extends CommonObject */ function deleteByYearAndJournal($delyear='', $journal='') { global $conf; - - if (empty($delyear) && empty($journal)) + + if (empty($delyear) && empty($journal)) { return -1; } - + $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1069,7 +1069,7 @@ class BookKeeping extends CommonObject if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -1079,11 +1079,11 @@ class BookKeeping extends CommonObject $this->db->rollback(); return -1; } - + $this->db->commit(); return 1; } - + /** * Delete bookkepping by piece number * @@ -1092,17 +1092,17 @@ class BookKeeping extends CommonObject */ function deleteMvtNum($piecenum) { global $conf; - + $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -1112,57 +1112,57 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } - + /** * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone - * + * * @return int New id of clone */ public function createFromClone($fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - + global $user; $error = 0; - $object = new Accountingbookkeeping($this->db); - + $object = new BookKeeping($this->db); + $this->db->begin(); - + // Load source object $object->fetch($fromid); // Reset object $object->id = 0; - + // Clear fields // ... - + // Create clone $result = $object->create($user); - + // Other options if ($result < 0) { $error ++; $this->errors = $object->errors; dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + // End if (! $error) { $this->db->commit(); - + return $object->id; } else { $this->db->rollback(); - + return - 1; } } - + /** * Initialise object with example values * Id must be 0 if object instance is a specimen @@ -1171,9 +1171,9 @@ class BookKeeping extends CommonObject */ public function initAsSpecimen() { global $user; - + $now=dol_now(); - + $this->id = 0; $this->doc_date = $now; $this->doc_type = ''; @@ -1192,7 +1192,7 @@ class BookKeeping extends CommonObject $this->code_journal = ''; $this->piece_num = ''; } - + /** * Load an accounting document into memory from database * @@ -1201,17 +1201,17 @@ class BookKeeping extends CommonObject */ public function fetchPerMvt($piecenum) { global $conf; - + $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + $this->piece_num = $obj->piece_num; $this->code_journal = $obj->code_journal; $this->doc_date = $this->db->jdate($obj->doc_date); @@ -1222,22 +1222,22 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Return next number movement * * @return string Next numero to use */ - public function getNextNumMvt() + public function getNextNumMvt() { global $conf; - + $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -1252,7 +1252,7 @@ class BookKeeping extends CommonObject return - 1; } } - + /** * Load all informations of accountancy document * @@ -1261,7 +1261,7 @@ class BookKeeping extends CommonObject */ function fetch_all_per_mvt($piecenum) { global $conf; - + $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; @@ -1269,17 +1269,17 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - + while ( $obj = $this->db->fetch_object($result) ) { - + $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -1294,7 +1294,7 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesmvt[] = $line; } } else { @@ -1302,10 +1302,10 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Export bookkeping * @@ -1314,27 +1314,27 @@ class BookKeeping extends CommonObject */ function export_bookkeping($model = 'ebp') { global $conf; - + $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); - + $resql = $this->db->query($sql); - + if ($resql) { $this->linesexport = array (); - + $num = $this->db->num_rows($resql); while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -1349,11 +1349,11 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesexport[] = $line; } $this->db->free($resql); - + return $num; } else { $this->error = "Error " . $this->db->lasterror(); @@ -1361,9 +1361,9 @@ class BookKeeping extends CommonObject return - 1; } } - - - + + + /** * Return list of accounts with label by chart of accounts * @@ -1378,11 +1378,11 @@ class BookKeeping extends CommonObject */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { global $conf; - + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - + $pcgver = $conf->global->CHARTOFACCOUNTS; - + $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; @@ -1391,82 +1391,82 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")"; $sql .= " ORDER BY account_number ASC"; - + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - + if (! $resql) { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); return - 1; } - + $out = ajax_combobox($htmlname, $event); - + $options = array(); $selected = null; - + while ($obj = $this->db->fetch_object($resql)) { $label = length_accountg($obj->account_number) . ' - ' . $obj->label; - + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; - + if ($select_in == 1) { $select_value_in = $obj->account_number; } if ($select_out == 1) { $select_value_out = $obj->account_number; } - + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number // Because same account_number can be share between different accounting_system and do have the same meaning if (($selectid != '') && $selectid == $select_value_in) { $selected = $select_value_out; } - + $options[$select_value_out] = $label; } - + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); $this->db->free($resql); return $out; } - - + + /** - * Description of a root accounting account + * Description of a root accounting account * * @param string $account Accounting account * @return string Root account */ function get_compte_racine($account = null) - { + { global $conf; $pcgver = $conf->global->CHARTOFACCOUNTS; - + $sql = "SELECT root.account_number, root.label as label"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $pcgver; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid"; - $sql .= " WHERE aa.account_number = '" . $account . "'"; + $sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; $sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } - + return $obj->label; - + } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); @@ -1474,8 +1474,8 @@ class BookKeeping extends CommonObject return -1; } } - - + + /** * Description of accounting account * @@ -1483,9 +1483,9 @@ class BookKeeping extends CommonObject * @return string Account desc */ function get_compte_desc($account = null) - { + { global $conf; - + $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; @@ -1495,20 +1495,20 @@ class BookKeeping extends CommonObject $sql .= " AND aa.active = 1"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } - - if(empty($obj->category)){ + + if(empty($obj->category)){ return $obj->label; }else{ return $obj->label.' ('.$obj->category.')'; - + } } else { $this->error = "Error " . $this->db->lasterror(); @@ -1516,7 +1516,7 @@ class BookKeeping extends CommonObject return -1; } } - + } diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 5428f4abdbf..c91b7276633 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -46,7 +46,7 @@ class Cpaiement /** */ - + public $code; public $libelle; public $type; @@ -56,7 +56,7 @@ class Cpaiement /** */ - + /** * Constructor @@ -83,7 +83,7 @@ class Cpaiement $error = 0; // Clean parameters - + if (isset($this->code)) { $this->code = trim($this->code); } @@ -103,14 +103,14 @@ class Cpaiement $this->module = trim($this->module); } - + // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - + $sql.= 'id,'; $sql.= 'code,'; $sql.= 'libelle,'; @@ -119,9 +119,9 @@ class Cpaiement $sql.= 'accountancy_code,'; $sql.= 'module'; - + $sql .= ') VALUES ('; - + $sql .= ' '.(! isset($this->id)?'NULL':$this->id).','; $sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").','; $sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").','; @@ -130,7 +130,7 @@ class Cpaiement $sql .= ' '.(! isset($this->accountancy_code)?'NULL':"'".$this->db->escape($this->accountancy_code)."'").','; $sql .= ' '.(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'"); - + $sql .= ')'; $this->db->begin(); @@ -202,7 +202,7 @@ class Cpaiement $obj = $this->db->fetch_object($resql); $this->id = $obj->id; - + $this->code = $obj->code; $this->libelle = $obj->libelle; $this->type = $obj->type; @@ -210,7 +210,7 @@ class Cpaiement $this->accountancy_code = $obj->accountancy_code; $this->module = $obj->module; - + } $this->db->free($resql); @@ -252,7 +252,7 @@ class Cpaiement $sql .= " t.accountancy_code,"; $sql .= " t.module"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; // Manage filter @@ -265,7 +265,7 @@ class Cpaiement if (count($sqlwhere) > 0) { $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); } - + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield,$sortorder); } @@ -279,10 +279,10 @@ class Cpaiement $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { - $line = new CpaiementLine(); + $line = new Cpaiement(); $line->id = $obj->id; - + $line->code = $obj->code; $line->libelle = $obj->libelle; $line->type = $obj->type; @@ -290,7 +290,7 @@ class Cpaiement $line->accountancy_code = $obj->accountancy_code; $line->module = $obj->module; - + $this->lines[$line->id] = $line; } @@ -320,7 +320,7 @@ class Cpaiement dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->code)) { $this->code = trim($this->code); } @@ -340,7 +340,7 @@ class Cpaiement $this->module = trim($this->module); } - + // Check parameters // Put here code to add a control on parameters values @@ -438,8 +438,8 @@ class Cpaiement return 1; } } - - + + /** * Initialise object with example values * Id must be 0 if object instance is a specimen @@ -449,7 +449,7 @@ class Cpaiement public function initAsSpecimen() { $this->id = 0; - + $this->code = ''; $this->libelle = ''; $this->type = ''; @@ -457,7 +457,7 @@ class Cpaiement $this->accountancy_code = ''; $this->module = ''; - + } } From 7556a604e364a6d4cb3d5517605170012277bf84 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 29 Jun 2017 16:30:57 +0200 Subject: [PATCH 015/109] fix travis --- .../class/accountancycategory.class.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 7668756a046..a7bab16b30d 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -429,7 +429,7 @@ class AccountancyCategory return - 1; } } - + public function getCats() { global $db, $langs, $user, $mysoc; @@ -462,7 +462,7 @@ class AccountancyCategory if ($num) { while ( $i < $num ) { $obj = $this->db->fetch_object($resql); - + $data[] = array ( 'rowid' => $obj->rowid, 'code' => $obj->code, @@ -483,10 +483,10 @@ class AccountancyCategory return - 1; } } - - - // calcule - + + + // calcule + const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/'; const PARENTHESIS_DEPTH = 10; @@ -535,10 +535,12 @@ class AccountancyCategory return 0; } - + /** * get cpts of category * + * @param int $cat_id Id accounting account category + * * @return array Result in table */ public function getCptsCat($cat_id) { @@ -554,7 +556,7 @@ class AccountancyCategory $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = ".$cat_id; $sql .= " ORDER BY t.account_number "; - + //echo $sql; $resql = $this->db->query($sql); @@ -582,5 +584,5 @@ class AccountancyCategory return -1; } } - + } From 7dc4eeddf04d0bfb6de78a5c4bcf6c793e32c405 Mon Sep 17 00:00:00 2001 From: KHELIFA Date: Thu, 29 Jun 2017 16:44:52 +0200 Subject: [PATCH 016/109] FIX: Function load_board in commande.class.php for warnings delay in dashboard --- htdocs/commande/class/commande.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 93df2f1aa0b..eb62d84ce48 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3243,7 +3243,8 @@ class Commande extends CommonOrder $response->nbtodo++; $generic_commande->statut = $obj->fk_statut; - $generic_commande->date_livraison = $obj->delivery_date; + $generic_commande->date_commande = $this->db->jdate($obj->date_commande); + $generic_commande->date_livraison = $this->db->jdate($obj->delivery_date); if ($generic_commande->hasDelay()) { $response->nbtodolate++; From 62f8aa8b40f1a45ee22a8ddfff25a54b462835f6 Mon Sep 17 00:00:00 2001 From: KHELIFA Date: Thu, 29 Jun 2017 16:49:30 +0200 Subject: [PATCH 017/109] Fix: In supplier order, show link Now for order date and delivery date --- htdocs/fourn/commande/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index bdd38ebc0b7..d49d9df85d2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2704,7 +2704,7 @@ elseif (! empty($object->id)) //print ''.$langs->trans("ToOrder").''; print ''.$langs->trans("OrderDate").''; $date_com = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - print $form->select_date($date_com,'',1,1,'',"commande",1,0,1); + print $form->select_date($date_com,'',1,1,'',"commande",1,1,1); print ''; print ''.$langs->trans("OrderMode").''; @@ -2756,7 +2756,7 @@ if ($action != 'makeorder') print ''; //print ''; print '\n"; print ""; - if (! $i) $totalarray['nbfield']++; + print '"; + if (! $i) $totalarray['nbfield']++; } // Action column diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index e9eb3d41859..e8fd04ac818 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -141,7 +141,7 @@ if ($id > 0 || ! empty($ref)) elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; - $sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,"; + $sql.= " f.facnumber, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; $sql.= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -232,23 +232,24 @@ if ($id > 0 || ! empty($ref)) $var=True; while ($i < min($num,$conf->liste_limit)) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($result); + $invoicestatic->id=$objp->facid; + $invoicestatic->ref=$objp->facnumber; + $societestatic->fetch($objp->socid); + $paiement = $invoicestatic->getSommePaiement(); $var=!$var; print ''; print '\n"; - $societestatic->fetch($objp->socid); print ''; print "\n"; print '"; print '\n"; print '\n"; - print ''; + print ''; print "\n"; $i++; From 7d4a093d9ebd49be669e43061e037dff7280f2d5 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:52:54 +0200 Subject: [PATCH 020/109] WAP alway decimal 2 digits --- .../fourn/class/fournisseur.product.class.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 38a1ea366c5..bcbaf18e9f5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,12 +699,13 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects to display in table format. - * @return string String with supplier price + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitl Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects + * to display in table format. + * @return string String with supplier price */ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { @@ -713,16 +714,18 @@ class ProductFournisseur extends Product $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= '
'.$langs->trans("Receive").'
'.$langs->trans("DeliveryDate").''; - print $form->select_date('','',1,1,'',"commande",1,0,1); + print $form->select_date('','',1,1,'',"commande",1,1,1); print "
".$langs->trans("Delivery")."\n"; From f79b72f724b67a4a2e7938b9cb56c8ee8d9c179b Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 29 Jun 2017 16:57:30 +0200 Subject: [PATCH 018/109] FIX edit sociale was emptying label --- htdocs/compta/sociales/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 92cb36059e4..1aecfdbdd08 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -196,7 +196,6 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr { $result=$object->fetch($id); - $object->lib=GETPOST('label'); $object->date_ech=$dateech; $object->periode=$dateperiod; $object->amount=price2num($amount); From ca6ce2ba8b0aa8fcb4568ce74646b13cc3d30393 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 30 Jun 2017 10:38:54 +0200 Subject: [PATCH 019/109] FIX status were wrong on product referent list --- htdocs/compta/facture/list.php | 8 ++++---- htdocs/product/stats/facture.php | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1d0a5ad7e9f..4ce8e0ed724 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1431,10 +1431,10 @@ if ($resql) // Status if (! empty($arrayfields['f.fk_statut']['checked'])) { - print ''; - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); - print "'; + print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); + print "
'; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->facnumber; print $invoicestatic->getNomUrl(1); print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; print dol_print_date($db->jdate($objp->datef),'day')."'.$objp->qty."'.price($objp->total_ht)."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'
'; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; foreach ($productFournList as $productFourn) { $out.= ''; + $out.= ''; $out.= ''; $out.= ''; } - $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + $out .= ''; } else { $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } From d0599cd9528dd9ad9e3e45d4930cf61bd6dd9159 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:54:04 +0200 Subject: [PATCH 021/109] Revert "WAP alway decimal 2 digits" This reverts commit 7d4a093d9ebd49be669e43061e037dff7280f2d5. --- .../fourn/class/fournisseur.product.class.php | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index bcbaf18e9f5..38a1ea366c5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,13 +699,12 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitl Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects - * to display in table format. - * @return string String with supplier price + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitle Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects to display in table format. + * @return string String with supplier price */ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { @@ -714,18 +713,16 @@ class ProductFournisseur extends Product $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'; + $out .= ''; + $out .= ''; + $out .= ''; foreach ($productFournList as $productFourn) { $out.= ''; - $out.= ''; $out.= ''; $out.= ''; } - $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + $out .= ''; } else { $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } From 574590a59860e3cda4189a4d0e59573fd4996fc1 Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:55:45 +0200 Subject: [PATCH 022/109] Add minimum qty column --- .../fourn/class/fournisseur.product.class.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 38a1ea366c5..bcbaf18e9f5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -699,12 +699,13 @@ class ProductFournisseur extends Product /** * Display price of product * - * @param int $showunitprice Show "Unit price" into output string - * @param int $showsuptitle Show "Supplier" into output string - * @param int $maxlen Max length of name - * @param integer $notooltip 1=Disable tooltip - * @param array $productFournList list of ProductFournisseur objects to display in table format. - * @return string String with supplier price + * @param int $showunitprice Show "Unit price" into output string + * @param int $showsuptitl Show "Supplier" into output string + * @param int $maxlen Max length of name + * @param integer $notooltip 1=Disable tooltip + * @param array $productFournList list of ProductFournisseur objects + * to display in table format. + * @return string String with supplier price */ function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array()) { @@ -713,16 +714,18 @@ class ProductFournisseur extends Product $out = ''; $langs->load("suppliers"); if (count($productFournList) > 0) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; foreach ($productFournList as $productFourn) { $out.= ''; + $out.= ''; $out.= ''; $out.= ''; } - $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; + $out .= ''; } else { $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } From 989084e4dece898320c368ac34f2561f8cb245eb Mon Sep 17 00:00:00 2001 From: fappels Date: Fri, 30 Jun 2017 10:56:05 +0200 Subject: [PATCH 023/109] WAP always 2 decimals --- htdocs/langs/en_US/suppliers.lang | 2 +- htdocs/product/list.php | 46 +++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 079b588167f..28c5fe39d0d 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -43,4 +43,4 @@ NotTheGoodQualitySupplier=Wrong quality ReputationForThisProduct=Reputation BuyerName=Buyer name AllProductServicePrices=All product / service prices -BuyingPriceNumShort=Nbr of Buying prices +BuyingPriceNumShort=Supplier prices diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 50bd61fad17..cb31de75892 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -829,31 +829,31 @@ else } // Number of buy prices - if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - if ($obj->tobuy) - { - if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList),$htmltext); - } - } - print ''; - } + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + if ($obj->tobuy) + { + if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList),$htmltext); + } + } + print ''; + } // WAP - if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - if ($obj->tobuy) - { - print price($product_static->pmp, 1, $langs, 1, 2, 1, 'auto'); - } - print ''; - } - + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + if ($obj->tobuy) + { + print price($product_static->pmp, 1, $langs, 1, 2, 2, 'auto'); + } + print ''; + } + // Limit alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { From ea504a0516b2f521408270423803f6ef9d0992f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Jun 2017 11:08:40 +0200 Subject: [PATCH 024/109] FIX We should be able to insert data with value '0' into const --- htdocs/core/modules/DolibarrModules.class.php | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 8e526baa241..f0dce5f37a1 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -50,13 +50,13 @@ class DolibarrModules // Can not be abstract, because we need to insta * @since 4.0.0 */ public $editor_name; - + /** * @var string URL of module at publisher site * @since 4.0.0 */ public $editor_url; - + /** * @var string Family * @see familyinfo @@ -80,13 +80,13 @@ class DolibarrModules // Can not be abstract, because we need to insta * */ public $familyinfo; - + /** * @var int Module position * @since 3.9.0 */ public $module_position=500; - + /** * @var string Module name * @@ -214,7 +214,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * HTML content supported. */ public $descriptionlong; - + /** * @var string[] Module language files */ @@ -254,7 +254,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * @var bool Module is enabled globally (Multicompany support) */ public $core_enabled; - + /** * @var string Relative path to module style sheet * @deprecated @@ -573,9 +573,9 @@ class DolibarrModules // Can not be abstract, because we need to insta { global $langs; $langs->load("admin"); - + if (empty($this->descriptionlong)) return ''; - + // If module description translation does not exist using its unique id, we can use its name to find translation if (is_array($this->langfiles)) { @@ -586,7 +586,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } return $langs->trans($this->descriptionlong); } - + /** * Gives the publisher name * @@ -596,7 +596,7 @@ class DolibarrModules // Can not be abstract, because we need to insta { return $this->editor_name; } - + /** * Gives the publisher url * @@ -606,7 +606,7 @@ class DolibarrModules // Can not be abstract, because we need to insta { return $this->editor_url; } - + /** * Gives module version (translated if param $translated is on) * For 'experimental' modules, gives 'experimental' translation @@ -709,7 +709,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } } - + /** * Gives the last date of activation * @@ -718,11 +718,11 @@ class DolibarrModules // Can not be abstract, because we need to insta function getLastActivationDate() { global $conf; - + $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->const_name."'"; $sql.= " AND entity IN (0, ".$conf->entity.")"; - + dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -731,11 +731,11 @@ class DolibarrModules // Can not be abstract, because we need to insta $obj=$this->db->fetch_object($resql); if ($obj) return $this->db->jdate($obj->tms); } - + return ''; } - - + + /** * Insert constants for module activation * @@ -836,7 +836,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data') { @@ -854,7 +854,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data') { @@ -872,7 +872,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'data') { @@ -890,7 +890,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $files[] = $file; } sort($files); - foreach ($files as $file) + foreach ($files as $file) { if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,6) == 'update') { @@ -1030,19 +1030,19 @@ class DolibarrModules // Can not be abstract, because we need to insta //$titre = $this->boxes[$key][0]; $file = $this->boxes[$key]['file']; //$note = $this->boxes[$key][2]; - + // TODO If the box is also included by another module and the other module is still on, we should not remove it. // For the moment, we manage this with hard coded exception //print "Remove box ".$file.'
'; if ($file == 'box_graph_product_distribution.php') { - if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) + if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) { dol_syslog("We discard disabling of module ".$file." because another module still active require it."); continue; } } - + if (empty($file)) $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; // For backward compatibility if ($this->db->type == 'sqlite3') { @@ -1117,7 +1117,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $status = isset($this->cronjobs[$key]['status'])?$this->cronjobs[$key]['status']:''; $priority = isset($this->cronjobs[$key]['priority'])?$this->cronjobs[$key]['priority']:''; $test = isset($this->cronjobs[$key]['test'])?$this->cronjobs[$key]['test']:''; // Line must be visible - + // Search if boxes def already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; $sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'"; @@ -1329,11 +1329,11 @@ class DolibarrModules // Can not be abstract, because we need to insta // Clean if (empty($visible)) $visible='0'; - if (empty($val)) $val=''; + if (empty($val) && $val != '0') $val=''; $sql = "SELECT count(*)"; $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE ".$this->db->decrypt('name')." = '".$name."'"; + $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'"; $sql.= " AND entity = ".$entity; $result=$this->db->query($sql); @@ -1347,7 +1347,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " VALUES ("; $sql.= $this->db->encrypt($name,1); $sql.= ",'".$type."'"; - $sql.= ",".($val?$this->db->encrypt($val,1):"''"); + $sql.= ",".(($val != '')?$this->db->encrypt($val,1):"''"); $sql.= ",".($note?"'".$this->db->escape($note)."'":"null"); $sql.= ",'".$visible."'"; $sql.= ",".$entity; @@ -1552,7 +1552,7 @@ class DolibarrModules // Can not be abstract, because we need to insta /** * Removes access rights - * + * * @return int Error count (0 if OK) */ function delete_permissions() @@ -1585,7 +1585,7 @@ class DolibarrModules // Can not be abstract, because we need to insta global $user; if (! is_array($this->menu) || empty($this->menu)) return 0; - + require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; $err=0; From 11cd4e1164d8e3dd0380afa9e70f4566e7497fe5 Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Fri, 30 Jun 2017 11:29:37 +0200 Subject: [PATCH 025/109] Fix Binding Customer --- htdocs/accountancy/customer/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 75c1a59aa30..2663ab1d779 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -189,7 +189,8 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accounta $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND product_type <= 2"; -$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')"; +$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='' OR p.accountancy_code_sell NOT IN + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid ='" . $conf->global->CHARTOFACCOUNTS . "'))"; // Add search filter like if ($search_lineid) { $sql .= natural_search("l.rowid", $search_lineid, 1); From 2c795da664e5c932bade64139ae121849ddbd760 Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Fri, 30 Jun 2017 11:30:20 +0200 Subject: [PATCH 026/109] Fix Binding Supplier --- htdocs/accountancy/supplier/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index ff39aad67f4..3077f8f337b 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -191,7 +191,8 @@ $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountan $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND product_type <= 2"; -$sql.= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')"; +$sql.= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy =''OR p.accountancy_code_buy NOT IN + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid ='" . $conf->global->CHARTOFACCOUNTS . "'))"; // Add search filter like if ($search_lineid) { $sql .= natural_search("l.rowid", $search_lineid, 1); From f978b0795a5d1d119d5016cc5d6f3e83ae776deb Mon Sep 17 00:00:00 2001 From: Darkjeff Date: Fri, 30 Jun 2017 11:31:24 +0200 Subject: [PATCH 027/109] Fix action in journal --- htdocs/accountancy/journal/bankjournal.php | 6 +++--- htdocs/accountancy/journal/purchasesjournal.php | 6 +++--- htdocs/accountancy/journal/sellsjournal.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index ed8d1d7501a..056f3644770 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -75,7 +75,7 @@ $date_endyear = GETPOST('date_endyear'); $in_bookkeeping = GETPOST('in_bookkeeping'); $now = dol_now(); -$action = GETPOST('action','alpha'); +$action = GETPOST('action','aZ09'); // Security check if ($user->societe_id > 0 && empty($id_journal)) @@ -612,7 +612,7 @@ if (! $error && $action == 'writebookkeeping') { } // Export -if ($action == 'export_csv') { +if ($action == 'exportcsv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -760,7 +760,7 @@ if (empty($action) || $action == 'view') {