From 8670a89ecb8f6742420486dc20125e680d62c740 Mon Sep 17 00:00:00 2001 From: Cedric Date: Thu, 14 Aug 2014 08:41:24 +0200 Subject: [PATCH 01/34] Fix #1544: Can remove date from invoice --- ChangeLog | 1 + htdocs/compta/facture.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6e81703b33a..2fc6cb6a5bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ Fix: Link product, In list view and label product Fix: visible task into area "time" for "My task" must limit task to tasks i am assigned to. Fix: When disabled, all fields to add time into task line must be disabled. Fix: Missing include files.lib.php in some pages ti use dol_delete_recursive +Fix: [ bug #1544 ] Can remove date from invoice ***** ChangeLog for 3.5.4 compared to 3.5.3 ***** Fix: Hide title of event when agenda module disabled. diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index bd5cdb0e9c8..50da8aab884 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -282,7 +282,15 @@ else if ($action == 'setinvoicedate' && $user->rights->facture->creer) { $object->fetch($id); $old_date_lim_reglement=$object->date_lim_reglement; - $object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']); + $date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']); + if (empty($date)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); + exit; + + } + $object->date=$date; $new_date_lim_reglement=$object->calculate_date_lim_reglement(); if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement=$new_date_lim_reglement; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date; From c6637207f88ad57bf3a6586d5899ad560ff18723 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 14 Aug 2014 14:25:41 +0200 Subject: [PATCH 02/34] Fix : VAT and NPR rates where coming from multiprice... --- htdocs/compta/facture.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 07960ed2c2c..1933bfe4f7c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1254,8 +1254,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $price_min = $prod->multiprices_min[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + //$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + //$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; } else { From e7a8de18bf17c269830abc92fd4cf3d6888f763c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Aug 2014 15:05:42 +0200 Subject: [PATCH 03/34] Fix: Minimum size for captcha --- htdocs/theme/amarok/style.css.php | 4 ++++ htdocs/theme/auguria/style.css.php | 3 +++ htdocs/theme/bureau2crea/style.css.php | 3 +++ htdocs/theme/cameleo/style.css.php | 3 +++ htdocs/theme/eldy/style.css.php | 3 +++ 5 files changed, 16 insertions(+) diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index eda6e01f1f4..54bd05b6762 100644 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -590,6 +590,10 @@ div.login { height: 16px; } +#securitycode { + min-width: 60px; +} + img.login, img.printer, img.entity { /* padding: dol_optimize_smallscreen?'0':'8')?>px 0px 0px 0px; */ margin:2px 0px 0px 0px; diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 946f46ad141..43a5bf87219 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -545,6 +545,9 @@ form#login { background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index 92d6b4f242f..c9619448b9f 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -578,6 +578,9 @@ form#login { background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index 8b4172522aa..4e83ab1c2a4 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -649,6 +649,9 @@ form#login { background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 309d6f87e46..19b994ffc32 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -862,6 +862,9 @@ div#login_left, div#login_right { table.login_table tr td table.none tr td { padding: 2px; } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } From 86f1d59e3cfa7d82f7ed3461bb3debd95473321d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 17 Aug 2014 15:12:20 +0200 Subject: [PATCH 04/34] Fix: broken feature: add param for use only "disabled" with delConstant and "enabled" with setConstant --- htdocs/core/js/lib_head.js | 21 ++++++++++++--------- htdocs/core/lib/ajax.lib.php | 14 ++++++++------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js index 9221843d575..18dc2258c70 100644 --- a/htdocs/core/js/lib_head.js +++ b/htdocs/core/js/lib_head.js @@ -1,5 +1,5 @@ // Copyright (C) 2005-2013 Laurent Destailleur -// Copyright (C) 2005-2012 Regis Houssin +// Copyright (C) 2005-2014 Regis Houssin // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -631,7 +631,7 @@ function hideMessage(fieldId,message) { /* * TODO Used by admin page only ? */ -function setConstant(url, code, input, entity) { +function setConstant(url, code, input, entity, strict) { $.get( url, { action: "set", name: code, @@ -642,7 +642,7 @@ function setConstant(url, code, input, entity) { $("#del_" + code).show(); $.each(input, function(type, data) { // Enable another element - if (type == "disabled") { + if (type == "disabled" && strict != 1) { $.each(data, function(key, value) { var newvalue=((value.search("^#") < 0 && value.search("^\.") < 0) ? "#" : "") + value; $(newvalue).removeAttr("disabled"); @@ -654,7 +654,10 @@ function setConstant(url, code, input, entity) { } else if (type == "enabled") { $.each(data, function(key, value) { var newvalue=((value.search("^#") < 0 && value.search("^\.") < 0) ? "#" : "") + value; - $(newvalue).attr("disabled", true); + if (strict == 1) + $(newvalue).removeAttr("disabled"); + else + $(newvalue).attr("disabled", true); if ($(newvalue).hasClass("butAction") == true) { $(newvalue).removeClass("butAction"); $(newvalue).addClass("butActionRefused"); @@ -686,7 +689,7 @@ function setConstant(url, code, input, entity) { /* * TODO Used by admin page only ? */ -function delConstant(url, code, input, entity) { +function delConstant(url, code, input, entity, strict) { $.get( url, { action: "del", name: code, @@ -706,7 +709,7 @@ function delConstant(url, code, input, entity) { $(newvalue).addClass("butActionRefused"); } }); - } else if (type == "enabled") { + } else if (type == "enabled" && strict != 1) { $.each(data, function(key, value) { var newvalue=((value.search("^#") < 0 && value.search("^\.") < 0) ? "#" : "") + value; $(newvalue).removeAttr("disabled"); @@ -740,7 +743,7 @@ function delConstant(url, code, input, entity) { /* * TODO Used by admin page only ? */ -function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton) { +function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict) { var boxConfirm = box; $("#confirm_" + code) .attr("title", boxConfirm.title) @@ -756,9 +759,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, text : yesButton, click : function() { if (action == "set") { - setConstant(url, code, input, entity); + setConstant(url, code, input, entity, strict); } else if (action == "del") { - delConstant(url, code, input, entity); + delConstant(url, code, input, entity, strict); } // Close dialog $(this).dialog("close"); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index e24d12dbc52..46aed9ec1c9 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2012 Regis Houssin + * Copyright (C) 2007-2014 Regis Houssin * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -380,9 +380,10 @@ function ajax_combobox($htmlname, $event=array(), $minLengthToAutocomplete=0) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param int $entity Entity to set * @param int $revertonoff Revert on/off + * @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant * @return void */ -function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) +function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0) { global $conf, $langs; @@ -395,6 +396,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) var url = \''.DOL_URL_ROOT.'/core/ajax/constantonoff.php\'; var code = \''.$code.'\'; var entity = \''.$entity.'\'; + var strict = \''.$strict.'\'; var yesButton = "'.dol_escape_js($langs->transnoentities("Yes")).'"; var noButton = "'.dol_escape_js($langs->transnoentities("No")).'"; @@ -403,9 +405,9 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) if (input.alert && input.alert.set) { if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton; if (input.alert.set.noButton) noButton = input.alert.set.noButton; - confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton); + confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton, strict); } else { - setConstant(url, code, input, entity); + setConstant(url, code, input, entity, strict); } }); @@ -414,9 +416,9 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0) if (input.alert && input.alert.del) { if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton; if (input.alert.del.noButton) noButton = input.alert.del.noButton; - confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton); + confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton, strict); } else { - delConstant(url, code, input, entity); + delConstant(url, code, input, entity, strict); } }); }); From 50eb2e2c152a936644997696d6849ce51407b8d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Aug 2014 18:24:57 +0200 Subject: [PATCH 05/34] Fix: backlink was wrong after deleting product or service. --- htdocs/product/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index e6a5075bd3b..d96aac8fc33 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -389,7 +389,7 @@ if (empty($reshook)) if ($result > 0) { - header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref)); + header('Location: '.DOL_URL_ROOT.'/product/liste.php?type='.$object->type.'&delprod='.urlencode($object->ref)); exit; } else From 9fdfc740dee3129ef6ab0436321f81088e01f92e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Aug 2014 20:23:06 +0200 Subject: [PATCH 06/34] Fix: define new ref before trigger --- htdocs/commande/class/commande.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6b88ff3553d..795c2e26526 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2011 Jean Heimburger @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU *General Public License as published by + * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * @@ -290,6 +290,13 @@ class Commande extends CommonOrder } } + // Set new ref and current status + if (! $error) + { + $this->ref = $num; + $this->statut = 1; + } + if (! $error) { // Appel des triggers @@ -300,13 +307,6 @@ class Commande extends CommonOrder // Fin appel triggers } - // Set new ref and current status - if (! $error) - { - $this->ref = $num; - $this->statut = 1; - } - if (! $error) { $this->db->commit(); From ecd90ddbffd271badedfdd3b3d43c6338abb5baf Mon Sep 17 00:00:00 2001 From: Cubexed Date: Mon, 18 Aug 2014 23:02:04 +0200 Subject: [PATCH 07/34] Enables the fetching and saving of start and end dates in supplier order lines. --- .../class/fournisseur.commande.class.php | 26 ++++++++++----- htdocs/fourn/commande/fiche.php | 32 ++++++++++++++++--- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 42ed12b1472..5eeadad207e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -210,7 +210,8 @@ class CommandeFournisseur extends CommonOrder $sql.= " l.tva_tx, l.remise_percent, l.subprice,"; $sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,"; $sql.= " l.total_ht, l.total_tva, l.total_ttc,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,"; + $sql.= " l.date_start, l.date_end"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= " WHERE l.fk_commande = ".$this->id; @@ -258,6 +259,9 @@ class CommandeFournisseur extends CommonOrder $line->ref_fourn = $objp->ref_supplier; // TODO deprecated $line->ref_supplier = $objp->ref_supplier; // Reference supplier + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $this->lines[$i] = $line; $i++; @@ -1720,9 +1724,11 @@ class CommandeFournisseur extends CommonOrder * @param int $info_bits Miscellaneous informations * @param int $type Type of line (0=product, 1=service) * @param int $notrigger Disable triggers + * @param timestamp $date_start Date start of service + * @param timestamp $date_end Date end of service * @return int < 0 if error, > 0 if ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='') { global $mysoc; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type"); @@ -1783,10 +1789,8 @@ class CommandeFournisseur extends CommonOrder $sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'"; $sql.= ",qty='".price2num($qty)."'"; - /*if ($date_end) { $sql.= ",date_start='$date_end'"; } - else { $sql.=',date_start=null'; } - if ($date_end) { $sql.= ",date_end='$date_end'"; } - else { $sql.=',date_end=null'; }*/ + $sql.= ",date_start=".(! empty($date_start)?"'".$this->db->idate($date_start)."'":"null"); + $sql.= ",date_end=".(! empty($date_end)?"'".$this->db->idate($date_end)."'":"null"); $sql.= ",info_bits='".$info_bits."'"; $sql.= ",total_ht='".price2num($total_ht)."'"; $sql.= ",total_tva='".price2num($total_tva)."'"; @@ -2007,7 +2011,7 @@ class CommandeFournisseur extends CommonOrder /** * Classe de gestion des lignes de commande */ -class CommandeFournisseurLigne +class CommandeFournisseurLigne extends CommonOrderLine { // From llx_commandedet var $qty; @@ -2028,6 +2032,8 @@ class CommandeFournisseurLigne var $total_ttc; var $info_bits; var $special_code; + var $date_start; + var $date_end; // From llx_product var $libelle; // Label produit @@ -2060,7 +2066,8 @@ class CommandeFournisseurLigne $sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql.= ' cd.total_localtax1, cd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,'; + $sql.= ' cd.date_start, cd.date_end'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; $sql.= ' WHERE cd.rowid = '.$rowid; @@ -2091,6 +2098,9 @@ class CommandeFournisseurLigne $this->product_libelle = $objp->product_libelle; $this->product_desc = $objp->product_desc; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + $this->db->free($result); return 1; } diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index e536c81f21c..1a28208c3a5 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -80,6 +80,9 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +//Date prefix +$date_pf = ''; + // Load object if ($id > 0 || ! empty($ref)) { @@ -190,6 +193,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) // Set if we used free entry or predefined product $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year')); if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -275,7 +280,12 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $productsupplier->fourn_ref, $remise_percent, 'HT', - $type + $pu_ttc, + $type, + '', + '', + $date_start, + $date_end ); } if ($idprod == -2 || $idprod == 0) @@ -313,14 +323,14 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { $price_base_type = 'HT'; $ht = price2num($_POST['price_ht']); - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type); + $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end); } else { $ttc = price2num($_POST['price_ttc']); $ht = $ttc / (1 + ($tauxtva / 100)); $price_base_type = 'HT'; - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type); + $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end); } } @@ -392,6 +402,9 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer if (!$res) dol_print_error($db); } + $date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year')); + $localtax1_tx=get_localtax($_POST['tva_tx'],1,$mysoc,$object->thirdparty); $localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty); @@ -406,7 +419,10 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer $localtax2_tx, 'HT', 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type + isset($_POST["type"])?$_POST["type"]:$line->product_type, + false, + $date_start, + $date_end ); unset($_POST['qty']); unset($_POST['type']); @@ -416,6 +432,8 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer unset($_POST['np_desc']); unset($_POST['pu']); unset($_POST['tva_tx']); + unset($_POST['date_start']); + unset($_POST['date_end']); unset($localtax1_tx); unset($localtax2_tx); if ($result >= 0) @@ -1744,6 +1762,12 @@ elseif (! empty($object->id)) $doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); $doleditor->Create(); + print '
'; + print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,''); + print ' '.$langs->trans('to').' '; + print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,''); + print ''; print ''; print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc); From b0163fbed25b3b4bef00d3ab07b65fc96668afca Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Fri, 22 Aug 2014 16:17:45 +0200 Subject: [PATCH 08/34] FIX error sql on update ficheinter --- htdocs/fichinter/class/fichinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index bd1306b0cf6..3055a73c73c 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -235,7 +235,7 @@ class Fichinter extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; - $sql.= ", description = '".$this->db->escape($this->description)."'"; + $sql.= "description = '".$this->db->escape($this->description)."'"; $sql.= ", duree = ".$this->duree; $sql.= ", fk_projet = ".$this->fk_project; $sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); From 28ad819ab4a9e3f7c3de6b593ce5e1dcb636034e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Aug 2014 09:49:15 +0200 Subject: [PATCH 09/34] Fix: error in strict mode --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2b84f51cb0d..7f12b4ee14b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1206,7 +1206,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu else dol_print_error($db); $db->free($resql); } - if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP + if (!empty($conf->ftp->enabled) && $mainmenu == 'ftp') // Entry for FTP { $MAXFTP=20; $i=1; From cdd716eb9d126c784a34c5ab35cae7ad78ce2c46 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 10:44:40 +0200 Subject: [PATCH 10/34] Fix: error with php strict mode --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7f12b4ee14b..83fcfca04bc 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1176,7 +1176,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,(empty($user->societe_id)?0:1),'eldy',$tabMenu); // We update newmenu for special dynamic menus - if ($user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account + if (!empty($user->rights->banque->lire) && $mainmenu == 'bank') // Entry for each bank account { $sql = "SELECT rowid, label, courant, rappro, courant"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; From a446318649ed655967f0f42a8f71fd48ab5103db Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 19:02:13 +0200 Subject: [PATCH 11/34] Fix: strict mode anarchy ;-) check your variable please --- htdocs/core/tpl/document_actions_pre_headers.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php index ca6929331ec..b386391cec2 100644 --- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php @@ -74,7 +74,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') setEventMessage($langs->trans("ErrorFailedToDeleteLink", $link->label), 'errors'); } } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id.($withproject?'&withproject=1':'')); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id.(!empty($withproject)?'&withproject=1':'')); exit; } } From 4fdd98c4a75b719d3b0729fadca6d9eca138ac50 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:34:50 +0200 Subject: [PATCH 12/34] Fix: another strict mode alert --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 88a931a3d8a..4b1e2e5c4ed 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -268,7 +268,7 @@ class FormFile if (! empty($iconPDF)) { return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } - $printer = ($user->rights->printipp->read && $conf->printipp->enabled)?true:false; + $printer = (!empty($user->rights->printipp->read) && !empty($conf->printipp->enabled))?true:false; $hookmanager->initHooks(array('formfile')); $forname='builddoc'; $out=''; From 48f9ef25740d6e188e2ccf3f5b3c14732911e030 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:52:20 +0200 Subject: [PATCH 13/34] Fix: php strict mode saga --- htdocs/core/class/html.formfile.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 4b1e2e5c4ed..51a27c7f860 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2010-2012 Regis Houssin - * Copyright (c) 2010 Juanjo Menent - * Copyright (c) 2013 Charles-Fr BENKE - * Copyright (C) 2013 Cédric Salvador - * Copyright (c) 2014 Marcos García +/* Copyright (C) 2008-2013 Laurent Destailleur + * Copyright (C) 2010-2014 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2013 Charles-Fr BENKE + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2014 Marcos García * * 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 @@ -513,11 +513,11 @@ class FormFile $out.= $genbutton; $out.= ''; - if($hookmanager->hooks['formfile']) + if (!empty($hookmanager->hooks['formfile'])) { foreach($hookmanager->hooks['formfile'] as $module) { - if(method_exists($module, 'formBuilddocLineOptions')) $out .= ''; + if (method_exists($module, 'formBuilddocLineOptions')) $out .= ''; } } $out.= ''; From 1aad1b6acd7decfce50a4d19602d6e1ab373950d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 19:32:41 +0200 Subject: [PATCH 14/34] Fix: strict mode --- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 8f884ee0f7b..68695fa2340 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -131,7 +131,7 @@ class InterfaceActionsAuto $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); - if ($object->prefix) $object->actionmsg.=" (".$object->prefix.")"; + if (!empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; //$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client); //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; From ff04729a07ca1b82bb8499d318fc686b2ba2d512 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 19:32:41 +0200 Subject: [PATCH 15/34] Fix: strict mode --- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 68695fa2340..32700488cb1 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -131,7 +131,7 @@ class InterfaceActionsAuto $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); - if (!empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; + if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; //$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client); //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; From 4fe83ebbf908a23a6a4730a4bafefa4c96d55d62 Mon Sep 17 00:00:00 2001 From: Damian Serrano Thode Date: Fri, 29 Aug 2014 11:34:07 +0200 Subject: [PATCH 16/34] Contract never shown on interventions Column fk_contrat is never read from the database, so it is never shown in the corresponding field of the intervention, even though you have set it choosing the contract from the dropdown. --- htdocs/fichinter/class/fichinter.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 49db958fa32..7e327eb896a 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -278,7 +278,7 @@ class Fichinter extends CommonObject $sql.= " f.datec,"; $sql.= " f.date_valid as datev,"; $sql.= " f.tms as datem,"; - $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams"; + $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if ($ref) $sql.= " WHERE f.ref='".$this->db->escape($ref)."'"; else $sql.= " WHERE f.rowid=".$rowid; @@ -304,6 +304,7 @@ class Fichinter extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->modelpdf = $obj->model_pdf; + $this->fk_contrat = $obj->fk_contrat; $this->extraparams = (array) json_decode($obj->extraparams, true); From b25db97c2815dc574e5faf2e960d90e899184e0b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 05:30:37 +0200 Subject: [PATCH 17/34] Typo --- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/agenda.lib.php | 4 ++-- htdocs/core/lib/bank.lib.php | 2 +- htdocs/core/lib/categories.lib.php | 2 +- htdocs/core/lib/contact.lib.php | 2 +- htdocs/core/lib/contract.lib.php | 2 +- htdocs/core/lib/ecm.lib.php | 8 ++++---- htdocs/core/lib/emailing.lib.php | 2 +- htdocs/core/lib/fichinter.lib.php | 2 +- htdocs/core/lib/fiscalyear.lib.php | 2 +- htdocs/core/lib/fourn.lib.php | 4 ++-- htdocs/core/lib/order.lib.php | 2 +- htdocs/core/lib/prelevement.lib.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/project.lib.php | 6 +++--- htdocs/core/lib/propal.lib.php | 2 +- htdocs/core/lib/sendings.lib.php | 4 ++-- htdocs/core/lib/stock.lib.php | 2 +- htdocs/core/lib/tax.lib.php | 2 +- htdocs/core/lib/trip.lib.php | 2 +- htdocs/core/lib/usergroups.lib.php | 4 ++-- 21 files changed, 30 insertions(+), 30 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index b6f2b02567a..14963b72288 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -508,7 +508,7 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function security_prepare_head() { diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index a0c1e3f1b4b..007f8474721 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -360,7 +360,7 @@ function show_array_last_actions_done($max=5) /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function agenda_prepare_head() { @@ -405,7 +405,7 @@ function agenda_prepare_head() * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function actions_prepare_head($object) { diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index c17c78bc8e1..349cb15063f 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -28,7 +28,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function bank_prepare_head($object) { diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index fb3a0210ef6..4d020526e44 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -27,7 +27,7 @@ * * @param Object $object Object related to tabs * @param string $type Type of category - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function categories_prepare_head($object,$type) { diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index b729aae2589..2518f7b7883 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -26,7 +26,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function contact_prepare_head($object) { diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 1086d4dcd14..e51f7594ac9 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -26,7 +26,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function contract_prepare_head($object) { diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index 1257d6a9bd1..2f12976e49f 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -27,7 +27,7 @@ * Prepare array with list of different ecm main dashboard * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_prepare_dasboard_head($object) { @@ -64,7 +64,7 @@ function ecm_prepare_dasboard_head($object) * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_prepare_head($object) { @@ -84,7 +84,7 @@ function ecm_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_file_prepare_head($object) { @@ -104,7 +104,7 @@ function ecm_file_prepare_head($object) * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_prepare_head_fm($object) { diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index 6c06a1eccb2..613b12dadad 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function emailing_prepare_head($object) { diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 01d79cdcabe..342a35a3d70 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -28,7 +28,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function fichinter_prepare_head($object) { diff --git a/htdocs/core/lib/fiscalyear.lib.php b/htdocs/core/lib/fiscalyear.lib.php index 60b2c810294..1db099b24bf 100644 --- a/htdocs/core/lib/fiscalyear.lib.php +++ b/htdocs/core/lib/fiscalyear.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function fiscalyear_prepare_head($object) { diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 171eda67a90..58d553e36d5 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function facturefourn_prepare_head($object) { @@ -92,7 +92,7 @@ function facturefourn_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ordersupplier_prepare_head($object) { diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 948bd74281c..43427acd59a 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function commande_prepare_head($object) { diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php index c6305423a96..dde5981cf75 100644 --- a/htdocs/core/lib/prelevement.lib.php +++ b/htdocs/core/lib/prelevement.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function prelevement_prepare_head($object) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index a252b361dcf..d8f814e06c3 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -29,7 +29,7 @@ * * @param Object $object Object related to tabs * @param User $user Object user - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function product_prepare_head($object, $user) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 3a4a2dc6035..e44b0dd413c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function project_prepare_head($object) { @@ -113,7 +113,7 @@ function project_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function task_prepare_head($object) { @@ -170,7 +170,7 @@ function task_prepare_head($object) /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function project_admin_prepare_head() { diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 3a5b25da295..bc0c7cae868 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -27,7 +27,7 @@ * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function propal_prepare_head($object) { diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index d2f3bf563c6..d2ff595b734 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function shipping_prepare_head($object) { @@ -85,7 +85,7 @@ function shipping_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function delivery_prepare_head($object) { diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index 2ebbb529407..3305f76875d 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function stock_prepare_head($object) { diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 164d346ac1c..62e46b7b9f7 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function tax_prepare_head($object) { diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index 7d58e9e01b1..ae38a1bf706 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function trip_prepare_head($object) { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 97354bd08ab..276efe85f02 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -27,7 +27,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function user_prepare_head($object) { @@ -178,7 +178,7 @@ function group_prepare_head($object) /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function user_admin_prepare_head() { From 2d14e53b4529bdb6fc497744d058c3e83f69079d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Aug 2014 19:58:38 +0200 Subject: [PATCH 18/34] Fix: Pb with pgsql --- htdocs/core/db/pgsql.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 1200deee93e..0b0bc8c8a5c 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -298,6 +298,9 @@ class DoliDBPgsql extends DoliDB $line=str_replace(' LIKE \'',' ILIKE \'',$line); $line=str_replace(' LIKE BINARY \'',' LIKE \'',$line); + // Replace INSERT IGNORE into INSERT + $line=preg_replace('/^INSERT IGNORE/','INSERT',$line); + // Delete using criteria on other table must not declare twice the deleted table // DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable if (preg_match('/DELETE FROM ([a-z_]+) USING ([a-z_]+), ([a-z_]+)/i',$line,$reg)) From 20475ba3e88ea084850c281890c6f1fdc631da4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Aug 2014 20:19:27 +0200 Subject: [PATCH 19/34] Fix: sql request not compatible with pgsql Conflicts: htdocs/core/ajax/ziptown.php --- htdocs/core/ajax/ziptown.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 80f6cd9bd63..291d7a6647d 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -65,9 +65,10 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; $sql.= ", p.rowid as fk_country, p.code as country_code, p.libelle as country"; $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; - $sql.= " FROM (".MAIN_DB_PREFIX."c_ziptown as z,".MAIN_DB_PREFIX."c_pays as p)"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; + $sql.= " ".MAIN_DB_PREFIX."c_pays as p"; $sql.= " WHERE z.fk_pays = p.rowid"; $sql.= " AND z.active = 1 AND p.active = 1"; if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; @@ -81,8 +82,8 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) $sql.= ", p.code as country_code, p.libelle as country"; $sql.= ", d.code_departement as county_code , d.nom as county"; $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON fk_departement = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_pays as p ON fk_pays = p.rowid'; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid'; $sql.= " WHERE"; if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; From 445bac25fec24d8456734ecbdd1cef560875a36a Mon Sep 17 00:00:00 2001 From: Drosis Nikos Date: Sat, 30 Aug 2014 23:57:37 +0300 Subject: [PATCH 20/34] Can change size of Logo picture --- htdocs/core/lib/pdf.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e0c6c9ee0e0..3c56cfcae3d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -269,7 +269,9 @@ function pdf_getPDFFontSize($outputlangs) */ function pdf_getHeightForLogo($logo, $url = false) { - $height=22; $maxwidth=130; + global $conf; + $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); + $maxwidth=130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $tmp=dol_getImageSize($logo, $url); if ($tmp['height']) From fd03f582c97c728ee5cc1d5e382fe0214be22535 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 31 Aug 2014 12:38:33 +0200 Subject: [PATCH 21/34] Fix SQL syntax --- htdocs/admin/limits.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 69237fe4f74..9c0bc80a25a 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -206,9 +206,9 @@ else // Add vat rates examples specific to country $vat_rates=array(); - $sql.="SELECT taux as vat_rate"; + $sql="SELECT taux as vat_rate"; $sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql.=" WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$mysoc->country_code."' AND taux != 0"; + $sql.=" WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$mysoc->country_code."' AND taux <> 0"; $sql.=" ORDER BY t.taux ASC"; $resql=$db->query($sql); if ($resql) From 6e545771675cbb6c5f3a5d865d37631bff17280b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Aug 2014 15:09:10 +0200 Subject: [PATCH 22/34] Better error management --- htdocs/core/lib/ajax.lib.php | 44 ++++++++++++++++++--------------- htdocs/societe/ajax/company.php | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 79ceb73d05a..130394b75a2 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -98,26 +98,30 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt $("input#search_'.$htmlname.'").autocomplete({ source: function( request, response ) { $.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){ - response($.map( data, function( item ) { - if (autoselect == 1 && data.length == 1) { - $("#search_'.$htmlname.'").val(item.value); - $("#'.$htmlname.'").val(item.key).trigger("change"); - } - var label = item.label.toString(); - var update = {}; - if (options.update) { - $.each(options.update, function(key, value) { - update[key] = item[value]; - }); - } - var textarea = {}; - if (options.update_textarea) { - $.each(options.update_textarea, function(key, value) { - textarea[key] = item[value]; - }); - } - return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled } - })); + if (data != null) + { + response($.map( data, function(item) { + if (autoselect == 1 && data.length == 1) { + $("#search_'.$htmlname.'").val(item.value); + $("#'.$htmlname.'").val(item.key).trigger("change"); + } + var label = item.label.toString(); + var update = {}; + if (options.update) { + $.each(options.update, function(key, value) { + update[key] = item[value]; + }); + } + var textarea = {}; + if (options.update_textarea) { + $.each(options.update_textarea, function(key, value) { + textarea[key] = item[value]; + }); + } + return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled } + })); + } + else console.error("Error: Ajax url '.$url.($urloption?'?'.$urloption:'').' has returned an empty page. Should be an empty json array."); }, "json"); }, dataType: "json", diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 03d6091f6c0..96ac9f0154b 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/product/ajax/products.php + * \file htdocs/product/ajax/company.php * \brief File to return Ajax response on product list request */ From de548ba610a6eaf6b639709c7c029fd2ac6c6a2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Aug 2014 23:01:49 +0200 Subject: [PATCH 23/34] Doxygen --- htdocs/core/lib/ajax.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 130394b75a2..f91ec3d188d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -31,7 +31,7 @@ * * @param string $selected Preselecte value * @param string $htmlname HTML name of input field - * @param string $url Url for request: /chemin/fichier.php + * @param string $url Url for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list) * @param string $urloption More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value From f2affade35f5a40626e9325860fd0c6f0120c5fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Aug 2014 23:06:58 +0200 Subject: [PATCH 24/34] Doxygen --- htdocs/core/modules/propale/mod_propale_marbre.php | 4 ++-- htdocs/core/modules/propale/mod_propale_saphir.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index ff38bc5f9cb..7889d62b3ff 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -26,8 +26,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; -/** \class mod_propale_marbre - * \brief Class to manage customer order numbering rules Marbre +/** + * Class to manage customer order numbering rules Marbre */ class mod_propale_marbre extends ModeleNumRefPropales { diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 5838000382c..503d8754684 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; /** - * \class mod_propale_saphir - * \brief Class of file that contains the numbering module rules Saphir + * Class of file that contains the numbering module rules Saphir */ class mod_propale_saphir extends ModeleNumRefPropales { From f245f43a3f3f11b05186a38a56d3cbdc77a082d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Aug 2014 23:18:09 +0200 Subject: [PATCH 25/34] Doxygen --- htdocs/core/modules/propale/mod_propale_marbre.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 7889d62b3ff..28260de97d8 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -124,7 +124,7 @@ class mod_propale_marbre extends ModeleNumRefPropales } else { - dol_syslog("mod_propale_marbre::getNextValue", LOG_DEBUG); + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); return -1; } @@ -134,7 +134,7 @@ class mod_propale_marbre extends ModeleNumRefPropales if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is else $num = sprintf("%04s",$max+1); - dol_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); + dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } From bff33166a59bf5e4ba20b9bdbd274a44f36b4741 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Sep 2014 11:49:44 +0200 Subject: [PATCH 26/34] Fix missing $user in create method --- htdocs/categories/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index d43c4df9a3d..58b4696c305 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -132,7 +132,7 @@ if ($action == 'add' && $user->rights->categorie->creer) // Create category in database if (! $error) { - $result = $object->create(); + $result = $object->create($user); if ($result > 0) { $action = 'confirmed'; From 0473bc5138e31459279fb478e8f56c524bf26c58 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Sep 2014 11:51:16 +0200 Subject: [PATCH 27/34] Fix missing $user into create call categorie --- htdocs/categories/class/categorie.class.php | 2 +- htdocs/categories/fiche.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ad436d5c6c8..c4de7377ebd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -137,7 +137,7 @@ class Categorie extends CommonObject * -3 : categorie invalide * -4 : category already exists */ - function create($user='') + function create($user) { global $conf,$langs,$hookmanager; $langs->load('categories'); diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index aca14acce2b..a2f9dc54df2 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -138,7 +138,7 @@ if ($action == 'add' && $user->rights->categorie->creer) // Create category in database if (! $error) { - $result = $object->create(); + $result = $object->create($user); if ($result > 0) { $action = 'confirmed'; From db1c97bdad116c5d9c393d9918949826a76605fa Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Sep 2014 11:52:20 +0200 Subject: [PATCH 28/34] changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index dad4cb65c1e..82d4efebcba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ For users: - Fix: debian script syntax error - Fix: error "menu param is not inside list" into pos module. - Fix: Salary payments are not reflected on the reporting sheets +- Fix: Trigger on create category call failed because user is not passed on card ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: From 4372c587142902b3e0f562cfeb6f69e16121196c Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Mon, 1 Sep 2014 18:24:25 +0200 Subject: [PATCH 29/34] Fix: Unsubscribe emailing not working --- ChangeLog | 1 + htdocs/public/emailing/mailing-unsubscribe.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dad4cb65c1e..ef7c7a9cadc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ For users: - Fix: debian script syntax error - Fix: error "menu param is not inside list" into pos module. - Fix: Salary payments are not reflected on the reporting sheets +- Fix: Unsubscribe emailing not working ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index 0b11ec3642b..2bf42cb4bba 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2012 Florian Henry + * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,7 +86,7 @@ if (! empty($tag) && ($unsuscrib=='1')) $resql=$db->query($sql); //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT sc.rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); $resql=$db->query($sql); From dc46d59d68ec791883e8d79f0afac7b93e9997b3 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Mon, 1 Sep 2014 18:24:25 +0200 Subject: [PATCH 30/34] Fix: Unsubscribe emailing not working --- ChangeLog | 1 + htdocs/public/emailing/mailing-unsubscribe.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7c05ea3295..b66c5a981f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -102,6 +102,7 @@ For users: - Fix: debian script syntax error - Fix: error "menu param is not inside list" into pos module. - Fix: Salary payments are not reflected on the reporting sheets +- Fix: Unsubscribe emailing not working ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index 0b11ec3642b..2bf42cb4bba 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2012 Florian Henry + * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,7 +86,7 @@ if (! empty($tag) && ($unsuscrib=='1')) $resql=$db->query($sql); //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT sc.rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); $resql=$db->query($sql); From 772acd6bf91af654fab49c750fc16f39410dcebc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Sep 2014 11:49:44 +0200 Subject: [PATCH 31/34] Fix missing $user in create method --- htdocs/categories/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index aca14acce2b..a2f9dc54df2 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -138,7 +138,7 @@ if ($action == 'add' && $user->rights->categorie->creer) // Create category in database if (! $error) { - $result = $object->create(); + $result = $object->create($user); if ($result > 0) { $action = 'confirmed'; From cc858b2af001679fc995e5b4ce18edfdac4e02be Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Mon, 1 Sep 2014 22:41:36 +0200 Subject: [PATCH 32/34] Fix SQL syntax ChangeLog --- ChangeLog | 1 + htdocs/admin/limits.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b66c5a981f1..be220bb0220 100644 --- a/ChangeLog +++ b/ChangeLog @@ -103,6 +103,7 @@ For users: - Fix: error "menu param is not inside list" into pos module. - Fix: Salary payments are not reflected on the reporting sheets - Fix: Unsubscribe emailing not working +- Fix: Trigger on create category call failed because user is not passed on card ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 781bc24aa09..1f07743b402 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -204,9 +204,9 @@ else // Add vat rates examples specific to country $vat_rates=array(); - $sql.="SELECT taux as vat_rate"; + $sql="SELECT taux as vat_rate"; $sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql.=" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND taux != 0"; + $sql.=" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND taux <> 0"; $sql.=" ORDER BY t.taux ASC"; $resql=$db->query($sql); if ($resql) From 17dec4b924c2fca89a3a6d1d6ddae2f9e6429ef6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Sep 2014 13:05:03 +0200 Subject: [PATCH 33/34] Fix: Bad merge --- htdocs/compta/facture.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 1cf4649547c..8138c56450e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -248,16 +248,18 @@ else if ($action == 'setmode' && $user->rights->facture->creer) { dol_print_error($db, $object->error); } -else if ($action == 'setinvoicedate' && $user->rights->facture->creer) { +else if ($action == 'setinvoicedate' && $user->rights->facture->creer) +{ $object->fetch($id); $old_date_lim_reglement = $object->date_lim_reglement; - $object->date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); + $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); if (empty($date)) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); exit; } + $object->date=$date; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; From df70450073046ce31a0366f37f7d8ed85c52dc5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Sep 2014 20:00:10 +0200 Subject: [PATCH 34/34] Fix: Doxygen --- htdocs/accountancy/admin/productaccount.php | 30 +-- .../class/accountancysystem.class.php | 18 +- .../class/accountingaccount.class.php | 108 +++++------ .../accountancy/class/bookkeeping.class.php | 180 ++++++++++-------- .../class/html.formventilation.class.php | 76 ++++---- htdocs/accountancy/journal/bankjournal.php | 128 ++++++------- htdocs/accountancy/journal/cashjournal.php | 118 ++++++------ .../accountancy/export-thirdpartyaccount.php | 35 ++-- 8 files changed, 352 insertions(+), 341 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 55e7b54031e..0b06a3d0daa 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,5 +1,5 @@ * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Florian Henry @@ -34,7 +34,7 @@ if (! $res && file_exists("../../../main.inc.php")) $res = @include ("../../../main.inc.php"); if (! $res) die("Include of main fails"); - + // Class dol_include_once("/core/lib/report.lib.php"); dol_include_once("/core/lib/date.lib.php"); @@ -73,13 +73,13 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - + /* * view */ - + print '

'; - + print ''; print ''; print ''; @@ -88,13 +88,13 @@ if ($resql) { print ''; print ''; print ''; - + $var = True; - + while ( $i < min($num, 250) ) { $obj = $db->fetch_object($resql); $var = ! $var; - + $compta_prodsell = $obj->accountancy_code_sell; if (empty($compta_prodsell)) { if ($obj->product_type == 0) @@ -102,7 +102,7 @@ if ($resql) { else $compta_prodsell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); } - + $compta_prodbuy = $obj->accountancy_code_buy; if (empty($compta_prodbuy)) { if ($obj->product_type == 0) @@ -110,12 +110,12 @@ if ($resql) { else $compta_prodbuy = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); } - + $product_static = new Product($db); - + print ""; // Ref produit - $product_static->ref = $objp->p . ref; + $product_static->ref = $objp->ref; $product_static->id = $objp->rowid; $product_static->type = $objp->type; print ''; print ''; print ''; - + print ''; print ''; - + print ''; print ''; - + print "\n"; $i ++; } diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 08d195aedcf..070f9a8071a 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -24,10 +24,10 @@ */ /** - * \class AccountancySystem - * \brief Classe to manage accountancy systems + * Class to manage accountancy systems */ -class AccountancySystem { +class AccountancySystem +{ var $db; var $error; var $rowid; @@ -37,7 +37,7 @@ class AccountancySystem { var $label; var $account_number; var $account_parent; - + /** * Constructor * @@ -46,7 +46,7 @@ class AccountancySystem { function __construct($db) { $this->db = $db; } - + /** * Insert accountancy system name into database * @@ -55,16 +55,16 @@ class AccountancySystem { */ function create($user) { $now = dol_now(); - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; $sql .= " (date_creation, fk_user_author, numero,intitule)"; $sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->intitule . "')"; - + 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 . "accounting_system"); - + if ($id > 0) { $this->id = $id; $result = $this->id; @@ -78,7 +78,7 @@ class AccountancySystem { $this->error = "AccountancySystem::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } - + return $result; } } \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 34c23cb0a51..4c54e609caf 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -24,10 +24,10 @@ */ /** - * \class AccountingAccount - * \brief Classe permettant la gestion des comptes generaux de compta + * Classe permettant la gestion des comptes generaux de compta */ -class AccountingAccount { +class AccountingAccount +{ var $db; var $id; var $rowid; @@ -41,7 +41,7 @@ class AccountingAccount { var $fk_user_author; var $fk_user_modif; var $active; - + /** * \brief Constructeur de la classe * \param DB handler acces base de donnees @@ -49,11 +49,11 @@ class AccountingAccount { */ function __construct($db, $rowid = '') { $this->db = $db; - + if ($rowid != '') return $this->fetch($rowid); } - + /** * \brief Load record in memory */ @@ -65,7 +65,7 @@ class AccountingAccount { } elseif ($account_number) { $sql .= " account_number = '" . $account_number . "'"; } - + dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -74,7 +74,7 @@ class AccountingAccount { return null; } } - + $this->id = $obj->rowid; $this->rowid = $obj->rowid; $this->datec = $obj->datec; @@ -88,10 +88,10 @@ class AccountingAccount { $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; $this->active = $obj->active; - + return $obj->rowid; } - + /** * \brief insert line in accountingaccount * \param user utilisateur qui effectue l'insertion @@ -99,7 +99,7 @@ class AccountingAccount { function create($user, $notrigger = 0) { global $conf, $langs; $error = 0; - + // Clean parameters if (isset($this->fk_pcg_version)) $this->fk_pcg_version = trim($this->fk_pcg_version); @@ -117,13 +117,13 @@ class AccountingAccount { $this->fk_user_author = trim($this->fk_user_author); if (isset($this->active)) $this->active = trim($this->active); - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accountingaccount("; - + $sql .= "datec"; $sql .= ", entity"; $sql .= ", fk_pcg_version"; @@ -134,9 +134,9 @@ class AccountingAccount { $sql .= ", label"; $sql .= ", fk_user_author"; $sql .= ", active"; - + $sql .= ") VALUES ("; - + $sql .= " '" . $this->db->idate($now) . "'"; $sql .= ", " . $conf->entity; $sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); @@ -147,25 +147,25 @@ class AccountingAccount { $sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . $user->id; $sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'"); - + $sql .= ")"; - + $this->db->begin(); - + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount"); - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -174,7 +174,7 @@ class AccountingAccount { // // End call triggers } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -188,7 +188,7 @@ class AccountingAccount { return $this->id; } } - + /** * Update record * @@ -197,9 +197,9 @@ class AccountingAccount { */ function update($user) { global $langs; - + $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); @@ -209,9 +209,9 @@ class AccountingAccount { $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); $sql .= " , fk_user_modif = " . $user->id; $sql .= " , active = '" . $this->active . "'"; - + $sql .= " WHERE rowid = " . $this->id; - + dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -223,7 +223,7 @@ class AccountingAccount { return - 1; } } - + /** * Check usage of accounting code * @@ -232,16 +232,16 @@ class AccountingAccount { */ function checkUsage() { global $langs; - + $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= "UNION"; $sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - + dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $num = $this->db->num_rows($resql); if ($num > 0) { @@ -255,7 +255,7 @@ class AccountingAccount { return - 1; } } - + /** * Delete object in database * @@ -266,18 +266,18 @@ class AccountingAccount { function delete($user, $notrigger = 0) { global $conf, $langs; $error = 0; - + $result = $this->checkUsage(); - + if ($result > 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 // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -286,11 +286,11 @@ class AccountingAccount { // // End call triggers } } - + if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount"; $sql .= " WHERE rowid=" . $this->id; - + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (! $resql) { @@ -298,7 +298,7 @@ class AccountingAccount { $this->errors[] = "Error " . $this->db->lasterror(); } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -315,7 +315,7 @@ class AccountingAccount { return - 1; } } - + /** * Information on record * @@ -326,10 +326,10 @@ class AccountingAccount { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a'; $sql .= ' WHERE a.rowid = ' . $id; - + dol_syslog(get_class($this) . '::info sql=' . $sql); $result = $this->db->query($sql); - + if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); @@ -352,7 +352,7 @@ class AccountingAccount { dol_print_error($this->db); } } - + /** * Account desactivate * @@ -361,19 +361,19 @@ class AccountingAccount { */ function account_desactivate($id) { global $langs; - + $result = $this->checkUsage(); - + if ($result > 0) { $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= "SET active = '0'"; $sql .= " WHERE rowid = ".$this->db->escape($id); - + dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - + if ($result) { $this->db->commit(); return 1; @@ -386,7 +386,7 @@ class AccountingAccount { return - 1; } } - + /** * Account activate * @@ -395,13 +395,13 @@ class AccountingAccount { */ function account_activate($id) { global $langs; - + $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= "SET active = '1'"; $sql .= " WHERE rowid = ".$this->db->escape($id); - + dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8b9666cc0a7..2788526de05 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2005 Rodolphe Quiedeville * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ class BookKeeping var $piece_num; var $linesexport = array (); var $linesmvt = array (); - + /** * Constructor * @@ -59,7 +59,7 @@ class BookKeeping { $this->db = $db; } - + /** * Load a line into memory from database * @@ -74,14 +74,14 @@ class BookKeeping $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE rowid = '" . $id . "'"; - + dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + $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; @@ -103,10 +103,10 @@ class BookKeeping dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Load an accounting document into memory from database * @@ -118,12 +118,12 @@ class BookKeeping $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE piece_num = '" . $piecenum . "'"; - + dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, 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); @@ -134,10 +134,10 @@ class BookKeeping dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Return next number movement * @@ -145,14 +145,14 @@ class BookKeeping */ function getNextNumMvt() { $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - + dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - + if ($result) { $obj = $this->db->fetch_object($result); - + return $obj->max; } else @@ -162,7 +162,7 @@ class BookKeeping return - 1; } } - + /** * Load all informations of accountancy document * @@ -177,17 +177,17 @@ class BookKeeping $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE piece_num = '" . $piecenum . "'"; - + dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, 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; @@ -202,7 +202,7 @@ class BookKeeping $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesmvt[] = $line; } } else { @@ -210,40 +210,43 @@ class BookKeeping dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** - * \brief Insert line into bookkeeping - * \param user User who inserted operation + * Insert line into bookkeeping + * + * @param User $user User who inserted operation + * @return $result Result */ - function create() { + function create($user='') + { global $conf, $user, $langs; - + $this->piece_num = 0; - + // first check if line not yet in bookkeeping $sql = "SELECT count(*)"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $row = $this->db->fetch_array($resql); if ($row[0] == 0) { - + // Determine piece_num $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) @@ -256,7 +259,7 @@ class BookKeeping { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -268,11 +271,11 @@ class BookKeeping 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 . "accounting_bookkeeping (doc_date, "; $sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,"; $sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)"; @@ -280,12 +283,12 @@ class BookKeeping $sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',"; $sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '"; $sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")"; - + 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 . "accounting_bookkeeping"); - + if ($id > 0) { $this->id = $id; $result = 0; @@ -305,27 +308,30 @@ class BookKeeping $result = - 5; dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); } - + return $result; } - + /** - * \brief Delete bookkepping by importkey + * Delete bookkepping by importkey + * + * @param string $importkey Import key + * @return int Result */ function delete_by_importkey($importkey) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE import_key = '" . $importkey . "'"; - + $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -339,7 +345,7 @@ class BookKeeping return 1; } } - + /** * Create object into database * @@ -351,7 +357,7 @@ class BookKeeping { global $conf, $langs; $error = 0; - + // Clean parameters if (isset($this->doc_type)) $this->doc_type = trim($this->doc_type); @@ -383,10 +389,10 @@ class BookKeeping $this->code_journal = trim($this->code_journal); if (isset($this->piece_num)) $this->piece_num = trim($this->piece_num); - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping("; $sql .= "doc_date,"; @@ -405,9 +411,9 @@ class BookKeeping $sql .= "import_key,"; $sql .= "code_journal,"; $sql .= "piece_num"; - + $sql .= ") VALUES ("; - + $sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ","; $sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ","; $sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ","; @@ -424,25 +430,25 @@ class BookKeeping $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ","; $sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ","; $sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . ""; - + $sql .= ")"; - + $this->db->begin(); - + dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -451,7 +457,7 @@ class BookKeeping // // End call triggers } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -465,7 +471,7 @@ class BookKeeping return $this->id; } } - + /** * Update object into database * @@ -477,7 +483,7 @@ class BookKeeping { global $conf, $langs; $error = 0; - + // Clean parameters if (isset($this->doc_type)) $this->doc_type = trim($this->doc_type); @@ -509,13 +515,13 @@ class BookKeeping $this->code_journal = trim($this->code_journal); 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 . "accounting_bookkeeping SET"; - + $sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ","; $sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ","; $sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ","; @@ -532,23 +538,23 @@ class BookKeeping $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ","; $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(); - + dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -557,7 +563,7 @@ class BookKeeping // // End call triggers } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -571,7 +577,7 @@ class BookKeeping return 1; } } - + /** * Delete object in database * @@ -583,24 +589,24 @@ class BookKeeping { global $conf, $langs; $error = 0; - + $this->db->begin(); - + if (! $error) { if (! $notrigger) { // Call trigger $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } } - + if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE rowid=" . $this->id; - + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (! $resql) { @@ -608,7 +614,7 @@ class BookKeeping $this->errors[] = "Error " . $this->db->lasterror(); } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -624,9 +630,12 @@ class BookKeeping return 1; } } - + /** - * \brief Delete bookkepping by importkey + * Delete bookkepping by importkey + * + * @param string $model Model + * @return int Result */ function export_bookkeping($model = 'ebp') { @@ -635,20 +644,20 @@ class BookKeeping $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - + $resql = $this->db->query($sql); - + dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, 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; @@ -663,11 +672,11 @@ class BookKeeping $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 @@ -679,6 +688,9 @@ class BookKeeping } } +/** + * Class BookKeepingLine + */ class BookKeepingLine { var $id; diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index b6d49e0c36a..7385219780b 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -19,10 +19,10 @@ /** * \file htdocs/accountancy/class/html.formventilation.class.php - * \ingroup Accounting Expert + * \ingroup Accounting Expert * \brief File of class with all html predefined components */ - + /** * Class to manage generation of HTML components for bank module */ @@ -30,7 +30,7 @@ class FormVentilation extends Form { var $db; var $error; - + /** * Constructor * @@ -48,33 +48,33 @@ class FormVentilation extends Form * @param string $selectedkey Value * @return string HTML edit field */ - function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey) + function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='') { global $langs; - + $date_array = array (); - + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; - + $out = ''; - + return $out; } - + /** * Return list of accounts with label by chart of accounts * @@ -95,38 +95,38 @@ class FormVentilation extends Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param array $event Event options - * + * * @return string String with HTML select */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) { global $conf, $user, $langs; - + $out = ''; - + $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " ORDER BY aa.account_number"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - + $out .= ajax_combobox($htmlname, $event); $out .= ''; if ($showempty) $out .= ''; @@ -184,7 +184,7 @@ class FormVentilation extends Form while ( $i < $num ) { $obj = $this->db->fetch_object($resql); $label = $obj->pcg_type; - + if (($selectid != '') && $selectid == $obj->pcg_type) { $out .= ''; } else { @@ -202,7 +202,7 @@ class FormVentilation extends Form $this->db->free($resql); return $out; } - + /** * Return list of accounts with label by sub_class of accounts * @@ -210,25 +210,25 @@ class FormVentilation extends Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param array $event Event options - * + * * @return string String with HTML select */ function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) { global $conf, $user, $langs; - + $out = ''; - + $sql = "SELECT DISTINCT pcg_subtype "; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= " ORDER BY pcg_subtype"; - + dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - + $out .= ajax_combobox($htmlname, $event); - + $out .= ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print "
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '
'; @@ -127,13 +127,13 @@ if ($resql) { print '' . $obj->ref . '' . $obj->label . '' . $obj->description . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . '' . $obj->accountancy_code_sell . '' . $compta_prodsell . '
"; print ""; @@ -520,18 +520,18 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + if ($val["lib"] == '(SupplierInvoicePayment)') $reflabel = $langs->trans('SupplierInvoicePayment'); if ($val["lib"] == '(CustomerInvoicePayment)') $reflabel = $langs->trans('CustomerInvoicePayment'); - + // Bank foreach ( $tabbq[$key] as $k => $mt ) { if (1) { @@ -546,7 +546,7 @@ if ($action == 'export_csv') { print ""; } } - + // Third party foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { @@ -561,12 +561,12 @@ if ($action == 'export_csv') { print ""; } } - + $var = ! $var; } - + print "
" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php index e7e065577c6..64b450497b9 100644 --- a/htdocs/accountancy/journal/cashjournal.php +++ b/htdocs/accountancy/journal/cashjournal.php @@ -38,7 +38,7 @@ if (! $res && file_exists("../../../main.inc.php")) $res = @include ("../../../main.inc.php"); if (! $res) die("Include of main fails"); - + // Class dol_include_once("/core/lib/report.lib.php"); dol_include_once("/core/lib/date.lib.php"); @@ -127,24 +127,24 @@ $paymentvatstatic = new TVA($db); dol_syslog("accountancy/journal/cashjournal.php:: sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { - + $num = $db->num_rows($result); // les variables $cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); $cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); $cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); - + $tabpay = array (); $tabbq = array (); $tabtp = array (); $tabcompany = array (); $tabtype = array (); - + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - + // controls $compta_bank = $obj->account_number; if ($obj->label == '(SupplierInvoicePayment)') @@ -153,9 +153,9 @@ if ($result) { $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); if ($obj->typeop == '(BankTransfert)') $compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH; - + // variable bookkeeping - + $tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["ref"] = $obj->label; $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; @@ -165,11 +165,11 @@ if ($result) { $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); } $links = $object->get_url($obj->rowid); - + foreach ( $links as $key => $val ) { - + $tabtype[$obj->rowid] = $links[$key]['type']; - + if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); @@ -178,16 +178,16 @@ if ($result) { $paymentsupplierstatic->ref = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); } else if ($links[$key]['type'] == 'company') { - + $societestatic->id = $links[$key]['url_id']; $societestatic->nom = $links[$key]['label']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabtp[$obj->rowid][$compta_soc] += $obj->amount; } else if ($links[$key]['type'] == 'sc') { - + $chargestatic->id = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id']; - + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if ($reg[1] == 'socialcontribution') @@ -198,7 +198,7 @@ if ($result) { } $chargestatic->ref = $chargestatic->lib; $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); - + $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; @@ -212,7 +212,7 @@ if ($result) { $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; } } else if ($links[$key]['type'] == 'payment_vat') { - + $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); @@ -226,9 +226,9 @@ if ($result) { }*/ } $tabbq[$obj->rowid][$compta_bank] += $obj->amount; - + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; - + $i ++; } } else { @@ -254,14 +254,14 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $compte->intitule; - $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt >= 0) ? $mt : 0; - $bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0); + $bookkeeping->debit = ($mt >= 0 ? $mt : 0); + $bookkeeping->credit = ($mt < 0 ? - $mt : 0); $bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL; - + if ($tabtype[$key] == 'payment') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -274,7 +274,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } } else if ($tabtype[$key] == 'payment_supplier') { - + $sqlmid = 'SELECT facf.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -287,7 +287,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } } - + $result = $bookkeeping->create(); if ($result < 0) { $error ++; @@ -296,7 +296,7 @@ if ($action == 'writeBookKeeping') { } // third party foreach ( $tabtp[$key] as $k => $mt ) { - + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -304,17 +304,17 @@ if ($action == 'writeBookKeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0); - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0 ? $mt : 0); $bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL; - + if ($tabtype[$key] == 'sc') { $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -329,7 +329,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; } else if ($tabtype[$key] == 'payment_supplier') { - + $sqlmid = 'SELECT facf.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -344,7 +344,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER; } else if ($tabtype[$key] == 'company') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -359,11 +359,11 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; } else { - + $bookkeeping->doc_ref = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; } - + $result = $bookkeeping->create(); if ($result < 0) { $error ++; @@ -371,7 +371,7 @@ if ($action == 'writeBookKeeping') { } } } - + if (empty($error)) { setEventMessage($langs->trans('Success'), 'mesgs'); } @@ -379,19 +379,19 @@ if ($action == 'writeBookKeeping') { // export csv if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_SEPARATORCSV; - + header('Content-Type: text/csv'); header('Content-Disposition:attachment;filename=journal_caisse.csv'); - + if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert { foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + // Cash print $date . $sep; print $conf->global->ACCOUNTING_CASH_JOURNAL . $sep; - + foreach ( $tabbq[$key] as $k => $mt ) { print length_accountg(html_entity_decode($k)) . $sep; print $sep; @@ -401,7 +401,7 @@ if ($action == 'export_csv') { print utf8_decode($langs->trans("CashPayment")) . $sep; print $val["ref"] . $sep; print "\n"; - + // Third party foreach ( $tabtp[$key] as $k => $mt ) { if ($mt) { @@ -427,7 +427,7 @@ if ($action == 'export_csv') { $date = dol_print_date($db->jdate($val["date"]), 'day'); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; - + // Cash foreach ( $tabbq[$key] as $k => $mt ) { print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; @@ -436,7 +436,7 @@ if ($action == 'export_csv') { print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; } print "\n"; - + // Third party foreach ( $tabtp[$key] as $k => $mt ) { if ($mt) { @@ -452,11 +452,11 @@ if ($action == 'export_csv') { } } } else { - + $form = new Form($db); - + llxHeader('', $langs->trans("CashJournal"), ''); - + $nom = $langs->trans("CashJournal"); $nomlink = ''; $periodlink = ''; @@ -465,11 +465,11 @@ if ($action == 'export_csv') { $description = $langs->trans("DescCashJournal") . '
'; $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); - + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -497,13 +497,13 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Cash foreach ( $tabbq[$key] as $k => $mt ) { if (1) { @@ -516,26 +516,26 @@ if ($action == 'export_csv') { print ""; } } - + // third party foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { print ""; - + print ""; print ""; - + print ""; print '"; print '"; } } - + $var = ! $var; } - + print "
" . $langs->trans("Account") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $val["soclib"] . "" . length_accounta($k) . "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; - + // End of page llxFooter(); } diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 7fb4a7c56e0..2556457f38e 100644 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -35,7 +35,7 @@ $langs->load("accountancy"); // Security check if (!$user->admin) accessforbidden(); - + // Date range $year = GETPOST("year"); if (empty($year)) { @@ -105,9 +105,8 @@ $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . $description = $langs->trans("DescThirdPartyReport"); $builddate = time(); -report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( - 'action' => '' -)); +$moreparam=array('action' => ''); +report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam); print ''; @@ -157,16 +156,16 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - + // export csv if (GETPOST('action') == 'export_csv') { - + header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=export_csv.csv'); - + $obj = $db->fetch_object($resql); $var = ! $var; - + print '"' . $obj->compta . '",'; print '"' . $obj->address . '",'; print '"' . $obj->zip . '",'; @@ -177,15 +176,15 @@ if ($resql) { print "\n"; $i ++; } - + /* * View */ - + $thirdpartystatic = new Societe($db); - + print '

'; - + print ''; print "
\n"; print ''; @@ -201,13 +200,13 @@ if ($resql) { print '' . $langs->trans("Contact") . ''; print '' . $langs->trans("Phone") . ''; print '' . $langs->trans("Fax") . ''; - + $var = True; - + while ( $obj = $db->fetch_object($resql) ) { - + $var = ! $var; - + print ""; print ''; $thirdpartystatic->id = $obj->rowid; @@ -227,10 +226,10 @@ if ($resql) { print '' . $obj->phone . ''; print '' . $obj->fax . ''; print "\n"; - + $i ++; } - + print ""; $db->free($resql); } else {