From 8670a89ecb8f6742420486dc20125e680d62c740 Mon Sep 17 00:00:00 2001 From: Cedric Date: Thu, 14 Aug 2014 08:41:24 +0200 Subject: [PATCH 001/123] 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 002/123] 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 003/123] 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 004/123] 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 005/123] 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 006/123] 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 007/123] 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 2aa3995b73d808fd4a325000d312e2f95c4ec26b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 21 Aug 2014 06:01:47 +0200 Subject: [PATCH 008/123] Fix :: Sql problem for fresh install on resource table // Ok in migration script --- htdocs/install/mysql/tables/llx_c_type_resource.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_type_resource.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql index 5a76ff0cfa6..dc5c5ee150a 100644 --- a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql +++ b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql @@ -17,5 +17,5 @@ -- ======================================================================== -ALTER TABLE llx_c_type_contact ADD UNIQUE INDEX uk_c_type_contact_id (element, source, code); +ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code); diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.sql b/htdocs/install/mysql/tables/llx_c_type_resource.sql index efb505ba574..8ba088c075e 100644 --- a/htdocs/install/mysql/tables/llx_c_type_resource.sql +++ b/htdocs/install/mysql/tables/llx_c_type_resource.sql @@ -29,6 +29,6 @@ create table llx_c_type_resource ( rowid integer PRIMARY KEY, code varchar(32) NOT NULL, - libelle varchar(64) NOT NULL, + label varchar(64) NOT NULL, active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; From 29ca4b7a0a0b9efa1b328c66d8b12a56d1375055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 21 Aug 2014 11:32:39 +0200 Subject: [PATCH 009/123] Enhanced modules parent class properties documentation --- htdocs/core/modules/DolibarrModules.class.php | 201 ++++++++++++++---- 1 file changed, 164 insertions(+), 37 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 1215f8e85e2..b730b150c3e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1,10 +1,11 @@ - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2013 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -31,29 +32,161 @@ */ abstract class DolibarrModules { - //! Database handler - var $db; - //! Relative path to module style sheet - var $style_sheet = ''; // deprecated - //! Path to create when module activated - var $dirs = array(); - //! Tableau des boites - var $boxes; - //! Tableau des constantes - var $const; - //! Tableau des droits - var $rights; - //! Tableau des menus - var $menu=array(); - //! Module parts array - var $module_parts=array(); - //! Tableau des documents ??? - var $docs; - - var $dbversion = "-"; - - /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string Relative path to module style sheet + * @deprecated + */ + public $style_sheet = ''; + + /** + * @var array Paths to create when module is activated + */ + public $dirs = array(); + + /** + * @var array Module boxes + */ + public $boxes = array(); + + /** + * @var array Module constants + */ + public $const = array(); + + /** + * @var array Module access rights + */ + public $rights; + + /** + * @var string Module access rights family + */ + public $rights_class; + + /** + * @var array Module menu entries + */ + public $menu = array(); + + /** + * @var array Module parts + * array( + * // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) + * 'triggers' => 0, + * // Set this to 1 if module has its own login method directory (/mymodule/core/login) + * 'login' => 0, + * // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions) + * 'substitutions' => 0, + * // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus) + * 'menus' => 0, + * // Set this to 1 if module has its own theme directory (/mymodule/theme) + * 'theme' => 0, + * // Set this to 1 if module overwrite template dir (/mymodule/core/tpl) + * 'tpl' => 0, + * // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode) + * 'barcode' => 0, + * // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx) + * 'models' => 0, + * // Set this to relative path of css file if module has its own css file + * 'css' => '/mymodule/css/mymodule.css.php', + * // Set this to relative path of js file if module must load a js on all pages + * 'js' => '/mymodule/js/mymodule.js', + * // Set here all hooks context managed by module + * 'hooks' => array('hookcontext1','hookcontext2'), + * // Set here all workflow context managed by module + * 'workflow' => array( + * 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array( + * 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', + * 'picto'=>'yourpicto@mymodule' + * ) + * ) + * ) + */ + public $module_parts = array(); + + /** + * @var string Module documents ? + * @deprecated Seems unused anywhere + */ + public $docs; + + /** + * @var string ? + * @deprecated Seems unused anywhere + */ + public $dbversion = "-"; + + /** + * @var string Error message + */ + public $error; + + /** + * @var int Module unique ID + */ + public $numero; + + /** + * @var string Module name + */ + public $name; + + /** + * @var string Module version + */ + public $version; + + /** + * @var string Module description + */ + public $description; + + /** + * @var string[] Module language files + */ + public $langfiles; + + /** + * @var string Module export code + */ + public $export_code; + + /** + * @var string Module export label + */ + public $export_label; + + /** + * @var string Module import code + */ + public $import_code; + + /** + * @var string Module import label + */ + public $import_label; + + /** + * @var string Module constant name + */ + public $const_name; + + /** + * @var bool Module can't be disabled + */ + public $always_enabled; + + /** + * @var bool Module is enabled globally (Multicompany support) + */ + public $core_enabled; + + /** * Method to enable a module. Insert into database all constants, boxes of module * * @param array $array_sql Array of SQL requests to execute when enabling module @@ -62,7 +195,7 @@ abstract class DolibarrModules */ function _init($array_sql, $options='') { - global $conf, $langs; + global $conf; $err=0; $this->db->begin(); @@ -98,18 +231,13 @@ abstract class DolibarrModules if (! $err) { $val=$array_sql[$i]; - $sql=''; + $sql=$val; $ignoreerror=0; if (is_array($val)) { $sql=$val['sql']; $ignoreerror=$val['ignoreerror']; } - else - { - $sql=$val; - } - // Add current entity id $sql=str_replace('__ENTITY__', $conf->entity, $sql); @@ -152,7 +280,6 @@ abstract class DolibarrModules */ function _remove($array_sql, $options='') { - global $langs; $err=0; $this->db->begin(); @@ -424,7 +551,7 @@ abstract class DolibarrModules */ function _load_tables($reldir) { - global $db,$conf; + global $conf; $error=0; $dirfound=0; From c3b30893fc74a0193cda9f3b256822207223cbe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 21 Aug 2014 12:16:13 +0200 Subject: [PATCH 010/123] Enhanced modules parent class methods documentation --- htdocs/core/modules/DolibarrModules.class.php | 208 ++++++++---------- 1 file changed, 97 insertions(+), 111 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index b730b150c3e..e4d1f834b4a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -22,13 +22,15 @@ */ /** - * \file htdocs/core/modules/DolibarrModules.class.php - * \brief File of parent class of module descriptor class files + * \file htdocs/core/modules/DolibarrModules.class.php + * \brief File of parent class of module descriptor class files */ /** - * Parent class of module descriptor class files + * Class DolibarrModules + * + * Parent class for module descriptor class files */ abstract class DolibarrModules { @@ -187,12 +189,14 @@ abstract class DolibarrModules public $core_enabled; /** - * Method to enable a module. Insert into database all constants, boxes of module - * - * @param array $array_sql Array of SQL requests to execute when enabling module - * @param string $options String with options when disabling module ('newboxdefonly|noboxes') - * @return int 1 if OK, 0 if KO - */ + * Enables a module. + * Inserts all informations into database + * + * @param string[] $array_sql SQL requests to be executed when enabling module + * @param string $options String with options when disabling module ('newboxdefonly|noboxes') + * + * @return int 1 if OK, 0 if KO + */ function _init($array_sql, $options='') { global $conf; @@ -272,11 +276,12 @@ abstract class DolibarrModules } /** - * Fonction de desactivation. Supprime de la base les constantes et boites du module + * Disable function. Deletes the module constant and boxes from the database. * - * @param array $array_sql Array of SQL requests to execute when disable module - * @param string $options String with options when disabling module ('newboxdefonly|noboxes') - * @return int 1 if OK, 0 if KO + * @param string[] $array_sql SQL requests to be executed when module is disabled + * @param string $options Options when disabling module ('newboxdefonly|noboxes') + * + * @return int 1 if OK, 0 if KO */ function _remove($array_sql, $options='') { @@ -339,10 +344,9 @@ abstract class DolibarrModules /** - * Retourne le nom traduit du module si la traduction existe dans admin.lang, - * sinon le nom defini par defaut dans le module. + * Gives the translated module name if translation exists in admin.lang or the default module name. * - * @return string Nom du module traduit + * @return string Translated module name */ function getName() { @@ -351,22 +355,21 @@ abstract class DolibarrModules if ($langs->trans("Module".$this->numero."Name") != ("Module".$this->numero."Name")) { - // Si traduction du nom du module existe + // If module name translation exists return $langs->trans("Module".$this->numero."Name"); } else { - // If translation of module with its numero does not exists, we take its name + // If module name translation using it's unique id does not exists, we take its name return $this->name; } } /** - * Retourne la description traduite du module si la traduction existe dans admin.lang, - * sinon la description definie par defaut dans le module + * Gives the translated module description if translation exists in admin.lang or the default module description * - * @return string Nom du module traduit + * @return string Translated module description */ function getDesc() { @@ -375,24 +378,23 @@ abstract class DolibarrModules if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) { - // Si traduction de la description du module existe + // If module description translation exists return $langs->trans("Module".$this->numero."Desc"); } else { - // Si traduction de la description du module n'existe pas, on prend definition en dur dans module + // If module description translation using it's unique id does not exists, we take its description return $this->description; } } /** - * Return module version. - * Pour les modules a l'etat 'experimental', retourne la traduction de 'experimental' - * Pour les modules 'dolibarr', retourne la version de Dolibarr - * Pour les autres modules, retourne la version du module + * Gives module version + * For 'experimental' modules, gives 'experimental' translation + * For 'dolibarr' modules, gives Dolibarr version * - * @return string Version du module + * @return string Module version */ function getVersion() { @@ -408,9 +410,9 @@ abstract class DolibarrModules /** - * Return if a module is a core or external module + * Tells if module is core or external * - * @return string 'core', 'external' or 'unknown' + * @return string 'core', 'external' or 'unknown' */ function isCoreOrExternalModule() { @@ -422,9 +424,9 @@ abstract class DolibarrModules /** - * Return list of lang files related to module + * Gives module related language files list * - * @return array Array of lang files + * @return string[] Language files list */ function getLangFilesArray() { @@ -432,10 +434,11 @@ abstract class DolibarrModules } /** - * Return translated label of a export dataset + * Gives translated label of an export dataset * - * @param int $r Index of dataset - * @return string Label of databaset + * @param int $r Dataset index + * + * @return string Translated databaset label */ function getExportDatasetLabel($r) { @@ -456,10 +459,11 @@ abstract class DolibarrModules /** - * Return translated label of an import dataset + * Gives translated label of an import dataset * - * @param int $r Index of dataset - * @return string Label of databaset + * @param int $r Dataset index + * + * @return string Translated dataset label */ function getImportDatasetLabel($r) { @@ -481,9 +485,9 @@ abstract class DolibarrModules /** - * Insert constant to activate module + * Insert constants for module activation * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function _active() { @@ -516,10 +520,10 @@ abstract class DolibarrModules /** - * Remove activation line + * Module deactivation * - * @return int Nb of errors (0 if OK) - **/ + * @return int Error count (0 if OK) + */ function _unactive() { global $conf; @@ -541,13 +545,13 @@ abstract class DolibarrModules /** - * Create tables and keys required by module. - * Files module.sql and module.key.sql with create table and create keys - * commands must be stored in directory reldir='/module/sql/' - * This function is called by this->init + * Create tables and keys required by module. + * Files module.sql and module.key.sql with create table and create keys + * commands must be stored in directory reldir='/module/sql/' + * This function is called by this->init * - * @param string $reldir Relative directory where to scan files - * @return int <=0 if KO, >0 if OK + * @param string $reldir Relative directory where to scan files + * @return int <=0 if KO, >0 if OK */ function _load_tables($reldir) { @@ -558,7 +562,7 @@ abstract class DolibarrModules if (empty($reldir)) return 1; - include_once DOL_DOCUMENT_ROOT .'/core/lib/admin.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; $ok = 1; foreach($conf->file->dol_document_root as $dirroot) @@ -635,14 +639,15 @@ abstract class DolibarrModules /** - * Insert boxes into llx_boxes_def + * Adds boxes * - * @param string $option String with options when disabling module ('newboxdefonly'=insert only boxes definition) - * @return int Nb of errors (0 if OK) + * @param string $option Options when disabling module ('newboxdefonly'=insert only boxes definition) + * + * @return int Error count (0 if OK) */ function insert_boxes($option='') { - require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; global $conf; @@ -732,9 +737,9 @@ abstract class DolibarrModules /** - * Delete boxes + * Removes boxes * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function delete_boxes() { @@ -784,9 +789,9 @@ abstract class DolibarrModules } /** - * Remove links to new module page present in llx_const + * Removes tabs * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function delete_tabs() { @@ -809,9 +814,9 @@ abstract class DolibarrModules } /** - * Add links of new pages from modules in llx_const + * Adds tabs * - * @return int Number of errors (0 if ok) + * @return int Error count (0 if ok) */ function insert_tabs() { @@ -844,13 +849,7 @@ abstract class DolibarrModules $sql.= ")"; dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); - $resql=$this->db->query($sql); - /* Allow duplicate key - if (! $resql) - { - $err++; - } - */ + $this->db->query($sql); } $i++; } @@ -859,9 +858,9 @@ abstract class DolibarrModules } /** - * Insert constants defined into $this->const array into table llx_const + * Adds constants * - * @return int Number of errors (0 if OK) + * @return int Error count (0 if OK) */ function insert_const() { @@ -926,9 +925,9 @@ abstract class DolibarrModules } /** - * Remove constants with tags deleteonunactive + * Removes constants tagged 'deleteonunactive' * - * @return int <0 if KO, 0 if OK + * @return int <0 if KO, 0 if OK */ function delete_const() { @@ -959,11 +958,12 @@ abstract class DolibarrModules } /** - * Insert permissions definitions related to the module into llx_rights_def + * Adds access rights * - * @param int $reinitadminperms If 1, we also grant them to all admin users - * @param int $force_entity Force current entity - * @return int Number of error (0 if OK) + * @param int $reinitadminperms If 1, we also grant them to all admin users + * @param int $force_entity Force current entity + * + * @return int Error count (0 if OK) */ function insert_permissions($reinitadminperms=0, $force_entity=null) { @@ -1055,7 +1055,7 @@ abstract class DolibarrModules if ($reinitadminperms) { if (! class_exists('User')) { - require DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + require DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; } $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); @@ -1099,9 +1099,9 @@ abstract class DolibarrModules /** - * Delete permissions + * Removes access rights * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function delete_permissions() { @@ -1124,15 +1124,15 @@ abstract class DolibarrModules /** - * Insert menus entries found into $this->menu into llx_menu* + * Adds menu entries * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function insert_menus() { global $user; - require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; $err=0; @@ -1228,9 +1228,9 @@ abstract class DolibarrModules /** - * Remove menus entries + * Removes menu entries * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function delete_menus() { @@ -1254,9 +1254,9 @@ abstract class DolibarrModules } /** - * Create directories required by module + * Creates directories * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function create_dirs() { @@ -1312,11 +1312,12 @@ abstract class DolibarrModules /** - * Insert directories in llx_const + * Adds directories definitions * - * @param string $name Name - * @param string $dir Directory - * @return int Nb of errors (0 if OK) + * @param string $name Name + * @param string $dir Directory + * + * @return int Error count (0 if OK) */ function insert_dirs($name,$dir) { @@ -1341,7 +1342,7 @@ abstract class DolibarrModules $sql.= " VALUES (".$this->db->encrypt($name,1).",'chaine',".$this->db->encrypt($dir,1).",'Directory for module ".$this->name."','0',".$conf->entity.")"; dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG); - $resql=$this->db->query($sql); + $this->db->query($sql); } } else @@ -1355,9 +1356,9 @@ abstract class DolibarrModules /** - * Remove directory entries + * Removes directories * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function delete_dirs() { @@ -1380,23 +1381,9 @@ abstract class DolibarrModules } /** - * Insert activation of generic parts from modules in llx_const - * Input entry use $this->module_parts = array( - * 'triggers' => 0, // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers) - * 'login' => 0, // Set this to 1 if module has its own login method directory (/mymodule/core/login) - * 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions) - * 'menus' => 0, // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus) - * 'theme' => 0, // Set this to 1 if module has its own theme directory (/mymodule/theme) - * 'tpl' => 0, // Set this to 1 if module overwrite template dir (/mymodule/core/tpl) - * 'barcode' => 0, // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode) - * 'models' => 0, // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx) - * 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css file if module has its own css file - * 'js' => '/mymodule/js/mymodule.js', // Set this to relative path of js file if module must load a js on all pages - * 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module - * 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule') // Set here all workflow context managed by module - * ) + * Adds generic parts * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function insert_module_parts() { @@ -1465,9 +1452,9 @@ abstract class DolibarrModules } /** - * Remove activation of generic parts of modules from llx_const + * Removes generic parts * - * @return int Nb of errors (0 if OK) + * @return int Error count (0 if OK) */ function delete_module_parts() { @@ -1495,7 +1482,6 @@ abstract class DolibarrModules } } } - return $err; } From c21b3894622c5dab1391be4a80cd70482e4fd75a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Aug 2014 14:17:27 +0200 Subject: [PATCH 011/123] Fix: Pb with focus position with ckeditor --- htdocs/includes/ckeditor/contents.css | 2 +- htdocs/theme/eldy/style.css.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/includes/ckeditor/contents.css b/htdocs/includes/ckeditor/contents.css index 100ed27b5d4..3d9895c2442 100644 --- a/htdocs/includes/ckeditor/contents.css +++ b/htdocs/includes/ckeditor/contents.css @@ -15,7 +15,7 @@ body /* Remove the background color to make it transparent */ background-color: #fff; - margin: 20px; + margin: 8px; } .cke_editable diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7eeadd6ae1f..f3c86c0897f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -242,6 +242,10 @@ a:hover { text-decoration: underline; color: #000000;} input:focus, textarea:focus, button:focus, select:focus { box-shadow: 0 0 4px #8091BF; } +textarea.cke_source:focus +{ + box-shadow: none; +} input, input.flat, textarea, textarea.flat, form.flat select, select.flat { font-size: px; @@ -2493,6 +2497,10 @@ A.none, A.none:active, A.none:visited, A.none:hover { /* CKEditor */ /* ============================================================================== */ +.cke_editable +{ + margin: 5px !important; +} .cke_editor table, .cke_editor tr, .cke_editor td { border: 0px solid #FF0000 !important; From 2c1e892efe7f414f0e5c8ad3f3746cce1e907bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 21 Aug 2014 12:39:17 +0200 Subject: [PATCH 012/123] Enhanced boxes model documentation --- htdocs/core/boxes/modules_boxes.php | 120 +++++++++++++++++++++------- 1 file changed, 90 insertions(+), 30 deletions(-) diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index ece19fe222c..275154cd80e 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -1,6 +1,7 @@ - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -25,31 +26,88 @@ /** - * Parent class of boxes + * Class ModeleBoxes + * + * Boxes parent class */ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" boxes { - var $db; - var $error=''; - var $max=5; - var $enabled=1; - - var $rowid; - var $id; - var $position; - var $box_order; - var $fk_user; - var $sourcefile; - var $class; - var $box_id; - var $note; - + /** + * @var DoliDB Database handler + */ + public $db; /** - * Constructor + * @var string Error message + */ + public $error = ''; + + /** + * @var int Maximum lines + */ + public $max = 5; + + /** + * @var int Status + */ + public $enabled=1; + + /** + * @var int Box definition database ID + */ + public $rowid; + + /** + * @var int ID + * @deprecated Same as box_id? + */ + public $id; + + /** + * @var int Position? + */ + public $position; + + /** + * @var string Display order + */ + public $box_order; + + /** + * @var int User ID + */ + public $fk_user; + + /** + * @var string Source file + */ + public $sourcefile; + + /** + * @var string Class name + */ + public $class; + + /** + * @var string ID + */ + public $box_id; + + /** + * @var string Alphanumeric ID + */ + public $boxcode; + + /** + * @var string Note + */ + public $note; + + /** + * Constructor * - * @param DoliDB $db Database handler - * @param string $param More parameters + * @param DoliDB $db Database handler + * @param string $param More parameters */ function __construct($db,$param='') { @@ -57,9 +115,9 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" } /** - * Return last error message + * Return last error message * - * @return string Error message + * @return string Error message */ function error() { @@ -68,10 +126,11 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" /** - * Load a box line from its rowid + * Load a box line from its rowid * - * @param int $rowid Row id to load - * @return int <0 if KO, >0 if OK + * @param int $rowid Row id to load + * + * @return int <0 if KO, >0 if OK */ function fetch($rowid) { @@ -110,11 +169,12 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" /** - * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) + *Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @return void + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * + * @return void */ function showBox($head, $contents) { From d485e270b99c0a391308fb925b46934380061083 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Aug 2014 23:19:01 +0200 Subject: [PATCH 013/123] Fix: menu param is not inside allowed list --- htdocs/cashdesk/affContenu.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index ca471e0bdf4..543006baedf 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -55,6 +55,8 @@ print ''; print '
'; $page=GETPOST('menu','alpha'); +if (empty($page)) $page='facturation'; + if (in_array( $page, array( From cd5d3f5368bda841f52f7d0ccad6a74c3bc742de Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 22 Aug 2014 07:19:14 +0200 Subject: [PATCH 014/123] Fix :: Sql problem on resource table --- htdocs/install/mysql/tables/llx_c_type_resource.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_type_resource.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql index 5a76ff0cfa6..dc5c5ee150a 100644 --- a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql +++ b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql @@ -17,5 +17,5 @@ -- ======================================================================== -ALTER TABLE llx_c_type_contact ADD UNIQUE INDEX uk_c_type_contact_id (element, source, code); +ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code); diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.sql b/htdocs/install/mysql/tables/llx_c_type_resource.sql index efb505ba574..8ba088c075e 100644 --- a/htdocs/install/mysql/tables/llx_c_type_resource.sql +++ b/htdocs/install/mysql/tables/llx_c_type_resource.sql @@ -29,6 +29,6 @@ create table llx_c_type_resource ( rowid integer PRIMARY KEY, code varchar(32) NOT NULL, - libelle varchar(64) NOT NULL, + label varchar(64) NOT NULL, active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; From b0163fbed25b3b4bef00d3ab07b65fc96668afca Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Fri, 22 Aug 2014 16:17:45 +0200 Subject: [PATCH 015/123] 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 a353f816e311b340b2b84e85785006fb82449190 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Fri, 22 Aug 2014 16:17:45 +0200 Subject: [PATCH 016/123] 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 d7bb50682fe..aa475c04176 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -227,7 +227,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 8e6a40d4756186830ad41714ff5086dadbb0209d Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Fri, 22 Aug 2014 16:17:45 +0200 Subject: [PATCH 017/123] 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 22466a3143f..cb4f178b840 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -224,7 +224,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 a97241f71682f59ff629c881b0566696becd42b1 Mon Sep 17 00:00:00 2001 From: Cubexed Date: Sat, 23 Aug 2014 17:05:08 +0200 Subject: [PATCH 018/123] Fix unable to delete order line Calling trigger without having globalized $conf causes error and cancels delete operation, this commit adds the missing 2014-08-23 16:52:05 ERR 127.0.0.1 Interfaces::run_triggers was called with wrong parameters action=LINEORDER_SUPPLIER_DELETE object=1 user= langs= conf= --- htdocs/fourn/class/fournisseur.commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f083318948e..0b62fc91526 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1379,6 +1379,7 @@ class CommandeFournisseur extends CommonOrder */ function deleteline($idline, $notrigger=0) { + global $user,$langs,$conf; if ($this->statut == 0) { $this->db->begin(); From 7cb283d0ea9800904c5da1d66a37a19305331b53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Aug 2014 19:16:37 +0200 Subject: [PATCH 019/123] Prepare code to be able to choose what to show into footer --- htdocs/core/lib/pdf.lib.php | 17 +++++++++++------ .../modules/cheque/pdf/pdf_blochet.class.php | 3 ++- .../commande/doc/pdf_einstein.modules.php | 3 ++- .../commande/doc/pdf_proforma.modules.php | 3 ++- .../modules/contract/doc/pdf_strato.modules.php | 3 ++- .../expedition/doc/pdf_rouget.modules.php | 3 ++- .../modules/facture/doc/pdf_crabe.modules.php | 3 ++- .../fichinter/doc/pdf_soleil.modules.php | 3 ++- .../livraison/pdf/pdf_typhon.modules.php | 7 ++++--- .../modules/project/pdf/pdf_baleine.modules.php | 7 ++++--- .../modules/propale/doc/pdf_azur.modules.php | 3 ++- .../pdf/pdf_canelle.modules.php | 3 ++- .../supplier_order/pdf/pdf_muscadet.modules.php | 7 ++++--- htdocs/langs/en_US/admin.lang | 1 + 14 files changed, 42 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ade08400762..e0c6c9ee0e0 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -651,7 +651,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default * @param int $marge_gauche Margin left (no more used) * @param int $page_hauteur Page height (no more used) * @param Object $object Object shown in PDF - * @param int $showdetails Show company details into footer. This param seems to not be used by standard version. + * @param int $showdetails Show company details into footer. This param seems to not be used by standard version. (1=Show address, 2=Show managers, 3=Both) * @param int $hidefreetext 1=Hide free text, 0=Show free text * @return int Return height of bottom margin including footer text */ @@ -681,10 +681,10 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass } // First line of company infos + $line1=""; $line2=""; $line3=""; $line4=""; - if ($showdetails) + if ($showdetails && 1) { - $line1=""; // Company name if ($fromcompany->name) { @@ -716,7 +716,6 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $line1.=($line1?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; } - $line2=""; // URL if ($fromcompany->url) { @@ -728,9 +727,16 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $line2.=($line2?" - ":"").$fromcompany->email; } } + if (($showdetails && 2) || ($fromcompany->country_code == 'DE')) + { + // Managers + if ($fromcompany->managers) + { + $line2.=($line2?" - ":"").$fromcompany->managers; + } + } // Line 3 of company infos - $line3=""; // Juridical status if ($fromcompany->forme_juridique_code) { @@ -757,7 +763,6 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass } // Line 4 of company infos - $line4=""; // Prof Id 3 if ($fromcompany->idprof3) { diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index 96214f08d66..ecb4abd561c 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -352,7 +352,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); - //return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object); + //$showdetails=0; + //return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; $marge_basse=$this->marge_basse; $marge_gauche=$this->marge_gauche; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 712dd0b765c..236a4d52454 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1271,7 +1271,8 @@ class pdf_einstein extends ModelePDFCommandes */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 408fd543c93..38ca0a8748e 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -1228,7 +1228,8 @@ class pdf_proforma extends ModelePDFCommandes */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 5fc0eb6dd2a..cee022805af 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -610,7 +610,8 @@ class pdf_strato extends ModelePDFContract */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'CONTRACT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 6d0e44817a7..177a2bb4fa7 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -657,7 +657,8 @@ class pdf_rouget extends ModelePdfExpedition */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index d07bd93825c..3c3cca12440 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1455,7 +1455,8 @@ class pdf_crabe extends ModelePDFFactures */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index f2055e8d643..284dc62a0b7 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -595,7 +595,8 @@ class pdf_soleil extends ModelePDFFicheinter */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index 095e325cb81..75bdc06aaed 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -358,7 +358,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder //$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxremainingqty - $this->posxqty, 3, $object->lines[$i]->qty_shipped, 0, 'R'); - + // Remaining to ship $pdf->SetXY($this->posxremainingqty, $curY); $qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line]; @@ -613,7 +613,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell($this->posxcomm - $this->posxdesc,2, $outputlangs->transnoentities("Designation"),'','L'); } - + // Modif SEB pour avoir une col en plus pour les commentaires clients $pdf->line($this->posxcomm, $tab_top, $this->posxcomm, $tab_top + $tab_height); if (empty($hidetop)) { @@ -863,7 +863,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index e6505c05283..e727f9ba90b 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -295,7 +295,7 @@ class pdf_baleine extends ModelePDFProjects $pdf->Close(); $pdf->Output($file,'F'); - + // Add pdfgeneration hook if (! is_object($hookmanager)) { @@ -306,7 +306,7 @@ class pdf_baleine extends ModelePDFProjects $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - + if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -454,7 +454,8 @@ class pdf_baleine extends ModelePDFProjects */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 4ac15330b42..4678b5a48af 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1362,7 +1362,8 @@ class pdf_azur extends ModelePDFPropales */ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 848778275eb..49a46c79e2e 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -1052,7 +1052,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index d601167c26d..1c9315a61bd 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -701,7 +701,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders foreach( $this->localtax1 as $localtax_type => $localtax_rate ) { if (in_array((string) $localtax_type, array('2','4','6'))) continue; - + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey != 0) // On affiche pas taux 0 @@ -733,7 +733,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders foreach( $this->localtax2 as $localtax_type => $localtax_rate ) { if (in_array((string) $localtax_type, array('2','4','6'))) continue; - + foreach( $localtax_rate as $tvakey => $tvaval ) { if ($tvakey != 0) // On affiche pas taux 0 @@ -1105,7 +1105,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders */ function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0) { - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e4cf7ab08ce..da61d43c1ad 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1082,6 +1082,7 @@ NotificationsDesc=EMails notifications feature allows you to silently send autom ModelModules=Documents templates DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...) WatermarkOnDraft=Watermark on draft document +JSOnPaimentBill=Activate feature to autofill payment lines on payment form CompanyIdProfChecker=Rules on Professional Ids MustBeUnique=Must be unique ? MustBeMandatory=Mandatory to create third parties ? From a5deeebfdca8aca6c2d97f4d0d0ed60251fb6acb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Aug 2014 19:32:36 +0200 Subject: [PATCH 020/123] Add try catch --- htdocs/comm/mailing/cibles.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index df51f91e1a2..e10ea970b43 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -98,11 +98,10 @@ if ($action == 'add') $result=$obj->add_to_target($id,$filtersarray); } } - if ($result > 0) { setEventMessage($langs->trans("XTargetsAdded",$result),'mesgs'); - + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -167,7 +166,6 @@ if ($_POST["button_removefilter"]) /* * View */ - llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'); $form = new Form($db); @@ -306,12 +304,14 @@ if ($object->fetch($id) >= 0) print img_object($langs->trans("Module").': '.get_class($obj),$obj->picto).' '.$obj->getDesc(); print ''; - /* - print ''; - print $modulename; - print ""; - */ - $nbofrecipient=$obj->getNbOfRecipients(''); + try { + $nbofrecipient=$obj->getNbOfRecipients(''); + } + catch(Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } + print ''; if ($nbofrecipient >= 0) { @@ -324,7 +324,13 @@ if ($object->fetch($id) >= 0) print ''; print ''; - $filter=$obj->formFilter(); + try { + $filter=$obj->formFilter(); + } + catch(Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } if ($filter) print $filter; else print $langs->trans("None"); print ''; @@ -421,7 +427,7 @@ if ($object->fetch($id) >= 0) print ''; print ' '; print ''; - + print ''; // Ligne des champs de filtres @@ -446,7 +452,7 @@ if ($object->fetch($id) >= 0) print ''; print ' '; print ''; - + // Date sending print ''; print ' '; @@ -530,7 +536,7 @@ if ($object->fetch($id) >= 0) print $object::libStatutDest($obj->statut,2); print ''; } - + //Sreach Icon print ''; print ''; From b7daef10c6f7c4c1ae3fbf2a86bd6797f932a423 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 26 Aug 2014 04:35:22 +0200 Subject: [PATCH 021/123] Fix llx_c_type_resource when you update from a 3.6-beta --- htdocs/install/mysql/migration/3.5.0-3.6.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 919fbee7d4d..0e7a226d0bd 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -293,6 +293,9 @@ create table llx_c_type_resource active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; +-- Fix llx_c_type_resource when you update from a 3.6-beta +ALTER TABLE llx_c_type_resource CHANGE libelle label VARCHAR(64) NOT NULL; + ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code); -- Fix :: account_parent must be an int, not an account number From 28ad819ab4a9e3f7c3de6b593ce5e1dcb636034e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Aug 2014 09:49:15 +0200 Subject: [PATCH 022/123] 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 ca7ff0ecfab48f79c1eaf4b1f106f0f5479fddfb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Aug 2014 09:49:15 +0200 Subject: [PATCH 023/123] 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 c31f8bd3855..2667e328e58 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1236,7 +1236,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 9dafdf41bb69a421c367565b8b560ff1cba819f8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Aug 2014 09:49:15 +0200 Subject: [PATCH 024/123] 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 fba04593b5b..b1e9ccffd52 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1247,7 +1247,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 a3469f1f01e0c400d959d84259a37101d3b5b322 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 26 Aug 2014 11:27:57 +0200 Subject: [PATCH 025/123] FIX bug on migration 3.6 -> 3.7 --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 868496f3316..40dd7b62f44 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -982,7 +982,6 @@ ALTER TABLE llx_c_civility ADD UNIQUE INDEX uk_c_civility(code); ALTER TABLE llx_adherent CHANGE civilite civility VARCHAR(6); ALTER TABLE llx_socpeople CHANGE civilite civility VARCHAR(6); ALTER TABLE llx_user CHANGE civilite civility VARCHAR(6); -) ENGINE=innodb; ALTER TABLE llx_c_type_fees CHANGE libelle label VARCHAR(30); ALTER TABLE llx_c_type_fees ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER label; From 85228fd8e78209a70a6f0147b139a6f698a119c6 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 26 Aug 2014 11:50:02 +0200 Subject: [PATCH 026/123] add support in admin --- htdocs/core/lib/fichinter.lib.php | 5 +++++ htdocs/fichinter/class/fichinter.class.php | 5 ++++- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 01d79cdcabe..cb30a202513 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -126,6 +126,11 @@ function fichinter_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributesdet'; + $h++; + complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove'); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index cb4f178b840..a62cefe32bf 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -987,7 +987,10 @@ class FichinterLigne extends CommonObjectLine var $duration; // Duree de l'intervention var $rang = 0; - + public $element='fichinterdet'; + public $table_element='fichinterdet'; + public $fk_element='fk_fichinter'; + /** * Constructor * diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 40dd7b62f44..dea3955ce52 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -991,3 +991,15 @@ ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_element (fk_element); ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_task (fk_task); ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_date (task_date); ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_datehour); + + +-- add extrafield on ficheinter lines +CREATE TABLE IF NOT EXISTS `llx_fichinterdet_extrafields` ( + `rowid` int(11) NOT NULL AUTO_INCREMENT, + `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `fk_object` int(11) NOT NULL, + `import_key` varchar(14) DEFAULT NULL, + PRIMARY KEY (`rowid`), + KEY `idx_ficheinter_extrafields` (`fk_object`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + From 40aadc8125b41b9ae955d5e272c83fc44676e970 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 26 Aug 2014 12:11:34 +0200 Subject: [PATCH 027/123] add extrafield in add form --- htdocs/core/class/commonobjectline.class.php | 2 +- .../admin/fichinterdet_extrafields.php | 159 ++++++++++++++++++ htdocs/fichinter/fiche.php | 11 +- 3 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 htdocs/fichinter/admin/fichinterdet_extrafields.php diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 675e1cf0794..3ba7cbf52ca 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -26,7 +26,7 @@ * Parent class for class inheritance lines of business objects * This class is useless for the moment so no inherit are done on it */ -abstract class CommonObjectLine +abstract class CommonObjectLine extends CommonObject { /** * Call trigger based on this instance diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php new file mode 100644 index 00000000000..7f8b5193631 --- /dev/null +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -0,0 +1,159 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/fichinter/admin/fichinter_extrafields.php + * \ingroup fichinter + * \brief Page to setup extra fields of ficheinter + */ + + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load("members"); +$langs->load('interventions'); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='fichinterdet'; //Must be the $element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + + +llxHeader(); + +$textobject=$langs->transnoentitiesnoconv("Interventions"); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup'); + + +$head=fichinter_admin_prepare_head(); + +dol_fiche_head($head, 'attributesdet', $langs->trans("Interventions"), 0, 'intervention'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Position").''.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel + /* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 437002aa23c..4943e5bc245 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1511,7 +1511,16 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; - + + //Line extrafield + + $lineadd = new FichinterLigne($db); + + $extrafieldsline = new ExtraFields($db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($lineadd->table_element); + + print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>4)); + if (! $num) print ''; } From 1e28fd354146ab4a7e65dcbbcba92e5b84daa8b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Aug 2014 15:24:32 +0200 Subject: [PATCH 028/123] Fix: syntax error --- build/debian/dolibarr.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 0f99f53203b..8a6078af377 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -129,7 +129,7 @@ case "$1" in then # Create an empty conf.php with permission to web server setup_empty_conf - else + #else # File already exist. We add params not found. #echo Add new params to overwrite path to use shared libraries/fonts #grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config From 35fca84f19e66d062f02cbbde570cb68c7b8285c Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 26 Aug 2014 17:08:03 +0200 Subject: [PATCH 029/123] ok on insert --- htdocs/fichinter/class/fichinter.class.php | 37 ++++++++++++++++++++-- htdocs/fichinter/fiche.php | 26 +++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index a62cefe32bf..642dfe29bcb 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -855,7 +855,7 @@ class Fichinter extends CommonObject * @param int $duration Intervention duration * @return int >0 if ok, <0 if ko */ - function addline($user,$fichinterid, $desc, $date_intervention, $duration) + function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_option=0) { dol_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration"); @@ -871,14 +871,20 @@ class Fichinter extends CommonObject $line->datei = $date_intervention; $line->duration = $duration; + if (is_array($array_option) && count($array_option)>0) { + $line->array_options=$array_option; + } + $result=$line->insert($user); - if ($result > 0) + + if ($result >= 0) { + $this->db->commit(); return 1; } else - { + { $this->error=$this->db->error(); $this->db->rollback(); return -1; @@ -1085,7 +1091,21 @@ class FichinterLigne extends CommonObjectLine $resql=$this->db->query($sql); if ($resql) { + $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet'); + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + $result=$this->update_total(); + if ($result > 0) { $this->rang=$rangToUse; @@ -1143,6 +1163,17 @@ class FichinterLigne extends CommonObjectLine $resql=$this->db->query($sql); if ($resql) { + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + $result=$this->update_total(); if ($result > 0) { diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 4943e5bc245..7b94d03c503 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -266,12 +266,20 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $duration = 0; } + $predef = ''; + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + + $result = $object->addline( $user, $id, $desc, $date_intervention, - $duration + $duration, + $array_option ); if ($result < 0) @@ -433,12 +441,19 @@ else if ($action == "addline" && $user->rights->ficheinter->creer) $date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int')); $duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int')); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $result=$object->addline( $user, $id, $desc, $date_intervention, - $duration + $duration, + $array_option ); // Define output language @@ -524,6 +539,13 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST( $objectline->datei = $date_inter; $objectline->desc = $desc; $objectline->duration = $duration; + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $objectline->array_options = $array_option; + $result = $objectline->update($user); if ($result < 0) { From 7af788729b280bb98f0b1682973c170d457ca331 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 26 Aug 2014 17:25:13 +0200 Subject: [PATCH 030/123] debug extrafield on create card --- htdocs/fichinter/class/fichinter.class.php | 12 +++++++ htdocs/fichinter/fiche.php | 39 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 642dfe29bcb..80375648e26 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -167,6 +167,17 @@ class Fichinter extends CommonObject $resql=$this->db->query($sql); if (! $resql) $error++; } + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + // Add linked object if (! $error && $this->origin && $this->origin_id) { @@ -1026,6 +1037,7 @@ class FichinterLigne extends CommonObjectLine { $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; + $this->id = $objp->rowid; $this->fk_fichinter = $objp->fk_fichinter; $this->datei = $this->db->jdate($objp->datei); $this->desc = $objp->description; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 7b94d03c503..36bf1690b3c 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -196,6 +196,13 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } + // Extrafields + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $array_option = $extrafields->getOptionalsFromPost($extralabels); + + $object->array_options = $array_option; + $id = $object->create($user); if ($id > 0) @@ -306,6 +313,13 @@ else if ($action == 'add' && $user->rights->ficheinter->creer) } else { + // Extrafields + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $array_option = $extrafields->getOptionalsFromPost($extralabels); + + $object->array_options = $array_option; + $result = $object->create($user); if ($result > 0) { @@ -1455,6 +1469,18 @@ else if ($id > 0 || ! empty($ref)) } print ''; + + $line = new FichinterLigne($db); + $line->fetch($objp->rowid); + + $extrafieldsline = new ExtraFields($db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element); + + $line->fetch_optionals($line->rowid, $extralabelslines); + + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5)); + + } // Line in update mode @@ -1483,6 +1509,17 @@ else if ($id > 0 || ! empty($ref)) print ''; print '
'; print '' . "\n"; + + $line = new FichinterLigne($db); + $line->fetch($objp->rowid); + + $extrafieldsline = new ExtraFields($db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element); + $line->fetch_optionals($line->rowid, $extralabelslines); + + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5)); + + } $i++; @@ -1541,7 +1578,7 @@ else if ($id > 0 || ! empty($ref)) $extrafieldsline = new ExtraFields($db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($lineadd->table_element); - print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>4)); + print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5)); if (! $num) print ''; } From a31fec1b0b50ee08d89b3659aaf2f78b5f992249 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Tue, 26 Aug 2014 19:55:35 +0200 Subject: [PATCH 031/123] Fix tab active to real tab active --- htdocs/comm/action/listactions.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 055086bbdbb..ae145d4be21 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -197,12 +197,7 @@ if ($resql) $newtitle=$langs->trans($title); - $tabactive=''; - if ($action == 'show_month') $tabactive='cardmonth'; - if ($action == 'show_week') $tabactive='cardweek'; - if ($action == 'show_day') $tabactive='cardday'; - if ($action == 'show_list') $tabactive='cardlist'; - if ($action == 'show_peruser') $tabactive='cardperuser'; + $tabactive='cardlist'; $head = calendars_prepare_head($param); From 4b4360af32ac43e4f2bc7ad8fa829515e9d5e1ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Aug 2014 23:02:21 +0200 Subject: [PATCH 032/123] Fix: sql syntax errors --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 868496f3316..ac16eefefa9 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -975,14 +975,13 @@ CREATE TABLE llx_holiday_types ( ); -- Change on table c_civilite -DROP INDEX uk_c_civilite ON llx_c_civilite; +ALTER TABLE llx_c_civilite DROP INDEX uk_c_civilite; ALTER TABLE llx_c_civilite RENAME TO llx_c_civility; ALTER TABLE llx_c_civility CHANGE civilite label VARCHAR(50); ALTER TABLE llx_c_civility ADD UNIQUE INDEX uk_c_civility(code); ALTER TABLE llx_adherent CHANGE civilite civility VARCHAR(6); ALTER TABLE llx_socpeople CHANGE civilite civility VARCHAR(6); ALTER TABLE llx_user CHANGE civilite civility VARCHAR(6); -) ENGINE=innodb; ALTER TABLE llx_c_type_fees CHANGE libelle label VARCHAR(30); ALTER TABLE llx_c_type_fees ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER label; From c3fe0c1ae9c4c69204503df976a2cf403c5137bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Aug 2014 23:08:06 +0200 Subject: [PATCH 033/123] Fix: sql errors into migration scripts --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index ac16eefefa9..cbe07b2fbdf 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -101,6 +101,7 @@ ALTER TABLE llx_product MODIFY COLUMN fk_barcode_type INTEGER NULL DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_product ALTER COLUMN fk_barcode_type SET DEFAULT NULL; UPDATE llx_product SET fk_barcode_type = NULL WHERE fk_barcode_type = 0; ALTER TABLE llx_product ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); +UPDATE llx_product SET fk_barcode_type = NULL WHERE fk_barcode_type NOT IN (SELECT rowid from llx_c_barcode_type); ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); From 12c67529712d924f16989b92f421ec4d0fe89485 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Aug 2014 23:45:02 +0200 Subject: [PATCH 034/123] Fix: Can upload files on services. --- ChangeLog | 4 ++++ htdocs/product/document.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d6ba26267a6..1cf11ece40a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.6.1 compared to 3.6.* ***** +For users: +- Fix: Can upload files on services. + ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: - New: Update ckeditor to version 4. diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 3e5417ae9e8..1e8c7b7cd9a 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -141,7 +141,7 @@ if ($object->id) print '
'; $modulepart = 'produit'; - $permission = $user->rights->produit->creer; + $permission = (($object->type == 0 && $user->rights->produit->creer) || ($object->type == 1 && $user->rights->service->creer)); $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } From 4405f17f2280395c83260911b439b808a2b2a437 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Aug 2014 23:47:44 +0200 Subject: [PATCH 035/123] Update changelog --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1cf11ece40a..f92c959db50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: - Fix: Can upload files on services. +- Fix: sql errors on updat fichinter +- Fix: debian script syntax error +- Fix: error "menu param is not inside list" into pos module. ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: From 71265558d2aad3c28cf4cc64e2d24f3160b412a3 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 27 Aug 2014 07:03:42 +0200 Subject: [PATCH 036/123] Integrate module Accounting Expert --- htdocs/accountancy/admin/account.php | 220 ++++++ htdocs/accountancy/admin/export.php | 176 +++++ htdocs/accountancy/admin/fiche.php | 297 ++++++++ htdocs/accountancy/admin/importaccounts.php | 197 +++++ htdocs/accountancy/admin/index.html | 0 htdocs/accountancy/admin/index.php | 301 ++++++++ htdocs/accountancy/admin/journaux.php | 176 +++++ htdocs/accountancy/admin/productaccount.php | 149 ++++ .../accountancy/admin/thirdpartyaccount.php | 253 +++++++ .../bookkeeping/balancebymonth.php | 143 ++++ htdocs/accountancy/bookkeeping/fiche.php | 385 ++++++++++ htdocs/accountancy/bookkeeping/index.html | 0 htdocs/accountancy/bookkeeping/liste.php | 226 ++++++ .../accountancy/bookkeeping/listebyyear.php | 137 ++++ .../class/accountancysystem.class.php | 86 +-- .../class/accountingaccount.class.php | 416 +++++++++++ .../accountancy/class/bookkeeping.class.php | 672 ++++++++++++++++++ .../class/html.formventilation.class.php | 246 +++++++ htdocs/accountancy/customer/fiche.php | 146 ++++ htdocs/accountancy/customer/index.html | 0 htdocs/accountancy/customer/index.php | 353 +++++++++ htdocs/accountancy/customer/lignes.php | 232 ++++++ htdocs/accountancy/customer/liste.php | 246 +++++++ htdocs/accountancy/journal/bankjournal.php | 568 +++++++++++++++ htdocs/accountancy/journal/cashjournal.php | 544 ++++++++++++++ htdocs/accountancy/journal/index.html | 0 htdocs/accountancy/journal/index.php | 58 ++ .../accountancy/journal/purchasesjournal.php | 482 +++++++++++++ htdocs/accountancy/journal/sellsjournal.php | 490 +++++++++++++ htdocs/accountancy/supplier/fiche.php | 149 ++++ htdocs/accountancy/supplier/index.html | 0 htdocs/accountancy/supplier/index.php | 272 +++++++ htdocs/accountancy/supplier/lignes.php | 232 ++++++ htdocs/accountancy/supplier/liste.php | 227 ++++++ htdocs/admin/accounting.php | 260 ------- htdocs/core/lib/accounting.lib.php | 188 +++++ htdocs/core/modules/modAccounting.class.php | 662 +++++++++++++---- .../install/mysql/migration/3.6.0-3.7.0.sql | 35 +- .../tables/llx_accounting_bookkeeping.sql | 39 + htdocs/langs/en_US/accounting.lang | 161 +++++ htdocs/langs/es_ES/accounting.lang | 161 +++++ htdocs/langs/fr_FR/accounting.lang | 161 +++++ htdocs/theme/amarok/img/object_accounting.png | Bin 0 -> 170 bytes .../theme/auguria/img/object_accounting.png | Bin 0 -> 170 bytes .../bureau2crea/img/object_accounting.png | Bin 0 -> 170 bytes .../theme/cameleo/img/object_accounting.png | Bin 0 -> 170 bytes htdocs/theme/eldy/img/object_accounting.png | Bin 0 -> 170 bytes 47 files changed, 9309 insertions(+), 437 deletions(-) create mode 100644 htdocs/accountancy/admin/account.php create mode 100644 htdocs/accountancy/admin/export.php create mode 100644 htdocs/accountancy/admin/fiche.php create mode 100644 htdocs/accountancy/admin/importaccounts.php create mode 100644 htdocs/accountancy/admin/index.html create mode 100644 htdocs/accountancy/admin/index.php create mode 100644 htdocs/accountancy/admin/journaux.php create mode 100644 htdocs/accountancy/admin/productaccount.php create mode 100644 htdocs/accountancy/admin/thirdpartyaccount.php create mode 100644 htdocs/accountancy/bookkeeping/balancebymonth.php create mode 100644 htdocs/accountancy/bookkeeping/fiche.php create mode 100644 htdocs/accountancy/bookkeeping/index.html create mode 100644 htdocs/accountancy/bookkeeping/liste.php create mode 100644 htdocs/accountancy/bookkeeping/listebyyear.php create mode 100644 htdocs/accountancy/class/accountingaccount.class.php create mode 100644 htdocs/accountancy/class/bookkeeping.class.php create mode 100644 htdocs/accountancy/class/html.formventilation.class.php create mode 100644 htdocs/accountancy/customer/fiche.php create mode 100644 htdocs/accountancy/customer/index.html create mode 100644 htdocs/accountancy/customer/index.php create mode 100644 htdocs/accountancy/customer/lignes.php create mode 100644 htdocs/accountancy/customer/liste.php create mode 100644 htdocs/accountancy/journal/bankjournal.php create mode 100644 htdocs/accountancy/journal/cashjournal.php create mode 100644 htdocs/accountancy/journal/index.html create mode 100644 htdocs/accountancy/journal/index.php create mode 100644 htdocs/accountancy/journal/purchasesjournal.php create mode 100644 htdocs/accountancy/journal/sellsjournal.php create mode 100644 htdocs/accountancy/supplier/fiche.php create mode 100644 htdocs/accountancy/supplier/index.html create mode 100644 htdocs/accountancy/supplier/index.php create mode 100644 htdocs/accountancy/supplier/lignes.php create mode 100644 htdocs/accountancy/supplier/liste.php delete mode 100644 htdocs/admin/accounting.php create mode 100644 htdocs/core/lib/accounting.lib.php create mode 100644 htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql create mode 100644 htdocs/langs/en_US/accounting.lang create mode 100644 htdocs/langs/es_ES/accounting.lang create mode 100644 htdocs/langs/fr_FR/accounting.lang create mode 100644 htdocs/theme/amarok/img/object_accounting.png create mode 100644 htdocs/theme/auguria/img/object_accounting.png create mode 100644 htdocs/theme/bureau2crea/img/object_accounting.png create mode 100644 htdocs/theme/cameleo/img/object_accounting.png create mode 100644 htdocs/theme/eldy/img/object_accounting.png diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php new file mode 100644 index 00000000000..f0bbd02f330 --- /dev/null +++ b/htdocs/accountancy/admin/account.php @@ -0,0 +1,220 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/admin/account.php + * \ingroup Accounting Expert + * \brief List accounting account + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + +// Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/accountingex/class/accountingaccount.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// Langs +$langs->load("compta"); +$langs->load("accountingex@accountingex"); + +$mesg = ''; +$action = GETPOST('action'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$limit = $conf->liste_limit; +$page = GETPOST("page", 'int'); +if ($page == - 1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) + $sortfield = "aa.account_number"; +if (! $sortorder) + $sortorder = "ASC"; + +if ($action == 'delete') { + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + print $formconfirm; +} + +$accounting = new AccountingAccount($db); + +if ($action == 'disable') { + $accounting = $accounting->fetch($id); + if (! empty($accounting->id)) { + $result = $accounting->account_desactivate($id); + } + + $action = 'update'; + if ($result < 0) { + setEventMessage($accounting->error, 'errors'); + } +} else if ($action == 'enable') { + + $accounting = $accounting->fetch($id); + + if (! empty($accounting->id)) { + $result = $accounting->account_activate($id); + } + $action = 'update'; + if ($result < 0) { + setEventMessage($accounting->error, 'errors'); + } +} + +/* + * View + * + */ +llxHeader('', $langs->trans("ListAccounts")); + +$pcgver = $conf->global->CHARTOFACCOUNTS; + +$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active "; +$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa, " . MAIN_DB_PREFIX . "accounting_system as asy"; +$sql .= " WHERE aa.fk_pcg_version = asy.pcg_version"; +$sql .= " AND asy.rowid = " . $pcgver; + +if (strlen(trim($_GET["search_account"]))) { + $sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'"; +} +if (strlen(trim($_GET["search_label"]))) { + $sql .= " AND aa.label like '%" . $_GET["search_label"] . "%'"; +} +if (strlen(trim($_GET["search_accountparent"]))) { + $sql .= " AND aa.account_parent like '%" . $_GET["search_accountparent"] . "%'"; +} +if (strlen(trim($_GET["search_pcgtype"]))) { + $sql .= " AND aa.pcg_type like '%" . $_GET["search_pcgtype"] . "%'"; +} +if (strlen(trim($_GET["search_pcgsubtype"]))) { + $sql .= " AND aa.pcg_subtype like '%" . $_GET["search_pcgsubtype"] . "%'"; +} + +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog('accountingex/admin/account.php:: $sql=' . $sql); +$result = $db->query($sql); + +if ($result) { + $num = $db->num_rows($result); + + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); + + $i = 0; + + print '
'; + + print '
'; + + print '' . $langs->trans("Addanaccount") . ''; + print '' . $langs->trans("ImportAccount") . ''; + print '

'; + + print ''; + print ''; + print_liste_field_titre($langs->trans("AccountNumber"), "account.php", "aa.account_number", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), "account.php", "aa.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Accountparent"), "account.php", "aa.account_parent", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Pcgtype"), "account.php", "aa.pcg_type", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Pcgsubtype"), "account.php", "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Active"), "account.php", "aa.active", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre(" "); + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = True; + + while ( $i < min($num, $limit) ) { + $obj = $db->fetch_object($resql); + + $var = ! $var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '' . "\n"; + + print "\n"; + $i ++; + } + + print "
 '; + print ''; + print '
' . $obj->account_number . '' . $obj->label . '' . $obj->account_parent . '' . $obj->pcg_type . '' . $obj->pcg_subtype . ''; + if (empty($obj->active)) { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } + print ''; + if ($user->rights->accountingex->admin) { + print ''; + print img_edit(); + print ' '; + print ''; + print img_delete(); + print ''; + } + print '
"; + print '
'; +} else { + dol_print_error($db); +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php new file mode 100644 index 00000000000..a326b7058ad --- /dev/null +++ b/htdocs/accountancy/admin/export.php @@ -0,0 +1,176 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountingex/admin/export.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/admin.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + +$langs->load("compta"); +$langs->load("bills"); +$langs->load('admin'); +$langs->load('accountingex@accountingex'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters ACCOUNTINGEX_* +$list = array ( + 'ACCOUNTINGEX_SEPARATORCSV' +); + +/* + * Actions + */ +if ($action == 'update') { + $error = 0; + + $modelcsv = GETPOST('modelcsv', 'int'); + + if (! empty($modelcsv)) { + + if (! dolibarr_set_const($db, 'ACCOUNTINGEX_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } + + foreach ( $list as $constname ) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + + if (! $error) { + setEventMessage($langs->trans("SetupSaved")); + } else { + setEventMessage($langs->trans("Error"), 'errors'); + } +} + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +print_fiche_titre($langs->trans('ConfigAccountingExpert')); + +$head = admin_account_prepare_head(null); + +dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron'); + +print '
'; +print ''; +print ''; + +print ''; +$var = True; + +print ''; +print ''; +print ''; + +$var = ! $var; + +print ''; +print ""; +print ""; +print "
' . $langs->trans("Modelcsv") . '
" . $langs->trans("Selectmodelcsv") . ""; +print '"; +print "
"; + +print "
\n"; + +/* + * Params + * + */ +$list = array ( + 'ACCOUNTINGEX_SEPARATORCSV' +); + +$num = count($list); +if ($num) { + print ''; + print ''; + print ''; + print "\n"; +} + +foreach ( $list as $key ) { + $var = ! $var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ''; +print "
' . $langs->trans('OtherOptions') . '
' . $label . ''; + print ''; + print '
\n"; + +print '
'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/fiche.php b/htdocs/accountancy/admin/fiche.php new file mode 100644 index 00000000000..76fc955fca2 --- /dev/null +++ b/htdocs/accountancy/admin/fiche.php @@ -0,0 +1,297 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/admin/fiche.php + * \ingroup Accounting Expert + * \brief Page fiche de compte + */ +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/accountingex/class/accountingaccount.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// Langs +$langs->load("bills"); +$langs->load("accountingex@accountingex"); + +$mesg = ''; +$action = GETPOST('action'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); +$accounting = new AccountingAccount($db); + +// action +if ($action == 'add') { + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; + + dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql); + $result = $db->query($sql); + $obj = $db->fetch_object($result); + + $accounting->fk_pcg_version = $obj->pcg_version; + $accounting->pcg_type = GETPOST('pcg_type'); + $accounting->pcg_subtype = GETPOST('pcg_subtype'); + $accounting->account_number = GETPOST('account_number', 'int'); + $accounting->account_parent = GETPOST('account_parent', 'int'); + $accounting->label = GETPOST('label', 'alpha'); + $accounting->active = 1; + + $res = $accounting->create($user); + + if ($res == 0) { + } else { + if ($res == - 3) { + $_error = 1; + $action = "create"; + } + if ($res == - 4) { + $_error = 2; + $action = "create"; + } + } + Header("Location: account.php"); +} elseif ($action == 'edit') { + if (! GETPOST('cancel', 'alpha')) { + $result = $accounting->fetch($id); + + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; + + dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql); + $result2 = $db->query($sql); + $obj = $db->fetch_object($result2); + + $accounting->fk_pcg_version = $obj->pcg_version; + $accounting->pcg_type = GETPOST('pcg_type'); + $accounting->pcg_subtype = GETPOST('pcg_subtype'); + $accounting->account_number = GETPOST('account_number', 'int'); + $accounting->account_parent = GETPOST('account_parent', 'int'); + $accounting->label = GETPOST('label', 'alpha'); + + $result = $accounting->update($user); + + if ($result > 0) { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit(); + } else { + $mesg = $object->error; + } + } else { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit(); + } +} else if ($action == 'delete') { + + $result = $accounting->fetch($id); + + if (! empty($accounting->id)) { + $result = $accounting->delete($user); + + if ($result > 0) { + Header("Location: account.php"); + } + } + + if ($result < 0) { + setEventMessage($accounting->error, 'errors'); + } +} + +/* + * View + * + */ +llxheader('', $langs->trans('AccountAccounting')); + +$form = new Form($db); +$htmlacc = new FormVentilation($db); + +if ($action == 'create') { + print_fiche_titre($langs->trans('NewAccount')); + + print '
' . "\n"; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Label") . '
' . $langs->trans("Accountparent") . ''; + print $htmlacc->select_account($accounting->account_parent, 'account_parent'); + print '
' . $langs->trans("Pcgtype") . ''; + print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type'); + print '
' . $langs->trans("Pcgsubtype") . ''; + print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype'); + print '
'; + + print '
    '; + print ''; +} else if ($id) { + $rowid = $id; + $account = $accounting->fetch($rowid); + + if ($account > 0) { + dol_htmloutput_mesg($mesg); + + $head = account_prepare_head($accounting); + + if ($action == 'update') { + // WYSIWYG Editor + $htmlacc = new FormVentilation($db); + + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + + $soc = new Societe($db); + if ($object->socid) { + $soc->fetch($object->socid); + } + + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); + + print '' . "\n"; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Label") . '
' . $langs->trans("Accountparent") . ''; + print $htmlacc->select_account($accounting->account_parent, 'account_parent'); + print '
' . $langs->trans("Pcgtype") . ''; + print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type'); + print '
' . $langs->trans("Pcgsubtype") . ''; + print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype'); + print '
'; + + print '
  '; + print ''; + print '
'; + + print ''; + + print ''; + } else { + $linkback = '' . $langs->trans("BackToChartofaccounts") . ''; + + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); + + print ''; + + // Account number + print ''; + print ''; + print ''; + + print ''; + print ''; + + $accp = new AccountingAccount($db); + if (! empty($accounting->account_parent)) { + $accp->fetch($accounting->account_parent, ''); + } + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print '
' . $langs->trans("AccountNumber") . '' . $accounting->account_number . '' . $linkback . '
' . $langs->trans("Label") . '' . $accounting->label . '
' . $langs->trans("Accountparent") . '' . $accp->account_number . ' - ' . $accp->label . '
' . $langs->trans("Pcgtype") . '' . $accounting->pcg_type . '
' . $langs->trans("Pcgsubtype") . '' . $accounting->pcg_subtype . '
' . $langs->trans("Active") . ''; + + if (empty($accounting->active)) { + print img_picto($langs->trans("Disabled"), 'switch_off'); + } else { + print img_picto($langs->trans("Activated"), 'switch_on'); + } + + print '
'; + + print ''; + + /* + * Barre d'actions + */ + + print '
'; + + if ($user->rights->accountingex->admin) { + print '' . $langs->trans('Modify') . ''; + } else { + print '' . $langs->trans('Modify') . ''; + } + + if ($user->rights->accountingex->admin) { + print '' . $langs->trans('Delete') . ''; + } else { + print '' . $langs->trans('Delete') . ''; + } + + print '
'; + } + } else { + dol_print_error($db); + } +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php new file mode 100644 index 00000000000..d9d255dad99 --- /dev/null +++ b/htdocs/accountancy/admin/importaccounts.php @@ -0,0 +1,197 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +/** + * \file htdocs/compta/accountingex/liste.php + * \ingroup compta + * \brief Page IMPORT COMPTE COMPTABLE + */ +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/accountingex/class/accountingaccount.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + +llxHeader('', $langs->trans("ImportAccount")); + +$to_import = GETPOST("mesCasesCochees"); + +if ($_POST["action"] == 'import') { + print '
' . $langs->trans("Processing") . '...
'; + if (is_array($to_import) && count($to_import) > 0) { + print '
' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '
'; + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; + + $result = $db->query($sql); + if ($result && ($db->num_rows($result) > 0)) { + + $obj = $db->fetch_object($result); + + $cpt = 0; + foreach ( $to_import as $maLigneCochee ) { + + $accounting = new AccountingAccount($db); + + $monLabel = GETPOST('intitule' . $maLigneCochee); + $monParentAccount = GETPOST('AccountParent' . $maLigneCochee); + $monType = GETPOST('pcgType' . $maLigneCochee); + $monSubType = GETPOST('pcgSubType' . $maLigneCochee); + + $accounting->fk_pcg_version = $obj->pcg_version; + $accounting->account_number = $maLigneCochee; + $accounting->label = $monLabel; + $accounting->account_parent = $monParentAccount; + $accounting->pcg_type = $monType; + $accounting->pcg_subtype = $monSubType; + $accounting->active = 1; + + $result = $accounting->create($user); + if ($result > 0) { + setEventMessage($langs->trans("AccountingAccountAdd"), 'mesgs'); + } else { + setEventMessage($accounting->error, 'errors'); + } + $cpt ++; + } + } else { + setEventMessage($langs->trans('AccountPlanNotFoundCheckSetting'), 'errors'); + } + } else { + print '
' . $langs->trans("AnyLineImport") . '
'; + } + print '
' . $langs->trans("EndProcessing") . '
'; +} + +/* +* list accounting account from product +* +*/ +$page = GETPOST("page"); +if ($page < 0) + $page = 0; +$limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION; +$offset = $limit * $page; + +$sql = "(SELECT p.rowid as product_id, p.accountancy_code_sell as accounting "; +$sql .= " FROM " . MAIN_DB_PREFIX . "product as p "; +$sql .= " WHERE p.accountancy_code_sell >=0"; +$sql .= " GROUP BY accounting "; +$sql .= ")"; +$sql .= "UNION ALL(SELECT p.rowid as product_id, p.accountancy_code_buy as accounting "; +$sql .= " FROM " . MAIN_DB_PREFIX . "product as p "; +$sql .= " WHERE p.accountancy_code_buy >=0"; +$sql .= " GROUP BY accounting "; +$sql .= ") "; +$sql .= " ORDER BY accounting DESC " . $db->plimit($limit + 1, $offset); + +dol_syslog('accountingex/admin/importaccounts.php:: $sql=' . $sql); +$result = $db->query($sql); +if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + print_barre_liste($langs->trans("ImportAccount"), $page, "importaccounts.php", "", $sortfield, $sortorder, '', $num_lignes); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $form = new Form($db); + $htmlacc = new FormVentilation($db); + + print '' . "\n"; + print ''; + + $var = True; + while ( $i < min($num_lignes, $limit) ) { + $objp = $db->fetch_object($result); + $var = ! $var; + print ""; + + print ''; + + print ''; + + // Colonne choix du compte + print ''; + + print ''; + + print ''; + + // Colonne choix ligne a ventiler + + $checked = ('intitule' == 'O') ? ' checked=checked' : ''; + + print ''; + + print ''; + $i ++; + } + + print ''; + + print '
' . $langs->trans("accountingaccount") . '' . $langs->trans("label") . '' . $langs->trans("parentaccount") . '' . $langs->trans("Pcgtype") . '' . $langs->trans("Pcgsubtype") . '' . $langs->trans("Import") . '
'; + print $objp->accounting; + print ''; + print ''; + print ''; + print $htmlacc->select_account($accounting->account_parent, 'AccountParent'); + print ''; + print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcgType'); + print ''; + print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcgSubType'); + print ''; + print ''; + print '
 
'; + print ''; +} else { + print $db->error(); +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/index.html b/htdocs/accountancy/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php new file mode 100644 index 00000000000..d25dffe4c25 --- /dev/null +++ b/htdocs/accountancy/admin/index.php @@ -0,0 +1,301 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file htdocs/accountingex/admin/index.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/admin.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + +$langs->load("compta"); +$langs->load("bills"); +$langs->load('admin'); +$langs->load('accountingex@accountingex'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters COMPTA_* & ACCOUNTINGEX_* +$list = array ( + 'ACCOUNTINGEX_LIMIT_LIST_VENTILATION', + 'ACCOUNTINGEX_LENGTH_GACCOUNT', + 'ACCOUNTINGEX_LENGTH_AACCOUNT', + 'COMPTA_ACCOUNT_CUSTOMER', + 'COMPTA_ACCOUNT_SUPPLIER', + 'COMPTA_PRODUCT_BUY_ACCOUNT', + 'COMPTA_PRODUCT_SOLD_ACCOUNT', + 'COMPTA_SERVICE_BUY_ACCOUNT', + 'COMPTA_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTINGEX_ACCOUNT_SUSPENSE', + 'ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH' +); + +/* + * Actions + */ + +$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES'; + +if ($action == 'update') +{ + $error = 0; + + $compta_modes = array( + 'RECETTES-DEPENSES', + 'CREANCES-DETTES' + ); + + $compta_mode = GETPOST('compta_mode','alpha'); + + if (in_array($compta_mode,$compta_modes)) { + + if (!dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } + + $chartofaccounts = GETPOST('chartofaccounts', 'int'); + + if (! empty($chartofaccounts)) { + + if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +if ($action == 'setlistsorttodo') { + $setlistsorttodo = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + + if (! $error) { + setEventMessage($langs->trans("SetupSaved"), 'mesgs'); + } else { + setEventMessage($langs->trans("Error"), 'mesgs'); + } +} + +if ($action == 'setlistsortdone') { + $setlistsortdone = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + if (! $error) { + setEventMessage($langs->trans("SetupSaved"), 'mesgs'); + } else { + setEventMessage($langs->trans("Error"), 'mesgs'); + } +} + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +print_fiche_titre($langs->trans('ConfigAccountingExpert')); + +$head = admin_account_prepare_head($accounting); + +dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron'); + +print '
'; +print ''; +print ''; + +print ''; + +// Cas du parametre COMPTA_MODE + +print ''; +print ''; +print "\n"; +print ''; +print '\n"; +print ''; +print '\n"; +print ''; + +print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'
'.$langs->trans('OptionModeTrue').''.nl2br($langs->trans('OptionModeTrueDesc')); +// Write info on way to count VAT +//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) +//{ +// // print "
\n"; +// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite')); +//} +//else +//{ +// // print "
\n"; +// // print nl2br($langs->trans('OptionModeTrueInfoExpert')); +//} +print "
'.$langs->trans('OptionModeVirtual').''.nl2br($langs->trans('OptionModeVirtualDesc'))."
\n"; + +print "
\n"; + +/* + * Define Chart of accounts + */ +print ''; +$var = True; + +print ''; +print ''; +print "\n"; +$var = ! $var; +print ''; +print ""; +print ""; +print "
'; +print $langs->trans("Chartofaccounts") . '
" . $langs->trans("Selectchartofaccounts") . ""; +print '"; +print "
"; + +print "
\n"; + +/* + * Others params + */ +print ''; +print ''; +print ''; +print "\n"; + +foreach ($list as $key) +{ + $var=!$var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ""; +print ''; +if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO)) { + print ''; +} else { + print ''; +} +print ''; + +print ""; +print ''; +if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE)) { + print ''; +} else { + print ''; +} +print ''; + +print ''; +print "
' . $langs->trans('OtherOptions') . '
'; + print ''; + print '
' . $langs->trans("ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO") . ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '
' . $langs->trans("ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE") . ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '
\n"; + +print '

'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/journaux.php b/htdocs/accountancy/admin/journaux.php new file mode 100644 index 00000000000..f7b354090e9 --- /dev/null +++ b/htdocs/accountancy/admin/journaux.php @@ -0,0 +1,176 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file htdocs/accountingex/admin/journaux.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/admin.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/core/lib/bank.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load('accountingex@accountingex'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters ACCOUNTINGEX_* +$list = array ( + 'ACCOUNTINGEX_SELL_JOURNAL', + 'ACCOUNTINGEX_PURCHASE_JOURNAL', + 'ACCOUNTINGEX_SOCIAL_JOURNAL', + 'ACCOUNTINGEX_CASH_JOURNAL', + 'ACCOUNTINGEX_MISCELLANEOUS_JOURNAL' +); + +/* + * Actions + */ + +if ($action == 'update') { + $error = 0; + + foreach ( $list as $constname ) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + + if (! $error) { + setEventMessage($langs->trans("SetupSaved")); + } else { + setEventMessage($langs->trans("Error"), 'errors'); + } +} + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +print_fiche_titre($langs->trans('ConfigAccountingExpert')); + +$head = admin_account_prepare_head(null); + +dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron'); + +print '
'; +print ''; +print ''; + +print ''; +print ''; +print ''; +print "\n"; + +foreach ( $list as $key ) { + $var = ! $var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ''; +print "
' . $langs->trans('Journaux') . '
'; + print ''; + print '
\n"; + +print '
'; + +print '
'; + +// Bank account +$sql = "SELECT ba.rowid, ba.ref , ba.label, ba.bank , ba.account_number, ba.code_journal "; +$sql .= " FROM ".MAIN_DB_PREFIX."lx_bank_account as ba"; +$sql .= " WHERE ba.clos = 0" ; +$sql .= " ORDER BY label"; + +dol_syslog('accountingex/admin/journaux.php:: $sql='.$sql); + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + +} + +print ''; +print ''; +print ''; +print "\n"; + +$form2 = new Form($db); + +$account = new Account($db); +foreach ( $resql as $key ) { + $var = ! $var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print '
' . $langs->trans('JournauxTresorerie') . '
'; + print ''; + print '
'; +print ''; + +print '
'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php new file mode 100644 index 00000000000..89bc1996771 --- /dev/null +++ b/htdocs/accountancy/admin/productaccount.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/admin/productaccount.php + * \ingroup Accounting Expert + * \brief Onglet de gestion de parametrages des ventilations + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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"); +dol_include_once("/product/class/product.class.php"); + +$langs->load("companies"); +$langs->load("compta"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + +llxHeader('', $langs->trans("Accounts")); + +$form = new Form($db); + +print ''; + +print ' + '; + +$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell as codesell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy "; +$sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; +$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1"; + +dol_syslog('accountingex/admin/productaccount.php:: $sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + /* +* view +*/ + + print '

'; + + print ''; + print ''; + print ''; + print ''; + print ''; + 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) + $compta_prodsell = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + 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) + $compta_prodbuy = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + 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->id = $objp->rowid; + $product_static->type = $objp->type; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print "\n"; + $i ++; + } + print "
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '
'; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print ' '; + print '' . $obj->ref . '' . $obj->label . '' . $obj->description . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . '' . $obj->accountancy_code_sell . '' . $compta_prodsell . '
"; + $db->free($resql); +} else { + dol_print_error($db); +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/thirdpartyaccount.php b/htdocs/accountancy/admin/thirdpartyaccount.php new file mode 100644 index 00000000000..c9af52fcc51 --- /dev/null +++ b/htdocs/accountancy/admin/thirdpartyaccount.php @@ -0,0 +1,253 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/admin/thirdpartyaccount.php + * \ingroup Accounting Expert + * \brief Onglet de gestion de parametrages des ventilations + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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"); + +$langs->load("companies"); +$langs->load("compta"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->admin) + accessforbidden(); + + // Date range +$year = GETPOST("year"); +if (empty($year)) { + $year_current = strftime("%Y", dol_now()); + $month_current = strftime("%m", dol_now()); + $year_start = $year_current; +} else { + $year_current = $year; + $month_current = strftime("%m", dol_now()); + $year_start = $year; +} +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); + +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q = GETPOST("q") ? GETPOST("q") : 0; + if ($q == 0) { + // We define date_start and date_end + $year_end = $year_start; + $month_start = GETPOST("month") ? GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + if (! GETPOST('month')) { + if (! GETPOST("year") && $month_start > $month_current) { + $year_start --; + $year_end --; + } + $month_end = $month_start - 1; + if ($month_end < 1) + $month_end = 12; + else + $year_end ++; + } else + $month_end = $month_start; + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); + } + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); + } +} else { +} + +llxHeader(); + +$form = new Form($db); + +$nomlink = ''; +$periodlink = ''; +$exportlink = ''; + +$nom = $langs->trans("ReportThirdParty"); +$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); +$description = $langs->trans("DescThirdPartyReport"); +$builddate = time(); + +report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( + 'action' => '' +)); + +print ''; + +print ' + '; + +$sql = "(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta as compta , "; +$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country "; +$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; +$sql .= ", " . MAIN_DB_PREFIX . "facture as f"; +$sql .= ", " . MAIN_DB_PREFIX . "c_country as cp"; +$sql .= " WHERE f.fk_soc = s.rowid"; +$sql .= " AND s.fk_pays = cp.rowid"; +if (! empty($date_start) && ! empty($date_end)) + $sql .= " AND f.datec >= '" . $db->idate($date_start) . "' AND f.datec <= '" . $db->idate($date_end) . "'"; +$sql .= " AND f.entity = " . $conf->entity; +if ($socid) + $sql .= " AND f.fk_soc = " . $socid; +$sql .= " GROUP BY name"; +$sql .= ")"; +$sql .= "UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta_fournisseur as compta , "; +$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , ff.datec , ff.fk_soc , cp.label as country "; +$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; +$sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as ff"; +$sql .= ", " . MAIN_DB_PREFIX . "c_country as cp"; +$sql .= " WHERE ff.fk_soc = s.rowid"; +$sql .= " AND s.fk_pays = cp.rowid"; +if (! empty($date_start) && ! empty($date_end)) + $sql .= " AND ff.datec >= '" . $db->idate($date_start) . "' AND ff.datec <= '" . $db->idate($date_end) . "'"; +$sql .= " AND ff.entity = " . $conf->entity; +if ($socid) + $sql .= " AND f.fk_soc = " . $socid; +$sql .= " GROUP BY name"; +$sql .= ")"; + +$sql .= "ORDER BY name ASC"; + +dol_syslog('accountingex/admin/thirdpartyaccount.php:: $sql=' . $sql); +$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 . '",'; + print '"' . $obj->town . '",'; + print '"' . $obj->country . '",'; + print '"' . $obj->phone . '",'; + print '"' . $obj->fax . '",'; + print "\n"; + $i ++; + } + + /* + * View + */ + + $thirdpartystatic = new Societe($db); + + print '

'; + + print ''; + print "
\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = True; + + while ( $obj = $db->fetch_object($resql) ) { + + $var = ! $var; + + print ""; + print ''; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $i ++; + } + + print "
' . $langs->trans("ThirdParties") . '' . $langs->trans("AccountNumber") . '' . $langs->trans("RaisonSociale") . '' . $langs->trans("Address") . '' . $langs->trans("Zip") . '' . $langs->trans("Town") . '' . $langs->trans("Country") . '' . $langs->trans("Contact") . '' . $langs->trans("Phone") . '' . $langs->trans("Fax") . '
'; + $thirdpartystatic->id = $obj->rowid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->client = $obj->client; + $thirdpartystatic->canvas = $obj->canvas; + $thirdpartystatic->status = $obj->status; + print $thirdpartystatic->getNomUrl(1); + print '' . $obj->compta . '' . $obj->address . '' . $obj->zip . '' . $obj->town . '' . $obj->country . '' . $obj->phone . '' . $obj->fax . '
"; + $db->free($resql); +} else { + dol_print_error($db); +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php new file mode 100644 index 00000000000..5ce55fef7f6 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -0,0 +1,143 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accountingex/bookkeeping/balancebymonth.php + * \ingroup Accounting Expert + * \brief Balance by month + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/date.lib.php"); +dol_include_once("accountingex/core/lib/account.lib.php"); + +// Langs +$langs->load("main"); +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("accountingex@accountingex"); + +// Filter +$year = $_GET["year"]; +if ($year == 0) { + $year_current = strftime("%Y", time()); + $year_start = $year_current; +} else { + $year_current = $year; + $year_start = $year; +} + +/* + * View + */ +llxHeader('', $langs->trans("CustomersVentilation")); + +$textprevyear = "" . img_previous() . ""; +$textnextyear = " " . img_next() . ""; + +print_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear); + +$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " , " . MAIN_DB_PREFIX . "facture as f"; +$sql .= " WHERE fd.fk_code_ventilation = 0"; +$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; + +dol_syslog('accountingex/bookkeeping/balancebymonth.php:: $sql=' . $sql); +$result = $db->query($sql); +if ($result) { + $row = $db->fetch_row($result); + $nbfac = $row[0]; + + $db->free($result); +} + +$y = $year_current; + +$var = true; + +print ''; +print ''; + +$sql = "SELECT bk.numero_compte AS 'compte',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; +$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; +$sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; +$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk"; +$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " GROUP BY bk.numero_compte"; + +$resql = $db->query($sql); +if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ( $i < $num ) { + + $row = $db->fetch_row($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $i ++; + } + $db->free($resql); +} else { + print $db->lasterror(); +} +print "
' . $langs->trans("Intitule") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . 'Total
' . length_accountg($row[0]) . '' . price($row[1]) . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '
\n"; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/fiche.php b/htdocs/accountancy/bookkeeping/fiche.php new file mode 100644 index 00000000000..b558f70e480 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/fiche.php @@ -0,0 +1,385 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/bookkeeping/fiche.php + * \ingroup Accounting Expert + * \brief Page to show account + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +dol_include_once("accountingex/class/bookkeeping.class.php"); + +// Langs +$langs->load("accountingex@accountingex"); + +// Security check +$id = GETPOST('id', 'int'); +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$action = GETPOST('action'); +$piece_num = GETPOST("piece_num"); + +$mesg = ''; + +$numero_compte = GETPOST('numero_compte'); +$code_tiers = GETPOST('code_tiers'); +$label_compte = GETPOST('label_compte'); +$debit = price2num(GETPOST('debit')); +$credit = price2num(GETPOST('credit')); + +if ($action == "confirm_update") { + + $error = 0; + + if ((intval($debit) != 0) && (intval($credit) != 0)) { + setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); + $error ++; + } + + if (empty($error)) { + $book = new BookKeeping($db); + + $result = $book->fetch($id); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + $book->numero_compte = $numero_compte; + $book->code_tiers = $code_tiers; + $book->label_compte = $label_compte; + $book->debit = $debit; + $book->credit = $credit; + + if (! empty($debit)) { + $book->montant = $debit; + $book->sens = 'D'; + } + if (! empty($credit)) { + $book->montant = $credit; + $book->sens = 'C'; + } + + $result = $book->update(); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + setEventMessage($langs->trans('Saved'), 'mesgs'); + $action = ''; + } + } + } +} + +else if ($action == "add") { + + $error = 0; + if ((intval($debit) != 0) && (intval($credit) != 0)) { + setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); + $error ++; + } + + if (empty($error)) { + $book = new BookKeeping($db); + + $book->numero_compte = $numero_compte; + $book->code_tiers = $code_tiers; + $book->label_compte = $label_compte; + $book->debit = $debit; + $book->credit = $credit; + $book->doc_date = GETPOST('doc_date'); + $book->doc_type = GETPOST('doc_type'); + $book->piece_num = $piece_num; + $book->doc_ref = GETPOST('doc_ref'); + $book->code_journal = GETPOST('code_journal'); + $book->fk_doc = GETPOST('fk_doc'); + $book->fk_docdet = GETPOST('fk_docdet'); + + if (! empty($debit)) { + $book->montant = $debit; + $book->sens = 'D'; + } + if (! empty($credit)) { + $book->montant = $credit; + $book->sens = 'C'; + } + + $result = $book->create_std($user); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + setEventMessage($langs->trans('Saved'), 'mesgs'); + $action = ''; + } + } +} + +else if ($action == "confirm_delete") { + $book = new BookKeeping($db); + + $result = $book->fetch($id); + + $piece_num = $book->piece_num; + + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + $result = $book->delete($user); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } + } + $action = ''; +} + +else if ($action == "confirm_create") { + $book = new BookKeeping($db); + + $book->label_compte = ''; + $book->debit = 0; + $book->credit = 0; + $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); + $book->doc_type = GETPOST('doc_type'); + $book->piece_num = GETPOST('next_num_mvt'); + $book->doc_ref = GETPOST('doc_ref'); + $book->code_journal = GETPOST('code_journal'); + $book->fk_doc = 0; + $book->fk_docdet = 0; + + $book->montant = 0; + + $result = $book->create_std($user); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + setEventMessage($langs->trans('Saved'), 'mesgs'); + $action = ''; + $piece_num = $book->piece_num; + } +} + +llxHeader(); + +$html = new Form($db); +$nbligne = 0; + +/* + * Confirmation to delete the command + */ +if ($action == 'delete') { + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); + print $formconfirm; +} + +if ($action == 'create') { + + print_fiche_titre($langs->trans("CreateMvts")); + + $code_journal_array = array ( + $conf->global->ACCOUNTINGEX_SELL_JOURNAL => $conf->global->ACCOUNTINGEX_SELL_JOURNAL, + $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL => $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL, + $conf->global->ACCOUNTINGEX_BANK_JOURNAL => $conf->global->ACCOUNTINGEX_BANK_JOURNAL, + $conf->global->ACCOUNTINGEX_SOCIAL_JOURNAL => $conf->global->ACCOUNTINGEX_SOCIAL_JOURNAL + ); + + $book = new BookKeeping($db); + $next_num_mvt = $book->next_num_mvt(); + + print '
'; + print '' . "\n"; + print '' . "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; + print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; + print '
'; + print ''; + + print '
'; +} else { + $book = new BookKeeping($db); + $result = $book->fetch_per_mvt($piece_num); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } + if (! empty($book->piece_num)) { + + print_fiche_titre($langs->trans("UpdateMvts")); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
' . $langs->trans("Codejournal") . '' . $book->code_journal . '
' . $langs->trans("Docref") . '' . $book->doc_ref . '
' . $langs->trans("Doctype") . '' . $book->doc_type . '
'; + + $result = $book->fetch_all_per_mvt($piece_num); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + + print_fiche_titre($langs->trans("ListeMvts")); + print ""; + if (count($book->linesmvt) > 0) { + + print ''; + + print_liste_field_titre($langs->trans("Numerocompte")); + print_liste_field_titre($langs->trans("Code_tiers")); + print_liste_field_titre($langs->trans("Labelcompte")); + print_liste_field_titre($langs->trans("Debit")); + print_liste_field_titre($langs->trans("Credit")); + print_liste_field_titre($langs->trans("Amount")); + print_liste_field_titre($langs->trans("Sens")); + + print ''; + print "\n"; + + foreach ( $book->linesmvt as $line ) { + $var = ! $var; + print ""; + + if ($action == 'update' && $line->id == $id) { + + print ''; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } + print "\n"; + } + + if ($action == "" || $action == 'add') { + $var = ! $var; + print ""; + + print ''; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } + + print "
' . $line->montant . '' . $line->sens . ''; + if ($user->rights->accountingex->access) { + print ''; + } + print ''; + print '' . $line->numero_compte . '' . $line->code_tiers . '' . $line->label_compte . '' . $line->debit . '' . $line->credit . '' . $line->montant . '' . $line->sens . ''; + if ($user->rights->accoutingex->access) { + print ''; + print img_edit(); + print ' '; + print ''; + print img_delete(); + print ''; + } + print '
"; + } + } + } else { + print_fiche_titre($langs->trans("NoRecords")); + } +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/index.html b/htdocs/accountancy/bookkeeping/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/bookkeeping/liste.php b/htdocs/accountancy/bookkeeping/liste.php new file mode 100644 index 00000000000..f587663e71c --- /dev/null +++ b/htdocs/accountancy/bookkeeping/liste.php @@ -0,0 +1,226 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accountingex/bookkeeping/liste.php + * \ingroup Accounting Expert + * \brief List operation of book keeping + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +dol_include_once("/accountingex/class/html.formventilation.class.php"); +dol_include_once("/accountingex/class/bookkeeping.class.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + +$page = GETPOST("page"); +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); +$action = GETPOST('action', 'alpha'); + +if ($sortorder == "") + $sortorder = "ASC"; +if ($sortfield == "") + $sortfield = "bk.rowid"; + +$offset = $conf->liste_limit * $page; + +$formventilation = new FormVentilation($db); + +/* + * Action + */ +if ($action == 'delbookkeeping') { + + $import_key = GETPOST('importkey', 'alpha'); + + if (! empty($import_key)) { + $object = new BookKeeping($db); + $result = $object->delete_by_importkey($import_key); + Header("Location: liste.php"); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + } + } +} // export csv +else if ($action == 'export_csv') { + + header('Content-Type: text/csv'); + header('Content-Disposition: attachment;filename=export_csv.csv'); + + $object = new BookKeeping($db); + $result = $object->export_bookkeping('ebp'); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + } + + foreach ( $object->linesexport as $line ) { + print $line->id . ','; + print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; + print '"' . $line->code_journal . '",'; + print '"' . $line->numero_compte . '",'; + print '"' . substr($line->code_journal, 0, 2) . '",'; + print '"' . substr($line->doc_ref, 0, 40) . '",'; + print '"' . $line->num_piece . '",'; + print '"' . $line->montant . '",'; + print '"' . $line->sens . '",'; + print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; + print '"' . $conf->currency . '",'; + print "\n"; + } +} + +else { + + llxHeader('', $langs->trans("Accounting") . ' - ' . $langs->trans("Bookkeeping")); + + /* + * List + */ + + $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num "; + $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk"; + + if (dol_strlen(trim(GETPOST("search_doc_type")))) { + + $sql .= " WHERE bk.doc_type LIKE '%" . GETPOST("search_doc_type") . "%'"; + + if (dol_strlen(trim(GETPOST("search_doc_ref")))) { + $sql .= " AND bk.doc_ref LIKE '%" . GETPOST("search_doc_ref") . "%'"; + } + } + if (dol_strlen(trim(GETPOST("search_doc_ref")))) { + $sql .= " WHERE bk.doc_ref LIKE '%" . GETPOST("search_doc_ref") . "%'"; + } + if (dol_strlen(trim(GETPOST("search_compte")))) { + $sql .= " WHERE bk.numero_compte LIKE '%" . GETPOST("search_compte") . "%'"; + } + if (dol_strlen(trim(GETPOST("search_tiers")))) { + $sql .= " WHERE bk.code_tiers LIKE '%" . GETPOST("search_tiers") . "%'"; + } + if (dol_strlen(trim(GETPOST("search_journal")))) { + $sql .= " WHERE bk.code_journal LIKE '%" . GETPOST("search_journal") . "%'"; + } + + $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); + + dol_syslog('accountingex/bookkeeping/liste.php:: $sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + print_barre_liste($langs->trans("Bookkeeping"), $page, "liste.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print ''; + + print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); + + print '
'; + + print ''; + + print 'Nouveau mouvement comptable'; + + print '
'; + print ''; + print ''; + print ''; + print '
'; + + print ""; + print ''; + print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder); + print_liste_field_titre(" "); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = True; + + while ( $i < min($num, $conf->liste_limit) ) { + $obj = $db->fetch_object($resql); + $var = ! $var; + + print ""; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i ++; + } + print "
      '; + print ''; + print '
' . $obj->doc_type . '' . dol_print_date($db->jdate($obj->doc_date), 'day') . '' . $obj->doc_ref . '' . length_accountg($obj->numero_compte) . '' . length_accounta($obj->code_tiers) . '' . $obj->label_compte . '' . price($obj->debit) . '' . price($obj->credit) . '' . price($obj->montant) . '' . $obj->sens . '' . $obj->code_journal . '' . img_edit() . '
"; + $db->free($resql); + } else { + dol_print_error($db); + } +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/listebyyear.php b/htdocs/accountancy/bookkeeping/listebyyear.php new file mode 100644 index 00000000000..2e17e1205ab --- /dev/null +++ b/htdocs/accountancy/bookkeeping/listebyyear.php @@ -0,0 +1,137 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accountingex/bookkeeping/listebyyear.php + * \ingroup Accounting Expert + * \brief Book keeping by year + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/date.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + +// Langs +$langs->load("accountingex@accountingex"); + +$page = GETPOST("page"); +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); + +// Filter +$year = GETPOST("year", 'int'); +if ($year == 0) { + $year_current = strftime("%Y", time()); + $year_start = $year_current; +} else { + $year_current = $year; + $year_start = $year; +} + +if ($sortorder == "") + $sortorder = "ASC"; +if ($sortfield == "") + $sortfield = "bk.rowid"; + +$offset = $conf->liste_limit * $page; + +llxHeader('', $langs->trans("Bookkeeping")); + +$textprevyear = "" . img_previous() . ""; +$textnextyear = " " . img_next() . ""; + +/* + * Mode Liste + * + */ + +$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal"; +$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk"; +// $sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y,1,false))."'"; +// $sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y,12,false))."'"; +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); + +dol_syslog('accountingex/bookkeeping/listebyyear.php:: $sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + print_barre_liste($langs->trans("Bookkeeping") . " $textprevyear " . $langs->trans("Year") . " $year_start $textnextyear", $page, $_SERVER['PHP_SELF'], "", $sortfield, $sortorder, '', $num); + print ""; + + print ''; + print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder); + print_liste_field_titre(" "); + print "\n"; + + $var = True; + + while ( $i < min($num, $conf->liste_limit) ) { + $obj = $db->fetch_object($resql); + $var = ! $var; + + print ""; + + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $i ++; + } + print "
' . $obj->doc_type . '' . dol_print_date($db->jdate($obj->doc_date)) . '' . $obj->doc_ref . '' . length_accountg($obj->numero_compte) . '' . length_accounta($obj->code_tiers) . '' . $obj->label_compte . '' . price($obj->debit) . '' . price($obj->credit) . '' . price($obj->montant) . '' . $obj->sens . '' . $obj->code_journal . '' . img_edit() . '
"; + $db->free($resql); +} else { + dol_print_error($db); +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 4d81a94985b..63b59a95aaf 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -1,5 +1,7 @@ +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Alexandre Spangaro + * 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 @@ -16,20 +18,18 @@ */ /** - * \file htdocs/accountancy/class/accountancysystem.class.php - * \ingroup accounting - * \brief File of class to manage accountancy systems + * \file accountingex/class/accountancysystem.class.php + * \ingroup Accounting Expert + * \brief File of class to manage accountancy systems */ - -/** \class AccountancySystem - * \brief Classe to manage accountancy systems +/** + * \class AccountancySystem + * \brief Classe to manage accountancy systems */ -class AccountancySystem -{ +class AccountancySystem { var $db; var $error; - var $rowid; var $fk_pcg_version; var $pcg_type; @@ -37,58 +37,48 @@ class AccountancySystem var $label; var $account_number; var $account_parent; - - + /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db handler */ - function __construct($db) - { + function __construct($db) { $this->db = $db; } - - + /** - * Insert accountancy system name into database + * Insert accountancy system name into database * - * @param User $user User making insert - * @return int <0 if KO, Id of line if OK + * @param User $user making insert + * @return int if KO, Id of line if OK */ - 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."')"; - + 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) - { + if ($resql) { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); + + if ($id > 0) { $this->id = $id; $result = $this->id; - } - else - { - $result = -2; - $this->error="AccountancySystem::Create Erreur $result"; + } else { + $result = - 2; + $this->error = "AccountancySystem::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } - } - else - { - $result = -1; - $this->error="AccountancySystem::Create Erreur $result"; + } else { + $result = - 1; + $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 new file mode 100644 index 00000000000..9cb29dc1e0b --- /dev/null +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -0,0 +1,416 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/class/Accountingaccount.class.php + * \ingroup Accounting Expert + * \brief Fichier de la classe des comptes comptable + */ + +/** + * \class AccountingAccount + * \brief Classe permettant la gestion des comptes generaux de compta + */ +class AccountingAccount { + var $db; + var $id; + var $rowid; + var $datec; // Creation date + var $fk_pcg_version; + var $pcg_type; + var $pcg_subtype; + var $account_number; + var $account_parent; + var $label; + var $fk_user_author; + var $fk_user_modif; + var $active; + + /** + * \brief Constructeur de la classe + * \param DB handler acces base de donnees + * \param id id compte (0 par defaut) + */ + function __construct($db, $rowid = '') { + $this->db = $db; + + if ($rowid != '') + return $this->fetch($rowid); + } + + /** + * \brief Load record in memory + */ + function fetch($rowid = null, $account_number = null) { + if ($rowid || $account_number) { + $sql = "SELECT * FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE "; + if ($rowid) { + $sql .= " rowid = '" . $rowid . "'"; + } 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) { + $obj = $this->db->fetch_object($result); + } else { + return null; + } + } + + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; + $this->datec = $obj->datec; + $this->tms = $obj->tms; + $this->fk_pcg_version = $obj->fk_pcg_version; + $this->pcg_type = $obj->pcg_type; + $this->pcg_subtype = $obj->pcg_subtype; + $this->account_number = $obj->account_number; + $this->account_parent = $obj->account_parent; + $this->label = $obj->label; + $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 + */ + 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); + if (isset($this->pcg_type)) + $this->pcg_type = trim($this->pcg_type); + if (isset($this->pcg_subtype)) + $this->pcg_subtype = trim($this->pcg_subtype); + if (isset($this->account_number)) + $this->account_number = trim($this->account_number); + if (isset($this->account_parent)) + $this->account_parent = trim($this->account_parent); + if (isset($this->label)) + $this->label = trim($this->label); + if (isset($this->fk_user_author)) + $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"; + $sql .= ", pcg_type"; + $sql .= ", pcg_subtype"; + $sql .= ", account_number"; + $sql .= ", account_parent"; + $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) . "'"); + $sql .= ", " . (! isset($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); + $sql .= ", " . (! isset($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'"); + $sql .= ", " . (! isset($this->account_number) ? 'NULL' : "'" . $this->account_number . "'"); + $sql .= ", " . (! isset($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); + $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); + // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + } + } + + // Commit or rollback + if ($error) { + foreach ( $this->errors as $errmsg ) { + dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return - 1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } + + /** + * Update record + * + * @param User $user update + * @return int if KO, >0 if OK + */ + 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"); + $sql .= " , pcg_subtype = " . ($this->pcg_subtype ? "'" . $this->db->escape($this->pcg_subtype) . "'" : "null"); + $sql .= " , account_number = '" . $this->account_number . "'"; + $sql .= " , account_parent = '" . $this->account_parent . "'"; + $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) { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return - 1; + } + } + + /** + * Check usage of accounting code + * + * @param User $user update + * @return int if KO, >0 if OK + */ + 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) { + $this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse'); + return 0; + } else { + return 1; + } + } else { + $this->error = $this->db->lasterror(); + return - 1; + } + } + + /** + * Delete object in database + * + * @param User $user that deletes + * @param int $notrigger triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + 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); + // $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // 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) { + $error ++; + $this->errors[] = "Error " . $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + foreach ( $this->errors as $errmsg ) { + dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return - 1 * $error; + } else { + $this->db->commit(); + return 1; + } + } else { + return - 1; + } + } + + /** + * Information on record + * + * @param int $id of record + * @return void + */ + function info($id) { + $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); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + if ($obj->fk_user_modif) { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->tms); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Account desactivate + * + * @param User $user update + * @return int if KO, >0 if OK + */ + 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; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return - 1; + } + } else { + return - 1; + } + } + + /** + * Account activate + * + * @param User $user update + * @return int if KO, >0 if OK + */ + 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) { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return - 1; + } + } +} \ No newline at end of file diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php new file mode 100644 index 00000000000..0ea235599b6 --- /dev/null +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -0,0 +1,672 @@ + + * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Alexandre Spangaro + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/class/bookkeeping.class.php + * \ingroup Accounting Expert + * \brief Fichier de la classe des comptes comptable + */ + +/** + * \class BookKeeping + * \brief Classe permettant la gestion des comptes generaux de compta + */ +class BookKeeping { + var $db; + var $id; + var $doc_date; + var $doc_type; + var $doc_ref; + var $date_create; + var $fk_doc; + var $fk_docdet; + var $code_tiers; + var $numero_compte; + var $label_compte; + var $debit; + var $credit; + var $montant; + var $sens; + var $fk_user_author; + var $code_journal; + var $piece_num; + var $linesexport = array (); + var $linesmvt = array (); + + /** + * \brief Constructeur de la classe + * \param DB handler acces base de donnees + * \param id id compte (0 par defaut) + */ + function BookKeeping($db) { + $this->db = $db; + } + + /** + * \brief Load record in memory + */ + function fetch_per_mvt($piecenum) { + $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type FROM " . MAIN_DB_PREFIX . "bookkeeping WHERE "; + $sql .= " 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); + $this->doc_ref = $obj->doc_ref; + $this->doc_type = $obj->doc_type; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); + return - 1; + } + + return 1; + } + + /** + * \brief Load record in memory + */ + function fetch($id) { + $sql = "SELECT rowid, doc_date, doc_type, "; + $sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, "; + $sql .= "numero_compte, label_compte, debit, credit, "; + $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; + $sql .= " FROM " . MAIN_DB_PREFIX . "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; + $this->fk_doc = $obj->fk_doc; + $this->fk_docdet = $obj->fk_docdet; + $this->code_tiers = $obj->code_tiers; + $this->numero_compte = $obj->numero_compte; + $this->label_compte = $obj->label_compte; + $this->debit = $obj->debit; + $this->credit = $obj->credit; + $this->montant = $obj->montant; + $this->sens = $obj->sens; + $this->code_journal = $obj->code_journal; + $this->piece_num = $obj->piece_num; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); + return - 1; + } + + return 1; + } + + /** + * \brief Return next num mvt + */ + function next_num_mvt() { + $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "bookkeeping"; + + dol_syslog(get_class($this) . "next_num_mvt sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + + return $obj->max; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); + return - 1; + } + } + + /** + * \brief Load record in memory + */ + function fetch_all_per_mvt($piecenum) { + $sql = "SELECT rowid, doc_date, doc_type, "; + $sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, "; + $sql .= "numero_compte, label_compte, debit, credit, "; + $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; + $sql .= " FROM " . MAIN_DB_PREFIX . "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; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->code_tiers = $obj->code_tiers; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->montant; + $line->sens = $obj->sens; + $line->code_journal = $obj->code_journal; + $line->piece_num = $obj->piece_num; + + $this->linesmvt[] = $line; + } + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); + return - 1; + } + + return 1; + } + + /** + * \brief Insere une ligne dans bookkeeping + * \param user utilisateur qui effectue l'insertion + */ + function create() { + global $conf, $user, $langs; + + $this->piece_num = 0; + + // first check if line not yet in bookkeeping + $sql = "SELECT count(*)"; + $sql .= " FROM " . MAIN_DB_PREFIX . "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 . "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) { + $objnum = $this->db->fetch_object($resqlnum); + $this->piece_num = $objnum->piece_num; + } + dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); + if (empty($this->piece_num)) { + $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; + $sqlnum .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); + $resqlnum = $this->db->query($sqlnum); + if ($resqlnum) { + $objnum = $this->db->fetch_object($resqlnum); + $this->piece_num = $objnum->maxpiecenum; + } + } + dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); + 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 . "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)"; + $sql .= " VALUES ('" . $this->doc_date . "','" . $this->doc_type . "','" . $this->doc_ref . "'," . $this->fk_doc . ","; + $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 . "bookkeeping"); + + if ($id > 0) { + $this->id = $id; + $result = 0; + } else { + $result = - 2; + dol_syslog("BookKeeping::Create Erreur $result lecture ID"); + } + } else { + $result = - 1; + dol_syslog("BookKeeping::Create Erreur $result INSERT Mysql"); + } + } else { + $result = - 3; + dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); + } + } else { + $result = - 5; + dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); + } + + return $result; + } + + /** + * \brief Delete bookkepping by importkey + */ + function delete_by_importkey($importkey) { + $this->db->begin(); + + // first check if line not yet in bookkeeping + $sql = "DELETE"; + $sql .= " FROM " . MAIN_DB_PREFIX . "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 ) { + dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return - 1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + /** + * Create object into database + * + * @param User $user that creates + * @param int $notrigger triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create_std($user, $notrigger = 0) { + global $conf, $langs; + $error = 0; + + // Clean parameters + + if (isset($this->doc_type)) + $this->doc_type = trim($this->doc_type); + if (isset($this->doc_ref)) + $this->doc_ref = trim($this->doc_ref); + if (isset($this->fk_doc)) + $this->fk_doc = trim($this->fk_doc); + if (isset($this->fk_docdet)) + $this->fk_docdet = trim($this->fk_docdet); + if (isset($this->code_tiers)) + $this->code_tiers = trim($this->code_tiers); + if (isset($this->numero_compte)) + $this->numero_compte = trim($this->numero_compte); + if (isset($this->label_compte)) + $this->label_compte = trim($this->label_compte); + if (isset($this->debit)) + $this->debit = trim($this->debit); + if (isset($this->credit)) + $this->credit = trim($this->credit); + if (isset($this->montant)) + $this->montant = trim($this->montant); + if (isset($this->sens)) + $this->sens = trim($this->sens); + if (isset($this->fk_user_author)) + $this->fk_user_author = trim($this->fk_user_author); + if (isset($this->import_key)) + $this->import_key = trim($this->import_key); + if (isset($this->code_journal)) + $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 . "bookkeeping("; + + $sql .= "doc_date,"; + $sql .= "doc_type,"; + $sql .= "doc_ref,"; + $sql .= "fk_doc,"; + $sql .= "fk_docdet,"; + $sql .= "code_tiers,"; + $sql .= "numero_compte,"; + $sql .= "label_compte,"; + $sql .= "debit,"; + $sql .= "credit,"; + $sql .= "montant,"; + $sql .= "sens,"; + $sql .= "fk_user_author,"; + $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) . "'") . ","; + $sql .= " " . (! isset($this->fk_doc) ? 'NULL' : "'" . $this->fk_doc . "'") . ","; + $sql .= " " . (! isset($this->fk_docdet) ? 'NULL' : "'" . $this->fk_docdet . "'") . ","; + $sql .= " " . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ","; + $sql .= " " . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ","; + $sql .= " " . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ","; + $sql .= " " . (! isset($this->debit) ? 'NULL' : "'" . $this->debit . "'") . ","; + $sql .= " " . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ","; + $sql .= " " . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ","; + $sql .= " " . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ","; + $sql .= " " . $user->id . ","; + $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 . "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); + // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + } + } + + // Commit or rollback + if ($error) { + foreach ( $this->errors as $errmsg ) { + dol_syslog(get_class($this) . "::create_std " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return - 1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } + + /** + * Update object into database + * + * @param User $user that modifies + * @param int $notrigger triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user = 0, $notrigger = 0) { + global $conf, $langs; + $error = 0; + + // Clean parameters + + if (isset($this->doc_type)) + $this->doc_type = trim($this->doc_type); + if (isset($this->doc_ref)) + $this->doc_ref = trim($this->doc_ref); + if (isset($this->fk_doc)) + $this->fk_doc = trim($this->fk_doc); + if (isset($this->fk_docdet)) + $this->fk_docdet = trim($this->fk_docdet); + if (isset($this->code_tiers)) + $this->code_tiers = trim($this->code_tiers); + if (isset($this->numero_compte)) + $this->numero_compte = trim($this->numero_compte); + if (isset($this->label_compte)) + $this->label_compte = trim($this->label_compte); + if (isset($this->debit)) + $this->debit = trim($this->debit); + if (isset($this->credit)) + $this->credit = trim($this->credit); + if (isset($this->montant)) + $this->montant = trim($this->montant); + if (isset($this->sens)) + $this->sens = trim($this->sens); + if (isset($this->fk_user_author)) + $this->fk_user_author = trim($this->fk_user_author); + if (isset($this->import_key)) + $this->import_key = trim($this->import_key); + if (isset($this->code_journal)) + $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 . "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") . ","; + $sql .= " fk_doc=" . (isset($this->fk_doc) ? $this->fk_doc : "null") . ","; + $sql .= " fk_docdet=" . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ","; + $sql .= " code_tiers=" . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ","; + $sql .= " numero_compte=" . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ","; + $sql .= " label_compte=" . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ","; + $sql .= " debit=" . (isset($this->debit) ? $this->debit : "null") . ","; + $sql .= " credit=" . (isset($this->credit) ? $this->credit : "null") . ","; + $sql .= " montant=" . (isset($this->montant) ? $this->montant : "null") . ","; + $sql .= " sens=" . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ","; + $sql .= " fk_user_author=" . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ","; + $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); + // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + } + } + + // Commit or rollback + if ($error) { + foreach ( $this->errors as $errmsg ) { + dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return - 1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user that deletes + * @param int $notrigger triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger = 0) { + global $conf, $langs; + $error = 0; + + $this->db->begin(); + + if (! $error) { + if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + // // Call triggers + // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + // $interface=new Interfaces($this->db); + // $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + } + } + + if (! $error) { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "bookkeeping"; + $sql .= " WHERE rowid=" . $this->id; + + dol_syslog(get_class($this) . "::delete sql=" . $sql); + $resql = $this->db->query($sql); + if (! $resql) { + $error ++; + $this->errors[] = "Error " . $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + foreach ( $this->errors as $errmsg ) { + dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return - 1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + /** + * \brief Delete bookkepping by importkey + */ + function export_bookkeping($model = 'ebp') { + $sql = "SELECT rowid, doc_date, doc_type, "; + $sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, "; + $sql .= "numero_compte, label_compte, debit, credit, "; + $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; + $sql .= " FROM " . MAIN_DB_PREFIX . "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; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->code_tiers = $obj->code_tiers; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->montant; + $line->sens = $obj->sens; + $line->code_journal = $obj->code_journal; + $line->piece_num = $obj->piece_num; + + $this->linesexport[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::export_bookkeping " . $this->error, LOG_ERR); + return - 1; + } + } +} +class BookKeepingLine { + var $id; + var $doc_date; + var $doc_type; + var $doc_ref; + var $fk_doc; + var $fk_docdet; + var $code_tiers; + var $numero_compte; + var $label_compte; + var $debit; + var $credit; + var $montant; + var $sens; + var $fk_user_author; + var $code_journal; + var $piece_num; +} \ No newline at end of file diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php new file mode 100644 index 00000000000..16aeb01dd02 --- /dev/null +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -0,0 +1,246 @@ + + * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/class/html.formventilation.class.php + * \brief Class for HML form + */ +class FormVentilation extends Form { + var $db; + var $error; + + /** + * Constructor + * + * @param DoliDB $db handler + */ + function __construct($db) { + $this->db = $db; + return 1; + } + + /** + * Return select filter with date of transaction + * + * @param string $htmlname of input + * @param string $selectedkey value + * @return string select input + */ + function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey) { + global $langs; + + $date_array = array (); + + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'bookkeeping '; + $sql .= ' ORDER BY import_key DESC'; + + $out = ''; + + return $out; + } + + /** + * Return list of the accounts with label + * + * @param string $selectedid pcg_type + * @param string $htmlname of combo list + * @param int $showempty en empty line + * + * @return 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 .= ''; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); + return - 1; + } + $this->db->free($resql); + return $out; + } + + /** + * Return list of pcg with label + * + * @param string $selectedid pcg_type + * @param string $htmlname of combo list + * @param int $showempty en empty line + * + * @return string with HTML select + */ + function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) { + global $conf, $user, $langs; + + $out = ''; + + $sql = "SELECT DISTINCT pcg_type "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount "; + $sql .= " ORDER BY pcg_type"; + + dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + + $out .= ajax_combobox($htmlname, $event); + + $out .= ''; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::select_pcgtype " . $this->error, LOG_ERR); + return - 1; + } + $this->db->free($resql); + return $out; + } + + /** + * Return subtype list of pcg with label + * + * @param string $selectedid pcg_type + * @param string $htmlname of combo list + * @param int $showempty en empty line + * + * @return 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 .= ''; + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); + return - 1; + } + $this->db->free($resql); + return $out; + } +} diff --git a/htdocs/accountancy/customer/fiche.php b/htdocs/accountancy/customer/fiche.php new file mode 100644 index 00000000000..4cb05ccb019 --- /dev/null +++ b/htdocs/accountancy/customer/fiche.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/customer/fiche.php + * \ingroup Accounting Expert + * \brief Page fiche ventilation + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +dol_include_once("/compta/facture/class/facture.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// Langs +$langs->load("bills"); +$langs->load("accountingex@accountingex"); + +$action = GETPOST('action', 'alpha'); +$codeventil = GETPOST('codeventil'); +$id = GETPOST('id'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + + /* + * Actions + */ + +if ($action == 'ventil' && $user->rights->accountingex->access) { + $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sql .= " SET fk_code_ventilation = " . $codeventil; + $sql .= " WHERE rowid = " . $id; + + dol_syslog("/accountingex/customer/fiche.php sql=" . $sql, LOG_DEBUG); + $resql = $db->query($sql); + if (! $resql) { + setEventMessage($db->lasterror(), 'errors'); + } +} + +llxHeader("", "", "FicheVentilation"); + +if ($cancel == $langs->trans("Cancel")) { + $action = ''; +} + +/* + * Create + */ +$form = new Form($db); +$facture_static = new Facture($db); +$formventilation = new FormVentilation($db); + +if (! empty($id)) { + $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,"; + $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,"; + $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; + $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; + + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; + } + + dol_syslog("/accountingex/customer/fiche.php sql=" . $sql, LOG_DEBUG); + $result = $db->query($sql); + + if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + + if ($num_lignes) { + + $objp = $db->fetch_object($result); + + print '
' . "\n"; + print ''; + print ''; + + print_fiche_titre($langs->trans("Ventilation")); + + print ''; + + // Ref facture + print ''; + $facture_static->ref = $objp->facnumber; + $facture_static->id = $objp->facid; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("Invoice") . '' . $facture_static->getNomUrl(1) . '
' . $langs->trans("Line") . '' . nl2br($objp->description) . '
' . $langs->trans("Account") . ''; + print $objp->account_number . '-' . $objp->label; + print '
' . $langs->trans("NewAccount") . ''; + print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); + print '
 
'; + print '
'; + } else { + print "Error"; + } + } else { + print "Error"; + } +} else { + print "Error ID incorrect"; +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/customer/index.html b/htdocs/accountancy/customer/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php new file mode 100644 index 00000000000..55287abef4d --- /dev/null +++ b/htdocs/accountancy/customer/index.php @@ -0,0 +1,353 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accountingex/customer/index.php + * \ingroup Accounting Expert + * \brief Page accueil clients ventilation comptable + */ +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/date.lib.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +// Filter +$year = $_GET["year"]; +if ($year == 0) { + $year_current = strftime("%Y", time()); + $year_start = $year_current; +} else { + $year_current = $year; + $year_start = $year; +} + +// Validate History +$action = GETPOST('action'); +if ($action == 'validatehistory') { + + $error = 0; + $db->begin(); + + if ($db->type == 'pgsql') { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; + $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; + $sql1 .= " AND fd.fk_code_ventilation = 0"; + } else { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; + $sql1 .= " AND fd.fk_code_ventilation = 0"; + } + + dol_syslog("/accountingex/customer/index.php sql=" . $sql, LOG_DEBUG); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Dispatched'), 'mesgs'); + } +} + +/* + * View + */ +llxHeader('', $langs->trans("CustomersVentilation")); + +$textprevyear = "" . img_previous() . ""; +$textnextyear = " " . img_next() . ""; + +print_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); + +print '' . $langs->trans("DescVentilCustomer") . ''; +print ''; + +$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " , " . MAIN_DB_PREFIX . "facture as f"; +$sql .= " WHERE fd.fk_code_ventilation = 0"; +$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; + +dol_syslog("/accountingex/customer/index.php sql=" . $sql, LOG_DEBUG); +$result = $db->query($sql); +if ($result) { + $row = $db->fetch_row($result); + $nbfac = $row[0]; + $db->free($result); +} + +$y = $year_current; + +$var = true; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$sql = "SELECT IF(aa.account_number IS NULL, 'Non pointe', aa.account_number) AS 'code comptable',"; +$sql .= " IF(aa.label IS NULL, 'Non pointe', aa.label) AS 'Intitulé',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,fd.total_ht,0)),2) AS 'Janvier',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,fd.total_ht,0)),2) AS 'Fevrier',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,fd.total_ht,0)),2) AS 'Mars',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,fd.total_ht,0)),2) AS 'Avril',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,fd.total_ht,0)),2) AS 'Mai',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,fd.total_ht,0)),2) AS 'Juin',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,fd.total_ht,0)),2) AS 'Juillet',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,fd.total_ht,0)),2) AS 'Aout',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,fd.total_ht,0)),2) AS 'Septembre',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,fd.total_ht,0)),2) AS 'Octobre',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,fd.total_ht,0)),2) AS 'Novembre',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,fd.total_ht,0)),2) AS 'Decembre',"; +$sql .= " ROUND(SUM(fd.total_ht),2) as 'Total'"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; +} + +$sql .= " GROUP BY fd.fk_code_ventilation"; + +dol_syslog("/accountingex/customer/index.php sql=" . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ( $i < $num ) { + $row = $db->fetch_row($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i ++; + } + $db->free($resql); +} else { + print $db->lasterror(); // affiche la derniere erreur sql +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Intitule") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . '' . $langs->trans("Total") . '
' . $row[0] . '' . $row[1] . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + +print "
\n"; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Total',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,fd.total_ht,0)),2) AS 'Janvier',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,fd.total_ht,0)),2) AS 'Fevrier',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,fd.total_ht,0)),2) AS 'Mars',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,fd.total_ht,0)),2) AS 'Avril',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,fd.total_ht,0)),2) AS 'Mai',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,fd.total_ht,0)),2) AS 'Juin',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,fd.total_ht,0)),2) AS 'Juillet',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,fd.total_ht,0)),2) AS 'Aout',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,fd.total_ht,0)),2) AS 'Septembre',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,fd.total_ht,0)),2) AS 'Octobre',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,fd.total_ht,0)),2) AS 'Novembre',"; +$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,fd.total_ht,0)),2) AS 'Decembre',"; +$sql .= " ROUND(SUM(fd.total_ht),2) as 'Total'"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; +} + +dol_syslog('accountingext/customer/index.php:: $sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ( $i < $num ) { + $row = $db->fetch_row($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i ++; + } + $db->free($resql); +} else { + print $db->lasterror(); // affiche la derniere erreur sql +} +print "
' . $langs->trans("TotalVente") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[1]) . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '
\n"; + +if (! empty($conf->margin->enabled)) { + print "
\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Marge',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Janvier',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Fevrier',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Mars',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Avril',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Mai',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Juin',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Juillet',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Aout',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Septembre',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Octobre',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Novembre',"; + $sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Decembre',"; + $sql .= " ROUND(SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))),2) as 'Total'"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; + } + + dol_syslog('accountingext/customer/index.php:: $sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ( $i < $num ) { + $row = $db->fetch_row($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i ++; + } + $db->free($resql); + } else { + print $db->lasterror(); // affiche la derniere erreur sql + } + print "
' . $langs->trans("TotalMarge") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[1]) . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '
\n"; +} +print "\n"; +print ''; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/customer/lignes.php b/htdocs/accountancy/customer/lignes.php new file mode 100644 index 00000000000..c0929f1fed5 --- /dev/null +++ b/htdocs/accountancy/customer/lignes.php @@ -0,0 +1,232 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accountingex/customer/lignes.php + * \ingroup Accounting Expert + * \brief Page of detail of the lines of ventilation of invoices customers + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + +// Class +dol_include_once("/accountingex/class/html.formventilation.class.php"); +dol_include_once("/compta/facture/class/facture.class.php"); +dol_include_once("/product/class/product.class.php"); + +// langs +$langs->load("bills"); +$langs->load("compta"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +$account_parent = GETPOST('account_parent'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$formventilation = new FormVentilation($db); + +// change account + +$changeaccount = GETPOST('changeaccount'); + +$is_search = GETPOST('button_search_x'); + +if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) { + $error = 0; + + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; + $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountingex/customer/lignes.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessage($db->lasterror(), 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessage($langs->trans('Save'), 'mesgs'); + } else { + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } +} + +/* + * View + */ + +llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); + +$page = GETPOST("page"); +if ($page < 0) + $page = 0; + +if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) { + $limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION; +} elseif ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) { + $limit = $conf->liste_limit; +} else { + $limit = $conf->liste_limit; +} + +$offset = $limit * $page; + +$sql = "SELECT l.rowid , f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.qty, l.tva_tx, l.fk_code_ventilation, aa.label, aa.account_number,"; +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; +$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa"; +$sql .= " , " . MAIN_DB_PREFIX . "facturedet as l"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; +$sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 "; +$sql .= " AND aa.rowid = l.fk_code_ventilation"; +if (strlen(trim(GETPOST("search_facture")))) { + $sql .= " AND f.facnumber like '%" . GETPOST("search_facture") . "%'"; +} +if (strlen(trim(GETPOST("search_ref")))) { + $sql .= " AND p.ref like '%" . GETPOST("search_ref") . "%'"; +} +if (strlen(trim(GETPOST("search_label")))) { + $sql .= " AND p.label like '%" . GETPOST("search_label") . "%'"; +} +if (strlen(trim(GETPOST("search_desc")))) { + $sql .= " AND l.description like '%" . GETPOST("search_desc") . "%'"; +} +if (strlen(trim(GETPOST("search_account")))) { + $sql .= " AND aa.account_number like '%" . GETPOST("search_account") . "%'"; +} + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; +} + +$sql .= " ORDER BY l.rowid"; +if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE > 0) { + $sql .= " DESC "; +} +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog("/accountingex/customer/linges.php sql=" . $sql, LOG_DEBUG); +$result = $db->query($sql); +if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + + // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... + print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lignes); + + print '' . $langs->trans("DescVentilDoneCustomer") . ''; + + print '
'; + print ''; + + print '

' . $langs->trans("ChangeAccount"); + print $formventilation->select_account($account_parent, 'account_parent', 1); + print '
'; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $facture_static = new Facture($db); + $product_static = new Product($db); + + $var = True; + while ( $objp = $db->fetch_object($result) ) { + $var = ! $var; + $codeCompta = $objp->account_number . ' ' . $objp->label; + + print ""; + + // Ref facture + $facture_static->ref = $objp->facnumber; + $facture_static->id = $objp->facid; + print ''; + + // Ref produit + $product_static->ref = $objp->product_ref; + $product_static->id = $objp->product_id; + $product_static->type = $objp->type; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ""; + $i ++; + } +} else { + print $db->error(); +} + +print "
' . $langs->trans("Invoice") . '' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Amount") . '' . $langs->trans("Account") . '  
  '; + print ''; + print ' 
' . $facture_static->getNomUrl(1) . ''; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print ' '; + print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . $codeCompta . '' . $objp->rowid . ''; + print img_edit(); + print '
"; + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/accountancy/customer/liste.php b/htdocs/accountancy/customer/liste.php new file mode 100644 index 00000000000..f0363918b0a --- /dev/null +++ b/htdocs/accountancy/customer/liste.php @@ -0,0 +1,246 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/customer/liste.php + * \ingroup Accounting Expert + * \brief Page de ventilation des lignes de facture clients + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +dol_include_once("/compta/facture/class/facture.class.php"); +dol_include_once("/product/class/product.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +$action = GETPOST('action'); +$codeventil = GETPOST('codeventil', 'array'); +$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$formventilation = new FormVentilation($db); + +llxHeader('', $langs->trans("Ventilation")); + +/* + * Action +*/ + +if ($action == 'ventil') { + print '
' . $langs->trans("Processing") . '...
'; + if (! empty($codeventil) && ! empty($mesCasesCochees)) { + print '
' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '
'; + $mesCodesVentilChoisis = $codeventil; + $cpt = 0; + foreach ( $mesCasesCochees as $maLigneCochee ) { + // print '
id selectionnee : '.$monChoix."
"; + $maLigneCourante = split("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monNumLigne = $maLigneCourante[1]; + $monCompte = $mesCodesVentilChoisis[$monNumLigne]; + + $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sql .= " SET fk_code_ventilation = " . $monCompte; + $sql .= " WHERE rowid = " . $monId; + + dol_syslog("/accountingex/customer/liste.php sql=" . $sql, LOG_DEBUG); + if ($db->query($sql)) { + print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + } else { + print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '
' . $sql . '
'; + } + + $cpt ++; + } + } else { + print '
' . $langs->trans("AnyLineVentilate") . '
'; + } + print '
' . $langs->trans("EndProcessing") . '
'; +} + +/* + * Customer Invoice lines + */ +$page = GETPOST('page'); +if ($page < 0) + $page = 0; + +if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) { + $limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION; +} else if ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) { + $limit = $conf->liste_limit; +} else { + $limit = $conf->liste_limit; +} + +$offset = $limit * $page; + +$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation,"; +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell"; +$sql .= " , aa.rowid as aarowid"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_sell = aa.account_number"; +$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0"; + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; +} + +$sql .= " ORDER BY l.rowid"; +if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO > 0) { + $sql .= " DESC "; +} +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog("/accountingex/customer/liste.php sql=" . $sql, LOG_DEBUG); +$result = $db->query($sql); +if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + + // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... + print_barre_liste($langs->trans("InvoiceLines"), $page, "liste.php", "", $sortfield, $sortorder, '', $num_lignes); + + print '
' . $langs->trans("DescVentilTodoCustomer") . '
'; + + print '
' . "\n"; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $facture_static = new Facture($db); + $product_static = new Product($db); + $form = new Form($db); + + $var = True; + while ( $i < min($num_lignes, $limit) ) { + $objp = $db->fetch_object($result); + $var = ! $var; + + // product_type: 0 = service ? 1 = product + // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service + // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! + $code_sell_notset = ''; + + if (empty($objp->code_sell)) { + $code_sell_notset = 'color:red'; + + if (! empty($objp->type)) { + if ($objp->type == 1) { + $objp->code_sell = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } else { + $objp->code_sell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } + } else { + $code_sell_notset = 'color:blue'; + + if ($objp->type == 1) { + $objp->code_sell = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } else { + $objp->code_sell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + } + } + } + + print ""; + + // Ref facture + $facture_static->ref = $objp->facnumber; + $facture_static->id = $objp->facid; + print ''; + + // Ref produit + $product_static->ref = $objp->product_ref; + $product_static->id = $objp->product_id; + $product_static->type = $objp->type; + print ''; + + print ''; + print ''; + + print ''; + + print ''; + + // Colonne choix du compte + print ''; + + // Colonne choix ligne a ventiler + print ''; + + print ''; + $i ++; + } + + print ''; + + print '
' . $langs->trans("Invoice") . '' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Amount") . '' . $langs->trans("AccountAccounting") . '' . $langs->trans("IntoAccount") . '' . $langs->trans("Ventilate") . '
' . $facture_static->getNomUrl(1) . ''; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print ' '; + print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . ''; + print price($objp->total_ht); + print ''; + print $objp->code_sell; + print ''; + print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1); + print ''; + print 'code_sell ? "checked" : "") . '/>'; + print '
 
'; + print '
'; +} else { + print $db->error(); +} + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php new file mode 100644 index 00000000000..493aa24b5ea --- /dev/null +++ b/htdocs/accountancy/journal/bankjournal.php @@ -0,0 +1,568 @@ + + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Olivier Geffroy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/journal/bankjournal.php + * \ingroup Accounting Expert + * \brief Page with sells journal + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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"); +dol_include_once("/core/lib/bank.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/societe/class/societe.class.php"); +dol_include_once("/adherents/class/adherent.class.php"); +dol_include_once("/compta/sociales/class/chargesociales.class.php"); +dol_include_once("/compta/paiement/class/paiement.class.php"); +dol_include_once("/compta/tva/class/tva.class.php"); +dol_include_once("/fourn/class/paiementfourn.class.php"); +dol_include_once("/fourn/class/fournisseur.facture.class.php"); +dol_include_once("/fourn/class/fournisseur.class.php"); +dol_include_once("/accountingex/class/bookkeeping.class.php"); +dol_include_once("/societe/class/client.class.php"); + +// Langs +$langs->load("companies"); +$langs->load("other"); +$langs->load("compta"); +$langs->load("bank"); +$langs->load('bills'); +$langs->load("accountingex@accountingex"); + +$date_startmonth = GETPOST('date_startmonth'); +$date_startday = GETPOST('date_startday'); +$date_startyear = GETPOST('date_startyear'); +$date_endmonth = GETPOST('date_endmonth'); +$date_endday = GETPOST('date_endday'); +$date_endyear = GETPOST('date_endyear'); +$action = GETPOST('action'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +/* + * View + */ + +$year_current = strftime("%Y", dol_now()); +$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonthyear = $year_current; +if ($pastmonth == 0) { + $pastmonth = 12; + $pastmonthyear --; +} + +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); + +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); +} + +$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); +$idpays = $p[0]; + +$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,"; +$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop"; +$sql .= " FROM " . MAIN_DB_PREFIX . "bank b"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account ba on b.fk_account=ba.rowid"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe soc on bu1.url_id=soc.rowid"; +// To isolate the cash of the other accounts +$sql .= " WHERE ba.courant <> 2"; +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND ba.entity = " . $conf->entity; +} +if ($date_start && $date_end) + $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; +$sql .= " ORDER BY b.datev"; + +$object = new Account($db); +$paymentstatic = new Paiement($db); +$paymentsupplierstatic = new PaiementFourn($db); +$societestatic = new Societe($db); +$chargestatic = new ChargeSociales($db); +$paymentvatstatic = new TVA($db); + +dol_syslog("accountingex/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG); +$result = $db->query($sql); +if ($result) { + + $num = $db->num_rows($result); + // 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->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); + $cptsociale = (! empty($conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); + + $tabpay = array (); + $tabbq = array (); + $tabtp = array (); + $tabcompany[$obj->rowid] = array ( + 'id' => $obj->socid, + 'name' => $obj->name, + 'code_client' => $obj->code_compta + ); + $tabtype = array (); + + $i = 0; + while ( $i < $num ) { + $obj = $db->fetch_object($result); + + // Controls + $compta_bank = $obj->account_number; + if ($obj->label == '(SupplierInvoicePayment)') + $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour); + if ($obj->label == '(CustomerInvoicePayment)') + $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); + if ($obj->typeop == '(BankTransfert)') + $compta_soc = $conf->global->ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH; + + // Variable bookkeeping + $tabpay[$obj->rowid]["date"] = $obj->do; + $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; + $tabpay[$obj->rowid]["ref"] = $obj->label; + $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; + if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { + $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); + } else { + $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); + } else if ($links[$key]['type'] == 'payment_supplier') { + $paymentsupplierstatic->id = $links[$key]['url_id']; + $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') + $reg[1] = 'SocialContribution'; + $chargestatic->lib = $langs->trans($reg[1]); + } else { + $chargestatic->lib = $links[$key]['label']; + } + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; + + dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $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); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } else if ($links[$key]['type'] == 'banktransfert') { + + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } + /*else { + $tabtp [$obj->rowid] [$cptsociale] += $obj->amount; + }*/ + } + $tabbq[$obj->rowid][$compta_bank] += $obj->amount; + + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; + + $i ++; + } +} else { + dol_print_error($db); +} + +/* + * Actions +*/ + +// Write bookkeeping +if ($action == 'writeBookKeeping') { + $error = 0; + foreach ( $tabpay as $key => $val ) { + // Bank + foreach ( $tabbq[$key] as $k => $mt ) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $compte->intitule; + $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0); + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_BANK_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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sqlmid .= " WHERE payf.fk_bank=" . $key; + dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + } + + $result = $bookkeeping->create(); + if ($result < 0) { + $error ++; + setEventMessage($object->errors, 'errors'); + } + } + // Third party + foreach ( $tabtp[$key] as $k => $mt ) { + + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->doc_type = 'banque'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_BANK_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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sqlmid .= " WHERE payf.fk_bank=" . $key; + dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $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 ++; + setEventMessage($object->errors, 'errors'); + } + } + } + + if (empty($error)) { + setEventMessage($langs->trans('Success'), 'mesgs'); + } +} +// export csv +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV; + + header('Content-Type: text/csv'); + header('Content-Disposition: attachment;filename=journal_banque.csv'); + + $companystatic = new Client($db); + + if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert + { + foreach ( $tabpay as $key => $val ) { + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + + // Bank + print $date . $sep; + print $conf->global->ACCOUNTINGEX_BANK_JOURNAL . $sep; + foreach ( $tabbq[$key] as $k => $mt ) { + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $val["type_payment"] . $sep; + print $sep; + } + print "\n"; + + // Third party + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $conf->global->ACCOUNTINGEX_BANK_JOURNAL . $sep; + if ($val["lib"] == '(SupplierInvoicePayment)') { + print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep; + } else { + print length_accountg($conf->global->COMPTA_ACCOUNT_CUSTOMER) . $sep; + } + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $val["type_payment"] . $sep; + print $sep; + print "\n"; + } + } + } + } else // Modèle Export Classique + { + foreach ( $tabpay as $key => $val ) { + $date = dol_print_date($db->jdate($val["date"]), 'day'); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + + // Bank + foreach ( $tabbq[$key] as $k => $mt ) { + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . $langs->trans("Bank") . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + } + print "\n"; + + // Third party + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . $companystatic->name . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } + } + } +} else { + + $form = new Form($db); + + llxHeader('', $langs->trans("BankJournal")); + + $nom = $langs->trans("BankJournal"); + $nomlink = ''; + $periodlink = ''; + $exportlink = ''; + $builddate = time(); + $description = $langs->trans("DescBankJournal") . '
'; + $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 ""; + print ""; + print ""; + print ""; + print ""; + 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) { + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + } + + // Third party + foreach ( $tabtp[$key] as $k => $mt ) { + if ($k != 'type') { + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + } + + $var = ! $var; + } + + print "
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $reflabel . "" . length_accountg($k) . "" . $langs->trans('Bank') . "" . $val["type_payment"] . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $val["soclib"] . "" . length_accounta($k) . "" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")" . $val["type_payment"] . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
"; + + // End of page + llxFooter(); +} +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php new file mode 100644 index 00000000000..c5e0b74543d --- /dev/null +++ b/htdocs/accountancy/journal/cashjournal.php @@ -0,0 +1,544 @@ + + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Olivier Geffroy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/journal/cashjournal.php + * \ingroup Accounting Expert + * \brief Page with cash journal + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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"); +dol_include_once("/core/lib/bank.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/societe/class/societe.class.php"); +dol_include_once("/adherents/class/adherent.class.php"); +dol_include_once("/compta/sociales/class/chargesociales.class.php"); +dol_include_once("/compta/paiement/class/paiement.class.php"); +dol_include_once("/compta/tva/class/tva.class.php"); +dol_include_once("/fourn/class/paiementfourn.class.php"); +dol_include_once("/fourn/class/fournisseur.facture.class.php"); +dol_include_once("/fourn/class/fournisseur.class.php"); +dol_include_once("/accountingex/class/bookkeeping.class.php"); + +// Langs +$langs->load("companies"); +$langs->load("other"); +$langs->load("compta"); +$langs->load("bank"); +$langs->load("accountingex@accountingex"); + +$date_startmonth = GETPOST('date_startmonth'); +$date_startday = GETPOST('date_startday'); +$date_startyear = GETPOST('date_startyear'); +$date_endmonth = GETPOST('date_endmonth'); +$date_endday = GETPOST('date_endday'); +$date_endyear = GETPOST('date_endyear'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$action = GETPOST('action'); + +/* + * View + */ + +$year_current = strftime("%Y", dol_now()); +$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonthyear = $year_current; +if ($pastmonth == 0) { + $pastmonth = 12; + $pastmonthyear --; +} + +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); + +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); +} + +$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); +$idpays = $p[0]; + +$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,"; +$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop"; +$sql .= " FROM " . MAIN_DB_PREFIX . "bank b"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account ba on b.fk_account=ba.rowid"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe soc on bu1.url_id=soc.rowid"; + +// Code opération type caisse +$sql .= " WHERE ba.courant = 2"; +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND ba.entity = " . $conf->entity; +} + +if ($date_start && $date_end) + $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; +$sql .= " ORDER BY b.datev"; + +$object = new Account($db); +$paymentstatic = new Paiement($db); +$paymentsupplierstatic = new PaiementFourn($db); +$societestatic = new Societe($db); +$chargestatic = new ChargeSociales($db); +$paymentvatstatic = new TVA($db); + +dol_syslog("accountingex/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->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); + $cptsociale = (! empty($conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_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)') + $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour); + if ($obj->label == '(CustomerInvoicePayment)') + $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); + if ($obj->typeop == '(BankTransfert)') + $compta_soc = $conf->global->ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH; + + // variable bookkeeping + + $tabpay[$obj->rowid]["date"] = $obj->do; + $tabpay[$obj->rowid]["ref"] = $obj->label; + $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; + if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { + $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); + } else { + $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); + } else if ($links[$key]['type'] == 'payment_supplier') { + $paymentsupplierstatic->id = $links[$key]['url_id']; + $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') + $reg[1] = 'SocialContribution'; + $chargestatic->lib = $langs->trans($reg[1]); + } else { + $chargestatic->lib = $links[$key]['label']; + } + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $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); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } else if ($links[$key]['type'] == 'banktransfert') { + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } + /*else { + $tabtp [$obj->rowid] [$cptsociale] += $obj->amount; + }*/ + } + $tabbq[$obj->rowid][$compta_bank] += $obj->amount; + + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; + + $i ++; + } +} else { + dol_print_error($db); +} + +/* + * Actions +*/ + +// write bookkeeping +if ($action == 'writeBookKeeping') { + $error = 0; + foreach ( $tabpay as $key => $val ) { + // cash + foreach ( $tabbq[$key] as $k => $mt ) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->doc_type = 'cash'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $compte->intitule; + $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0); + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sqlmid .= " WHERE payf.fk_bank=" . $key; + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + } + + $result = $bookkeeping->create(); + if ($result < 0) { + $error ++; + setEventMessage($object->errors, 'errors'); + } + } + // third party + foreach ( $tabtp[$key] as $k => $mt ) { + + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->doc_type = 'cash'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sqlmid .= " WHERE payf.fk_bank=" . $key; + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $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"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $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 ++; + setEventMessage($object->errors, 'errors'); + } + } + } + + if (empty($error)) { + setEventMessage($langs->trans('Success'), 'mesgs'); + } +} +// export csv +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV; + + header('Content-Type: text/csv'); + header('Content-Disposition:attachment;filename=journal_caisse.csv'); + + if ($conf->global->ACCOUNTINGEX_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->ACCOUNTINGEX_CASH_JOURNAL . $sep; + + foreach ( $tabbq[$key] as $k => $mt ) { + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print price($mt) . $sep; + } + print utf8_decode($langs->trans("CashPayment")) . $sep; + print $val["ref"] . $sep; + print "\n"; + + // Third party + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $conf->global->ACCOUNTINGEX_CASH_JOURNAL . $sep; + if ($obj->label == '(SupplierInvoicePayment)') { + print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep; + } else { + print length_accountg($conf->global->COMPTA_ACCOUNT_CUSTOMER) . $sep; + } + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print price($mt) . $sep; + print $langs->trans("ThirdParty") . $sep; + print $val["ref"] . $sep; + print "\n"; + } + } + } + } else // Modèle Export Classique + { + foreach ( $tabpay as $key => $val ) { + $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; + print '"' . $langs->trans("Cash") . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + } + print "\n"; + + // Third party + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . $langs->trans("ThirdParty") . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } + } + } +} else { + + $form = new Form($db); + + llxHeader('', $langs->trans("CashJournal"), ''); + + $nom = $langs->trans("CashJournal"); + $nomlink = ''; + $periodlink = ''; + $exportlink = ''; + $builddate = time(); + $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 ""; + print ""; + print ""; + 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) { + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; + print ""; + } + } + + // third party + foreach ( $tabtp[$key] as $k => $mt ) { + if ($k != 'type') { + print ""; + + print ""; + print ""; + + print ""; + print '"; + print '"; + } + } + + $var = ! $var; + } + + print "
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("Account") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $val["lib"] . "" . length_accountg($k) . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $val["soclib"] . "" . length_accounta($k) . "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; + + // End of page + llxFooter(); +} +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/journal/index.html b/htdocs/accountancy/journal/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/journal/index.php b/htdocs/accountancy/journal/index.php new file mode 100644 index 00000000000..74e53e4076b --- /dev/null +++ b/htdocs/accountancy/journal/index.php @@ -0,0 +1,58 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accountingex/journal/index.php + * \ingroup Accounting Expert + * \brief Index + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +llxHeader('', 'Journaux', ''); + +$form = new Form($db); + +// End of page +$db->close(); +llxFooter(); +?> \ No newline at end of file diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php new file mode 100644 index 00000000000..01dbc0a28c2 --- /dev/null +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -0,0 +1,482 @@ + + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Olivier Geffroy + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/journal/purchasesjournal.php + * \ingroup Accounting Expert + * \brief Page with purchases journal + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/fourn/class/fournisseur.facture.class.php"); +dol_include_once("/fourn/class/fournisseur.class.php"); +dol_include_once("/accountingex/class/bookkeeping.class.php"); +dol_include_once("/accountingex/class/accountingaccount.class.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +$date_startmonth = GETPOST('date_startmonth'); +$date_startday = GETPOST('date_startday'); +$date_startyear = GETPOST('date_startyear'); +$date_endmonth = GETPOST('date_endmonth'); +$date_endday = GETPOST('date_endday'); +$date_endyear = GETPOST('date_endyear'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$action = GETPOST('action'); + +/* + * View + */ + +$year_current = strftime("%Y", dol_now()); +$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonthyear = $year_current; +if ($pastmonth == 0) { + $pastmonth = 12; + $pastmonthyear --; +} + +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); + +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); +} + +$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); +$idpays = $p[0]; + +$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,"; +$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; +$sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.fournisseur,"; +$sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = fd.fk_product"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn f ON f.rowid = fd.fk_facture_fourn"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = f.fk_soc"; +$sql .= " WHERE f.fk_statut > 0 "; +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = " . $conf->entity; +} +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $sql .= " AND f.type IN (0,1,2)"; +else + $sql .= " AND f.type IN (0,1,2,3)"; +if ($date_start && $date_end) + $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; +$sql .= " ORDER BY f.datef"; + +dol_syslog('accountingex/journal/purchasesjournal.php:: $sql=' . $sql); +$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"); + $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)) ? $conf->global->COMPTA_VAT_ACCOUNT : $langs->trans("CodeNotDef"); + + $tabfac = array (); + $tabht = array (); + $tabtva = array (); + $tabttc = array (); + $tabcompany = array (); + + $i = 0; + while ( $i < $num ) { + $obj = $db->fetch_object($result); + // contrôles + $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; + $compta_prod = $obj->compte; + if (empty($compta_prod)) { + if ($obj->product_type == 0) + $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT)) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + else + $compta_prod = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT)) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + } + $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + + $tabfac[$obj->rowid]["date"] = $obj->df; + $tabfac[$obj->rowid]["ref"] = $obj->ref; + $tabfac[$obj->rowid]["type"] = $obj->type; + $tabfac[$obj->rowid]["description"] = $obj->description; + $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; + $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + $tabcompany[$obj->rowid] = array ( + 'id' => $obj->socid, + 'name' => $obj->name, + 'code_fournisseur' => $obj->code_compta_fournisseur + ); + + $i ++; + } +} else { + dol_print_error($db); +} + +/* + * Actions +*/ +// Bookkeeping Write +if ($action == 'writebookkeeping') { + $now = dol_now(); + + foreach ( $tabfac as $key => $val ) { + foreach ( $tabttc[$key] as $k => $mt ) { + // get compte id and label + + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'supplier_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; + $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt > 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL; + + $bookkeeping->create(); + } + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $compte = new AccountingAccount($db); + if ($compte->fetch(null, $k)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'supplier_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = dol_trunc($val["description"], 128); + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL; + + $bookkeeping->create(); + } + } + } + + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'supplier_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $langs->trans("VAT"); + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL; + + $bookkeeping->create(); + } + } + } +} + +// export csv + +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV; + + header('Content-Type: text/csv'); + header('Content-Disposition: attachment;filename=journal_achats.csv'); + + if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert + { + foreach ( $tabfac as $key => $val ) { + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + if ($mt) { + print $date . $sep; + print $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($val["description"], 32) . $sep; + print $val["ref"]; + print "\n"; + } + } + + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $langs->trans("VAT") . $sep; + print $val["ref"]; + print "\n"; + } + } + print $date . $sep; + print $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL . $sep; + print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep; + + foreach ( $tabttc[$key] as $k => $mt ) { + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print utf8_decode($companystatic->name) . $sep; + print $val["ref"]; + } + print "\n"; + } + } else // Modèle Export Classique + { + foreach ( $tabfac as $key => $val ) { + $date = dol_print_date($db->jdate($val["date"]), 'day'); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($val["description"], 32) . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } + } + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } + } + + // Third party + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + foreach ( $tabttc[$key] as $k => $mt ) { + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + } + print "\n"; + } + } +} else { + + llxHeader('', '', ''); + + $form = new Form($db); + + $nom = $langs->trans("PurchasesJournal"); + $nomlink = ''; + $periodlink = ''; + $exportlink = ''; + $builddate = time(); + $description = $langs->trans("DescPurchasesJournal") . '
'; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $description .= $langs->trans("DepositsAreNotIncluded"); + else + $description .= $langs->trans("DepositsAreIncluded"); + $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 ""; + // /print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $var = true; + $r = ''; + + $invoicestatic = new FactureFournisseur($db); + $companystatic = new Fournisseur($db); + + foreach ( $tabfac as $key => $val ) { + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + + $date = dol_print_date($db->jdate($val["date"]), 'day'); + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + print ""; + // print ""; + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; + print ""; + } + } + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print ""; + // print ""; + print ""; + print ""; + print ""; + print '"; + print '"; + print ""; + } + } + print ""; + + // Third party + // print ""; + print ""; + print ""; + + foreach ( $tabttc[$key] as $k => $mt ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + + print ""; + print '"; + print '"; + } + print ""; + + $var = ! $var; + } + + print "
".$langs->trans("JournalNum")."" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
".$conf->global->COMPTA_JOURNAL_BUY."" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $invoicestatic->description . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
".$conf->global->COMPTA_JOURNAL_BUY."" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $langs->trans("VAT") . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
".$conf->global->COMPTA_JOURNAL_BUY."" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accounta($k); + print "" . $langs->trans("ThirdParty"); + print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; + print "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; + + // End of page + llxFooter(); +} +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php new file mode 100644 index 00000000000..dd249db3b13 --- /dev/null +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -0,0 +1,490 @@ + + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Olivier Geffroy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/journal/sellsjournal.php + * \ingroup Accounting Expert + * \brief Page with sells journal + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +dol_include_once("/compta/facture/class/facture.class.php"); +dol_include_once("/societe/class/client.class.php"); +dol_include_once("/accountingex/class/bookkeeping.class.php"); +dol_include_once("/accountingex/class/accountingaccount.class.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +$date_startmonth = GETPOST('date_startmonth'); +$date_startday = GETPOST('date_startday'); +$date_startyear = GETPOST('date_startyear'); +$date_endmonth = GETPOST('date_endmonth'); +$date_endday = GETPOST('date_endday'); +$date_endyear = GETPOST('date_endyear'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$action = GETPOST('action'); + +/* + * View + */ + +$year_current = strftime("%Y", dol_now()); +$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonthyear = $year_current; +if ($pastmonth == 0) { + $pastmonth = 12; + $pastmonthyear --; +} + +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); + +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); +} + +$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); +$idpays = $p[0]; + +$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; +$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; +$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; +$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte, "; +$sql .= " ct.accountancy_code_sell as account_tva"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = fd.fk_product"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "facture f ON f.rowid = fd.fk_facture"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = f.fk_soc"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +$sql .= " WHERE fd.fk_code_ventilation > 0 "; +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = " . $conf->entity; +} +$sql .= " AND f.fk_statut > 0"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $sql .= " AND f.type IN (0,1,2)"; +else + $sql .= " AND f.type IN (0,1,2,3)"; +$sql .= " AND fd.product_type IN (0,1)"; +if ($date_start && $date_end) + $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; +$sql .= " ORDER BY f.datef"; + +dol_syslog('accountingex/journal/sellsjournal.php:: $sql=' . $sql); +$result = $db->query($sql); +if ($result) { + $tabfac = array (); + $tabht = array (); + $tabtva = array (); + $tabttc = array (); + $tabcompany = array (); + + $num = $db->num_rows($result); + $i = 0; + $resligne = array (); + while ( $i < $num ) { + $obj = $db->fetch_object($result); + // les variables + $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER)) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); + $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; + + $compta_prod = $obj->compte; + if (empty($compta_prod)) { + if ($obj->product_type == 0) + $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + else + $compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT)) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + } + $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)) ? $conf->global->COMPTA_VAT_ACCOUNT : $langs->trans("CodeNotDef"); + $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + + // la ligne facture + $tabfac[$obj->rowid]["date"] = $obj->df; + $tabfac[$obj->rowid]["ref"] = $obj->facnumber; + $tabfac[$obj->rowid]["type"] = $obj->type; + $tabfac[$obj->rowid]["description"] = $obj->description; + $tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; + if (! isset($tabttc[$obj->rowid][$compta_soc])) + $tabttc[$obj->rowid][$compta_soc] = 0; + if (! isset($tabht[$obj->rowid][$compta_prod])) + $tabht[$obj->rowid][$compta_prod] = 0; + if (! isset($tabtva[$obj->rowid][$compta_tva])) + $tabtva[$obj->rowid][$compta_tva] = 0; + $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + $tabcompany[$obj->rowid] = array ( + 'id' => $obj->socid, + 'name' => $obj->name, + 'code_client' => $obj->code_compta + ); + + $i ++; + } +} else { + dol_print_error($db); +} + +/* + * Action + */ + +// Bookkeeping Write +if ($action == 'writebookkeeping') { + $now = dol_now(); + + foreach ( $tabfac as $key => $val ) { + foreach ( $tabttc[$key] as $k => $mt ) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_facturedet"]; + $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; + $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_SELL_JOURNAL; + + $bookkeeping->create(); + } + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $compte = new AccountingAccount($db); + if ($compte->fetch(null, $k)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_facturedet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = dol_trunc($val["description"], 128); + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0) ? $mt : 0; + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_SELL_JOURNAL; + + $bookkeeping->create(); + } + } + } + + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_facturedet"]; + $bookkeeping->fk_compte = $compte->id; + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $langs->trans("VAT"); + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0) ? $mt : 0; + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_SELL_JOURNAL; + + $bookkeeping->create(); + } + } + } +} +// export csv +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV; + + header('Content-Type: text/csv'); + header('Content-Disposition: attachment;filename=journal_ventes.csv'); + + $companystatic = new Client($db); + + if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert + { + foreach ( $tabfac as $key => $val ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + + print $date . $sep; + print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep; + print length_accountg($conf->global->COMPTA_ACCOUNT_CUSTOMER) . $sep; + foreach ( $tabttc[$key] as $k => $mt ) { + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print utf8_decode($companystatic->name) . $sep; + } + print $val["ref"]; + print "\n"; + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($val["description"], 32) . $sep; + print $val["ref"]; + print "\n"; + } + } + // TVA + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $langs->trans("VAT") . $sep; + print $val["ref"]; + print "\n"; + } + } + } + } else // Modèle Export Classique + { + foreach ( $tabfac as $key => $val ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + $date = dol_print_date($db->jdate($val["date"]), 'day'); + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + foreach ( $tabttc[$key] as $k => $mt ) { + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + } + print "\n"; + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($val["description"], 32) . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } + + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } + } + } +} else { + + $form = new Form($db); + + llxHeader('', $langs->trans("SellsJournal")); + + $nom = $langs->trans("SellsJournal"); + $nomlink = ''; + $periodlink = ''; + $exportlink = ''; + $builddate = time(); + $description = $langs->trans("DescSellsJournal") . '
'; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $description .= $langs->trans("DepositsAreNotIncluded"); + else + $description .= $langs->trans("DepositsAreIncluded"); + $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 ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $var = true; + $r = ''; + + $invoicestatic = new Facture($db); + $companystatic = new Client($db); + + foreach ( $tabfac as $key => $val ) { + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + + $date = dol_print_date($db->jdate($val["date"]), 'day'); + + print ""; + + // Third party + // print ""; + print ""; + print ""; + foreach ( $tabttc[$key] as $k => $mt ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + print ""; + print ""; + } + print ""; + + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + print ""; + // print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + } + + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print ""; + // print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + } + + $var = ! $var; + } + + print "
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
".$conf->global->COMPTA_JOURNAL_SELL."" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accounta($k); + print "" . $langs->trans("ThirdParty"); + print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + print "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
".$conf->global->COMPTA_JOURNAL_SELL."" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $invoicestatic->description . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
".$conf->global->COMPTA_JOURNAL_SELL."" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
"; + + // End of page + llxFooter(); +} +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/supplier/fiche.php b/htdocs/accountancy/supplier/fiche.php new file mode 100644 index 00000000000..1ad626e136f --- /dev/null +++ b/htdocs/accountancy/supplier/fiche.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Olivier Geffroy + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +/** + * \file accountingex/supplier/fiche.php + * \ingroup Accountign Expert + * \brief Page fiche ventilation + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +dol_include_once("/fourn/class/fournisseur.facture.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +$action = GETPOST('action'); +$id = GETPOST('id', 'int'); +$codeventil = GETPOST('codeventil'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +if ($action == 'ventil' && $user->rights->accountingex->access) { + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sql .= " SET fk_code_ventilation = " . $codeventil; + $sql .= " WHERE rowid = " . $id; + + dol_syslog('accountingex/journal/sellsjournal.php:: $sql=' . $sql); + + $resql = $db->query($sql); + if (! $resql) { + setEventMessage($db->lasterror(), 'errors'); + } +} + +/* + * View + */ +llxHeader("", "", "FicheVentilation"); + +if ($cancel == $langs->trans("Cancel")) { + $action = ''; +} + +/* + * Create + */ +$form = new Form($db); +$facturefournisseur_static = new FactureFournisseur($db); +$formventilation = new FormVentilation($db); + +if ($_GET["id"]) { + $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; + $sql .= ", aa.account_number, aa.label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; + $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; + } + + $result = $db->query($sql); + if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + + if ($num_lignes) { + $objp = $db->fetch_object($result); + + print '
' . "\n"; + print ''; + print ''; + + print_fiche_titre($langs->trans("Ventilation")); + + print ''; + + // ref invoice + print ''; + $facturefournisseur_static->ref = $objp->facnumber; + $facturefournisseur_static->id = $objp->facid; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("BillsSuppliers") . '' . $facturefournisseur_static->getNomUrl(1) . '
Ligne' . stripslashes(nl2br($objp->description)) . '
' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
' . $langs->trans("Account") . ''; + print $objp->account_number . '-' . $objp->label; + print '
' . $langs->trans("NewAccount") . ''; + print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); + print '
 
'; + print '
'; + } else { + print "Error 1"; + } + } else { + print "Error 2"; + } +} else { + print "Error ID incorrect"; +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/supplier/index.html b/htdocs/accountancy/supplier/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php new file mode 100644 index 00000000000..a108415aa56 --- /dev/null +++ b/htdocs/accountancy/supplier/index.php @@ -0,0 +1,272 @@ + + * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2013 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/supplier/index.php + * \ingroup Accounting Expert + * \brief Page accueil ventilation + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +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/date.lib.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + + // Filter +$year = $_GET["year"]; +if ($year == 0) { + $year_current = strftime("%Y", time()); + $year_start = $year_current; +} else { + $year_current = $year; + $year_start = $year; +} + +// Validate History +$action = GETPOST('action'); +if ($action == 'validatehistory') { + + $error = 0; + $db->begin(); + + if ($db->type == 'pgsql') { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; + $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; + $sql1 .= " AND fd.fk_code_ventilation = 0"; + } else { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; + $sql1 .= " AND fd.fk_code_ventilation = 0"; + } + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Dispatched'), 'mesgs'); + } +} + +/* + * View + */ + +llxHeader('', $langs->trans("SuppliersVentilation")); + +$textprevyear = "" . img_previous() . ""; +$textnextyear = " " . img_next() . ""; + +print_fiche_titre($langs->trans("VentilationComptableSupplier") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); + +print '' . $langs->trans("DescVentilSupplier") . ''; +print ''; + +$y = $year_current; + +$var = true; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$sql = "SELECT IF(aa.account_number IS NULL, 'Non pointe', aa.account_number) AS 'code comptable',"; +$sql .= " IF(aa.label IS NULL, 'Non pointe', aa.label) AS 'Intitulé',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=1,ffd.total_ht,0)),2) AS 'Janvier',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=2,ffd.total_ht,0)),2) AS 'Fevrier',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=3,ffd.total_ht,0)),2) AS 'Mars',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=4,ffd.total_ht,0)),2) AS 'Avril',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=5,ffd.total_ht,0)),2) AS 'Mai',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=6,ffd.total_ht,0)),2) AS 'Juin',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=7,ffd.total_ht,0)),2) AS 'Juillet',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=8,ffd.total_ht,0)),2) AS 'Aout',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=9,ffd.total_ht,0)),2) AS 'Septembre',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=10,ffd.total_ht,0)),2) AS 'Octobre',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=11,ffd.total_ht,0)),2) AS 'Novembre',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=12,ffd.total_ht,0)),2) AS 'Decembre',"; +$sql .= " ROUND(SUM(ffd.total_ht),2) as 'Total'"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = ffd.fk_code_ventilation"; +$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND ff.fk_statut > 0 "; + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND ff.entity = '" . $conf->entity . "'"; +} + +$sql .= " GROUP BY ffd.fk_code_ventilation"; + +dol_syslog('/accountingex/supplier/index.php:: sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ( $i < $num ) { + + $row = $db->fetch_row($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i ++; + } + $db->free($resql); +} else { + print $db->lasterror(); // affiche la derniere erreur sql +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Intitule") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . '' . $langs->trans("Total") . '
' . $row[0] . '' . $row[1] . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + +print "
\n"; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS 'Total',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=1,ffd.total_ht,0)),2) AS 'Janvier',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=2,ffd.total_ht,0)),2) AS 'Fevrier',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=3,ffd.total_ht,0)),2) AS 'Mars',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=4,ffd.total_ht,0)),2) AS 'Avril',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=5,ffd.total_ht,0)),2) AS 'Mai',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=6,ffd.total_ht,0)),2) AS 'Juin',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=7,ffd.total_ht,0)),2) AS 'Juillet',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=8,ffd.total_ht,0)),2) AS 'Aout',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=9,ffd.total_ht,0)),2) AS 'Septembre',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=10,ffd.total_ht,0)),2) AS 'Octobre',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=11,ffd.total_ht,0)),2) AS 'Novembre',"; +$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=12,ffd.total_ht,0)),2) AS 'Decembre',"; +$sql .= " ROUND(SUM(ffd.total_ht),2) as 'Total'"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND ff.fk_statut > 0 "; + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND ff.entity = '" . $conf->entity . "'"; +} + +dol_syslog('/accountingex/supplier/index.php:: sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ( $i < $num ) { + $row = $db->fetch_row($resql); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $i ++; + } + + $db->free($resql); +} else { + print $db->lasterror(); // show last sql error +} +print "
' . $langs->trans("Total") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . '' . $langs->trans("Total") . '
' . $row[0] . '' . $row[1] . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '
\n"; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/supplier/lignes.php b/htdocs/accountancy/supplier/lignes.php new file mode 100644 index 00000000000..d3d47b6b371 --- /dev/null +++ b/htdocs/accountancy/supplier/lignes.php @@ -0,0 +1,232 @@ + + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2013-2014 Florian Henry 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/supplier/lignes.php + * \ingroup Accounting Expert + * \brief Page of detail of the lines of ventilation of invoices suppliers + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + +// Class +dol_include_once("/accountingex/class/html.formventilation.class.php"); +dol_include_once("/fourn/class/fournisseur.facture.class.php"); +dol_include_once("/product/class/product.class.php"); +dol_include_once("/core/lib/date.lib.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$formventilation = new FormVentilation($db); + +$changeaccount = GETPOST('changeaccount'); + +$is_search = GETPOST('button_search_x'); + +if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) { + $error = 0; + + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; + $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountingex/supplier/lignes.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessage($db->lasterror(), 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessage($langs->trans('Save'), 'mesgs'); + } else { + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } +} + +/* + * View + */ + +llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched")); + +$page = $_GET["page"]; +if ($page < 0) + $page = 0; + +if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) { + $limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION; +} else if ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) { + $limit = $conf->liste_limit; +} else { + $limit = $conf->liste_limit; +} + +$offset = $limit * $page; + +$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht , l.qty, l.rowid, l.tva_tx, aa.label, aa.account_number, "; +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; +$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa"; +$sql .= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; +$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 "; +$sql .= " AND aa.rowid = l.fk_code_ventilation"; +if (strlen(trim($_GET["search_facture"]))) { + $sql .= " AND f.facnumber like '%" . $_GET["search_facture"] . "%'"; +} +if (strlen(trim($_GET["search_ref"]))) { + $sql .= " AND p.ref like '%" . $_GET["search_ref"] . "%'"; +} +if (strlen(trim($_GET["search_label"]))) { + $sql .= " AND p.label like '%" . $_GET["search_label"] . "%'"; +} +if (strlen(trim($_GET["search_desc"]))) { + $sql .= " AND l.description like '%" . $_GET["search_desc"] . "%'"; +} +if (strlen(trim($_GET["search_account"]))) { + $sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'"; +} +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; +} + +$sql .= " ORDER BY l.rowid"; +if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE > 0) { + $sql .= " DESC "; +} +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog('accountingex/supplier/lignes.php::list sql= ' . $sql1); +$result = $db->query($sql); + +if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + + // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... + print_barre_liste($langs->trans("InvoiceLinesDone"), $page, "lignes.php", "", $sortfield, $sortorder, '', $num_lignes); + + print '' . $langs->trans("DescVentilDoneSupplier") . ''; + + print '
'; + print ''; + + print '

'. $langs->trans("ChangeAccount"); + print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); + print '
'; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $facturefournisseur_static = new FactureFournisseur($db); + $product_static = new Product($db); + + $var = True; + while ( $i < min($num_lignes, $limit) ) { + $objp = $db->fetch_object($result); + $var = ! $var; + $codeCompta = $objp->account_number . ' ' . $objp->label; + + print ""; + + // Ref Invoice + $facturefournisseur_static->ref = $objp->facnumber; + $facturefournisseur_static->id = $objp->facid; + print ''; + + // Ref Product + $product_static->ref = $objp->product_ref; + $product_static->id = $objp->product_id; + $product_static->type = $objp->type; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ""; + $i ++; + } +} else { + print $db->error(); +} + +print "
' . $langs->trans("Invoice") . '' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Amount") . '' . $langs->trans("Account") . '  
  '; + print ''; + print ' 
' . $facturefournisseur_static->getNomUrl(1) . ''; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print ' '; + print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . $codeCompta . '' . $objp->rowid . ''; + print img_edit(); + print '
"; + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/accountancy/supplier/liste.php b/htdocs/accountancy/supplier/liste.php new file mode 100644 index 00000000000..cbb7e06dab0 --- /dev/null +++ b/htdocs/accountancy/supplier/liste.php @@ -0,0 +1,227 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/supplier/liste.php + * \ingroup Accounting Expert + * \brief Page de ventilation des lignes de facture + */ + +// Dolibarr environment +$res = @include ("../main.inc.php"); +if (! $res && file_exists("../main.inc.php")) + $res = @include ("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) + $res = @include ("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) + $res = @include ("../../../main.inc.php"); +if (! $res) + die("Include of main fails"); + + // Class +dol_include_once("/fourn/class/fournisseur.facture.class.php"); +dol_include_once("/fourn/class/fournisseur.product.class.php"); +dol_include_once("/accountingex/class/html.formventilation.class.php"); + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountingex@accountingex"); + +$action = GETPOST('action'); +$codeventil = GETPOST('codeventil', 'array'); +$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accountingex->access) + accessforbidden(); + +$formventilation = new FormVentilation($db); + +llxHeader('', $langs->trans("Ventilation")); + +/* + * Action + */ + +if ($action == 'ventil') { + print '
' . $langs->trans("Processing") . '...
'; + if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) { + print '
' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '
'; + $mesCodesVentilChoisis = $codeventil; + $cpt = 0; + + foreach ( $mesCasesCochees as $maLigneCochee ) { + // print '
id selectionnee : '.$monChoix."
"; + $maLigneCourante = split("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monNumLigne = $maLigneCourante[1]; + $monCompte = $mesCodesVentilChoisis[$monNumLigne]; + + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sql .= " SET fk_code_ventilation = " . $monCompte; + $sql .= " WHERE rowid = " . $monId; + + dol_syslog('accountingext/supplier/liste.php:: sql=' . $sql); + if ($db->query($sql)) { + print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + } else { + print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '
' . $sql . '
'; + } + + $cpt ++; + } + } else { + print '
' . $langs->trans("AnyLineVentilate") . '
'; + } + print '
' . $langs->trans("EndProcessing") . '
'; +} + +/* + * Supplier Invoice Lines + * + */ +$page = GETPOST('page'); +if ($page < 0) + $page = 0; + +if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) { + $limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION; +} else if ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) { + $limit = $conf->liste_limit; +} else { + $limit = $conf->liste_limit; +} + +$offset = $limit * $page; + +$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, "; +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number"; +$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0"; + +if (! empty($conf->multicompany->enabled)) { + $sql .= " AND f.entity = '" . $conf->entity . "'"; +} + +$sql .= " ORDER BY l.rowid"; +if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO > 0) { + $sql .= " DESC "; +} +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog('accountingext/supplier/liste.php:: $sql=' . $sql); +$result = $db->query($sql); +if ($result) { + $num_lignes = $db->num_rows($result); + $i = 0; + + // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... + print_barre_liste($langs->trans("InvoiceLines"), $page, "liste.php", "", $sortfield, $sortorder, '', $num_lignes); + + print '
' . $langs->trans("DescVentilTodoSupplier") . '
'; + + print '
' . "\n"; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $facturefourn_static = new FactureFournisseur($db); + $productfourn_static = new ProductFournisseur($db); + $form = new Form($db); + + $var = True; + while ( $i < min($num_lignes, $limit) ) { + $objp = $db->fetch_object($result); + $var = ! $var; + print ""; + + // Ref facture + $facturefourn_static->ref = $objp->ref; + $facturefourn_static->id = $objp->facid; + print ''; + + // Ref facture supplier + $productfourn_static->ref = $objp->product_ref; + $productfourn_static->id = $objp->product_id; + $productfourn_static->type = $objp->type; + print ''; + + // print ''; + + // print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + // Colonne choix du compte + print ''; + // Colonne choix ligne a ventiler + print ''; + + print ""; + $i ++; + } + + print ''; + + print "
Facture' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Amount") . '' . $langs->trans("Compte") . '' . $langs->trans("IntoAccount") . '' . $langs->trans("Ventilate") . '
' . $facturefourn_static->getNomUrl(1) . ''; + if ($productfourn_static->id) + print $productfourn_static->getNomUrl(1); + else + print ' '; + print ''.$objp->ref.''.$objp->ref_supplier.'' . dol_trunc($objp->product_label, 24) . '' . stripslashes(nl2br($objp->description)) . ''; + print price($objp->price); + print ''; + print $objp->code_buy; + print ''; + print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1); + print ''; + print 'code_buy ? "checked" : "") . '/>'; + print '
 
"; + + print '
'; +} else { + print $db->error(); +} + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/accounting.php b/htdocs/admin/accounting.php deleted file mode 100644 index 80f9a647125..00000000000 --- a/htdocs/admin/accounting.php +++ /dev/null @@ -1,260 +0,0 @@ - - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2012 Alexandre Spangaro - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/admin/accounting.php - * \ingroup compta - * \brief Page to setup accountancy module - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - -$langs->load('admin'); -$langs->load('compta'); - -if (!$user->admin) -accessforbidden(); - -$action = GETPOST('action','alpha'); - -$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES'; - -if ($action == 'setcomptamode') -{ - $compta_mode = GETPOST('compta_mode','alpha'); - - $res = dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessage($langs->trans("SetupSaved")); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - } - -} - -if ($action == 'setchart') -{ - $chartofaccounts = GETPOST('chartofaccounts','alpha'); - - $res = dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts,'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessage($langs->trans("SetupSaved")); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - } -} - -if ($action == 'update' || $action == 'add') -{ - $constname = GETPOST('constname','alpha'); - $constvalue = GETPOST('constvalue','alpha'); - $consttype = GETPOST('consttype','alpha'); - $constnote = GETPOST('constnote','alpha'); - - $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessage($langs->trans("SetupSaved")); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - } -} - - -/*if ($action == 'delete') -{ - if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity)); - { - print $db->error(); - } -}*/ - -/* - * Affichage page - */ - -llxHeader(); - -$form=new Form($db); - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup'); - - -print '
'; - -print ''; - -// Cas du parametre COMPTA_MODE -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; -print ''; -print '\n"; -print ''; -print '\n"; -print ''; - -print "
'.$langs->trans('OptionMode').''.$langs->trans('Description').'
'.$langs->trans('OptionModeTrue').''.nl2br($langs->trans('OptionModeTrueDesc')); -// Write info on way to count VAT -if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) -{ - // print "
\n"; - // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite')); -} -else -{ - // print "
\n"; - // print nl2br($langs->trans('OptionModeTrueInfoExpert')); -} -print "
'.$langs->trans('OptionModeVirtual').''.nl2br($langs->trans('OptionModeVirtualDesc'))."
\n"; - -/* - * Define Chart of accounts - * - */ -if (! empty($conf->global->ACCOUNTING_SELECTCHART) && ! empty($conf->accounting->enabled)) -{ - print '
'; - print_titre($langs->trans("Definechartofaccounts")); - - print '
'; - print ''; - - print ''; - $var=True; - - print ''; - print ''; - print ''; - print "\n"; - $var=!$var; - print ''; - print ""; - print ""; - print "
'; - print ''; - print $langs->trans("Chartofaccounts").'
".$langs->trans("Selectchartofaccounts").""; - print '"; - print "
"; - print "
"; -} - -print "
\n"; - -// Cas des autres parametres COMPTA_* -$list=array('COMPTA_PRODUCT_BUY_ACCOUNT','COMPTA_PRODUCT_SOLD_ACCOUNT','COMPTA_SERVICE_BUY_ACCOUNT','COMPTA_SERVICE_SOLD_ACCOUNT', -'COMPTA_VAT_ACCOUNT','COMPTA_ACCOUNT_CUSTOMER','COMPTA_ACCOUNT_SUPPLIER' -); - -$num=count($list); -if ($num) -{ - print ''; - print ''; - print ''; - print "\n"; -} - -foreach ($list as $key) -{ - $var=!$var; - - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - - // Param - $libelle = $langs->trans($key); - print '\n"; - - // Value - print '\n"; - print ''; - - $i++; -} - -if ($num) -{ - print "
'.$langs->trans('OtherOptions').'
'.$libelle; - //print ' ('.$key.')'; - print "'; - print ''; - print ''; - print '   '; - print "
\n"; -} - -$db->close(); - -llxFooter(); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php new file mode 100644 index 00000000000..e11aa0770b2 --- /dev/null +++ b/htdocs/core/lib/accounting.lib.php @@ -0,0 +1,188 @@ + + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file accountingex/core/lib/account.lib.php + * \ingroup Accounting Expert + * \brief Ensemble de fonctions de base pour les comptes comptables + */ + +/** + * Prepare array with list of tabs + * + * @param Object $object to tabs + * @return array of tabs to shoc + */ +function admin_accounting_prepare_head($object) { + global $langs, $conf; + + $h = 0; + $head = array (); + + $head[$h][0] = dol_buildpath('/accountancy/admin/index.php', 1); + $head[$h][1] = $langs->trans("Configuration"); + $head[$h][2] = 'general'; + $h ++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin'); + + $head[$h][0] = dol_buildpath('/accountancy/admin/journaux.php', 1); + $head[$h][1] = $langs->trans("Journaux"); + $head[$h][2] = 'journal'; + $h ++; + + $head[$h][0] = dol_buildpath('/accountancy/admin/export.php', 1); + $head[$h][1] = $langs->trans("Export"); + $head[$h][2] = 'export'; + $h ++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin', 'remove'); + + return $head; +} + +/** + * Prepare array with list of tabs + * + * @param Object $object to tabs + * @return array of tabs to shoc + */ +function accounting_prepare_head($object) { + global $langs, $conf; + + $h = 0; + $head = array (); + + $head[$h][0] = dol_buildpath('/accountancy/admin/fiche.php', 1) . '?id=' . $object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h ++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account', 'remove'); + + return $head; +} + +/** + * Return general account with defined length + * + * @param $account + * + * @return $account + */ +function length_accountg($account) { + global $conf, $langs; + + $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT; + + if (! empty($g)) { + // Clean parameters + $i = strlen($account); + + if ($i >= 2) { + while ( $i < $g ) { + $account .= '0'; + + $i ++; + } + + return $account; + } else { + return $account; + } + } else { + return $account; + } +} + +/** + * Return auxiliary account with defined length + * + * @param $account + * + * @return $account + */ +function length_accounta($accounta) { + global $conf, $langs; + + $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT; + + if (! empty($a)) { + // Clean parameters + $i = strlen($accounta); + + if ($i >= 2) { + while ( $i < $a ) { + $accounta .= '0'; + + $i ++; + } + + return $accounta; + } else { + return $accounta; + } + } else { + return $accounta; + } +} + +/** + * Return account with defined length for Sage export software + * + * @param $account + * + * @return $account + */ +function length_exportsage($txt, $len, $end) { + // $txt = utf8_decode($txt); + // problem with this function, but we need to have the number of letter + if (strlen($txt) == $len) { + $res = $txt; + } + + elseif (strlen($txt) > $len) { + $res = substr($txt, 0, $len); + } + + else { + if ($end == 1) { + $res = $txt; + } else { + $res = ""; + } + for($i = strlen($txt); $i <= ($len - 1); $i ++) { + $res .= " "; + } + if ($end == 0) { + $res .= $txt; + } + } + return $res; +} \ No newline at end of file diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 489f07378a9..7a83486f286 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -1,9 +1,8 @@ - * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 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 @@ -20,154 +19,573 @@ */ /** - * \defgroup accounting Module accounting - * \brief Module to include accounting features - * \file htdocs/core/modules/modAccounting.class.php - * \ingroup accounting - * \brief Fichier de description et activation du module Comptabilite Expert + * \file accountingex/core/modules/modAccountingExpert.class.php + * \ingroup Accounting Expert + * \brief Module to activate Accounting Expert module */ - include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; - /** - * Classe de description et activation du module Comptabilite Expert + * \class modAccountingExpert + * \brief Description and activation class for module accounting expert */ class modAccounting extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions + * Constructor. + * Define names, constants, directories, boxes, permissions * - * @param DoliDB $db Database handler + * @param DoliDB $db */ function __construct($db) { global $conf; - $this->db = $db; - $this->numero = 50400 ; - + $this->db = $db; + $this->numero = 50400; + $this->family = "financial"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Gestion complete de comptabilite (doubles parties)"; - + $this->name = preg_replace('/^mod/i', '', get_class($this)); + $this->description = "Advanced manage of accounting"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - //$this->version = 'dolibarr'; - $this->version = "development"; - - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->version = 'development'; + + $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); $this->special = 0; - - // Config pages - $this->config_page_url = array("accounting.php"); - - // Dependancies - $this->depends = array("modFacture","modBanque","modTax"); - $this->requiredby = array(); - $this->conflictwith = array("modComptabilite"); - $this->langfiles = array("compta"); - - // Constants - $this->const = array(0=>array('MAIN_COMPANY_CODE_ALWAYS_REQUIRED','chaine','1','With this constants on, third party code is always required whatever is numbering module behaviour',0,'current',1), - 1=>array('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED','chaine','1','With this constants on, bank account number is always required',0,'current',1), - - ); // List of particular constants to add when module is enabled - + $this->picto = 'accountingex@accountingex'; + + // Defined if the directory /mymodule/inc/triggers/ contains triggers or not + // $this->triggers = 1; + // Data directories to create when module is enabled - $this->dirs = array("/accounting/temp"); - + $this->dirs = array ( + '/accountingex/temp' + ); + + // Config pages + $this->config_page_url = array('index.php@accounting'); + + // Dependencies + $this->depends = array ("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array (); // List of modules id to disable if this one is disabled + $this->conflictwith = array ("modComptabilite"); // List of modules are in conflict with this module + $this->phpmin = array ( + 5, + 2 + ); // Minimum version of PHP required by module + $this->need_dolibarr_version = array ( + 3, + 4 + ); // Minimum version of Dolibarr required by module + $this->langfiles = array ( + "accountingex@accountingex" + ); + + // Constants + $this->const = array (); + $this->const[1] = array ( + "MAIN_COMPANY_CODE_ALWAYS_REQUIRED", + "chaine", + "1", + "With this constants on, third party code is always required whatever is numbering module behaviour" + ); + $this->const[2] = array ( + "MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED", + "chaine", + "1", + "With this constants on, bank account number is always required" + ); + $this->const[1] = array ( + "ACCOUNTING_SEPARATORCSV", + "string", + "," + ); + $this->const[2] = array ( + "ACCOUNTING_ACCOUNT_SUSPENSE", + "chaine", + "471" + ); + $this->const[3] = array ( + "ACCOUNTING_SELL_JOURNAL", + "chaine", + "VTE" + ); + $this->const[4] = array ( + "ACCOUNTING_PURCHASE_JOURNAL", + "chaine", + "ACH" + ); + $this->const[5] = array ( + "ACCOUNTING_SOCIAL_JOURNAL", + "chaine", + "SOC" + ); + $this->const[6] = array ( + "ACCOUNTING_CASH_JOURNAL", + "chaine", + "CAI" + ); + $this->const[7] = array ( + "ACCOUNTING_MISCELLANEOUS_JOURNAL", + "chaine", + "OD" + ); + $this->const[8] = array ( + "ACCOUNTING_BANK_JOURNAL", + "chaine", + "BQ" + ); // Deprecated Move into llx_bank_account + $this->const[9] = array ( + "ACCOUNTING_ACCOUNT_TRANSFER_CASH", + "chaine", + "58" + ); + $this->const[10] = array ( + "CHARTOFACCOUNTS", + "chaine", + "2" + ); + $this->const[11] = array ( + "ACCOUNTING_MODELCSV", + "chaine", + "0" + ); + $this->const[12] = array ( + "ACCOUNTING_LENGTH_GACCOUNT", + "chaine", + "" + ); + $this->const[13] = array ( + "ACCOUNTING_LENGTH_AACCOUNT", + "chaine", + "" + ); + $this->const[14] = array ( + "ACCOUNTING_LIMIT_LIST_VENTILATION", + "chaine", + "50" + ); + $this->const[15] = array ( + "ACCOUNTING_LIST_SORT_VENTILATION_TODO", + "yesno", + "1" + ); + $this->const[16] = array ( + "ACCOUNTING_LIST_SORT_VENTILATION_DONE", + "yesno", + "1" + ); + + // Tabs + $this->tabs = array(); + + // Css + $this->module_parts = array ( + 'css' => array ( + '/accountingex/css/accountingex.css.php' + ) + ); + // Boxes - $this->boxes = array(); - + $this->boxes = array (); + // Permissions - $this->rights = array(); $this->rights_class = 'accounting'; - $r=0; - - $this->rights[$r][0] = 50401; - $this->rights[$r][1] = 'Lire le plan de compte'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; - $this->rights[$r][4] = 'plancompte'; - $this->rights[$r][5] = 'lire'; - $r++; - - $this->rights[$r][0] = 50402; - $this->rights[$r][1] = 'Creer/modifier un plan de compte'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'plancompte'; - $this->rights[$r][5] = 'creer'; - $r++; - - $this->rights[$r][0] = 50403; - $this->rights[$r][1] = 'Cloturer plan de compte'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'plancompte'; - $this->rights[$r][5] = 'cloturer'; - $r++; - - $this->rights[$r][0] = 50411; - $this->rights[$r][1] = 'Lire les mouvements comptables'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; - $this->rights[$r][4] = 'mouvements'; - $this->rights[$r][5] = 'lire'; - $r++; - - $this->rights[$r][0] = 50412; - $this->rights[$r][1] = 'Creer/modifier/annuler les mouvements comptables'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mouvements'; - $this->rights[$r][5] = 'creer'; - $r++; - - $this->rights[$r][0] = 50415; - $this->rights[$r][1] = 'Lire CA, bilans, resultats, journaux, grands livres'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'comptarapport'; - $this->rights[$r][5] = 'lire'; - $r++; + + $this->rights = array (); // Permission array used by this module + $r = 0; + + $this->rights[$r][0] = 150001; // Permission id (must not be already used) + $this->rights[$r][1] = 'Acces_module'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'access'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r ++; + + $this->rights[$r][0] = 150002; // Permission id (must not be already used) + $this->rights[$r][1] = 'Administration_module'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'admin'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r ++; + + $this->rights[$r][0] = 150010; // Permission id (must not be already used) + $this->rights[$r][1] = 'Développement'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'dev'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r ++; + + // Main menu entries + $this->menus = array (); + $r = 0; + + $this->menu[$r] = array ( + 'fk_menu' => 0, + 'type' => 'top', + 'titre' => 'Accounting', + 'mainmenu' => 'accounting', + 'leftmenu' => '0', + 'url' => '/accountingex/customer/index.php', + 'langs' => 'accountingex@accountingex', + 'position' => 100, + 'perms' => '$user->rights->accountingex->access', + 'enabled' => '$conf->accountingexpert->enabled', + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting', + 'type' => 'left', + 'titre' => 'CustomersVentilation', + 'leftmenu' => 'CustomersVentilation', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/customer/index.php', + 'langs' => 'accountingex@accountingex', + 'position' => 101, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation', + 'type' => 'left', + 'titre' => 'ToDispatch', + 'leftmenu' => 'ToDispatchCustomer', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/customer/liste.php', + 'langs' => 'accountingex@accountingex', + 'position' => 102, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation', + 'type' => 'left', + 'titre' => 'Dispatched', + 'leftmenu' => 'DispatchedCustomer', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/customer/lignes.php', + 'langs' => 'accountingex@accountingex', + 'position' => 103, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting', + 'type' => 'left', + 'titre' => 'SuppliersVentilation', + 'leftmenu' => 'SuppliersVentilation', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/supplier/index.php', + 'langs' => 'accountingex@accountingex', + 'position' => 110, + 'enabled' => '$conf->fournisseur->enabled', + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation', + 'type' => 'left', + 'titre' => 'ToDispatch', + 'leftmenu' => 'ToDispatchSupplier', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/supplier/liste.php', + 'langs' => 'accountingex@accountingex', + 'position' => 111, + 'enabled' => '$conf->fournisseur->enabled', + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation', + 'type' => 'left', + 'titre' => 'Dispatched', + 'leftmenu' => 'DispatchedSupplier', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/supplier/lignes.php', + 'langs' => 'accountingex@accountingex', + 'position' => 112, + 'enabled' => '$conf->fournisseur->enabled', + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting', + 'type' => 'left', + 'titre' => 'Journaux', + 'leftmenu' => 'Journaux', + 'mainmenu' => 'accounting', + // 'url'=>'', + 'langs' => 'accountingex@accountingex', + 'position' => 120, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', + 'type' => 'left', + 'titre' => 'SellsJournal', + 'leftmenu' => 'SellsJournal', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/journal/sellsjournal.php', + 'langs' => 'accountingex@accountingex', + 'position' => 121, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', + 'type' => 'left', + 'titre' => 'PurchasesJournal', + 'leftmenu' => 'PurchasesJournal', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/journal/purchasesjournal.php', + 'langs' => 'accountingex@accountingex', + 'position' => 122, + 'enabled' => '$conf->fournisseur->enabled', + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', + 'type' => 'left', + 'titre' => 'CashJournal', + 'leftmenu' => 'CashJournal', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/journal/cashjournal.php', + 'langs' => 'accountingex@accountingex', + 'position' => 123, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', + 'type' => 'left', + 'titre' => 'BankJournal', + 'leftmenu' => 'BankJournal', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/journal/bankjournal.php', + 'langs' => 'accountingex@accountingex', + 'position' => 200, + 'enabled' => '$conf->banque->enabled', + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting', + 'type' => 'left', + 'titre' => 'Bookkeeping', + 'leftmenu' => 'Bookkeeping', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/bookkeeping/liste.php', + 'langs' => 'accountingex@accountingex', + 'position' => 300, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping', + 'type' => 'left', + 'titre' => 'ByYear', + 'leftmenu' => 'ByYear', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/bookkeeping/listebyyear.php', + 'langs' => 'accountingex@accountingex', + 'position' => 301, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping', + 'type' => 'left', + 'titre' => 'AccountBalanceByMonth', + 'leftmenu' => 'AccountBalanceByMonth', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/bookkeeping/balancebymonth.php', + 'langs' => 'accountingex@accountingex', + 'position' => 302, + 'enabled' => 1, + 'perms' => 1, + 'target' => '', + 'user' => 0 + ); + $r ++; + + // Parameters Menu + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting', + 'type' => 'left', + 'titre' => 'Parameters', + 'leftmenu' => 'Parameters', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/admin/index.php', + 'langs' => 'accountingex@accountingex', + 'position' => 400, + 'enabled' => 1, + 'perms' => '$user->rights->accountingex->admin', + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', + 'type' => 'left', + 'titre' => 'Globalparameters', + 'leftmenu' => 'Globalparameters', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/admin/index.php', + 'langs' => 'accountingex@accountingex', + 'position' => 401, + 'enabled' => 1, + 'perms' => '$user->rights->accountingex->admin', + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters', + 'type' => 'left', + 'titre' => 'Chartofaccounts', + 'leftmenu' => 'Chartofaccounts', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/admin/account.php', + 'langs' => 'accountingex@accountingex', + 'position' => 402, + 'enabled' => 1, + 'perms' => '$user->rights->accountingex->admin', + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters', + 'type' => 'left', + 'titre' => 'Menuaccount', + 'leftmenu' => 'Menuaccount', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/admin/account.php', + 'langs' => 'accountingex@accountingex', + 'position' => 403, + 'enabled' => 1, + 'perms' => '$user->rights->accountingex->admin', + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', + 'type' => 'left', + 'titre' => 'Menuthirdpartyaccount', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/admin/thirdpartyaccount.php', + 'langs' => 'accountingex@accountingex', + 'position' => 404, + 'enabled' => 1, + 'perms' => '$user->rights->accountingex->admin', + 'target' => '', + 'user' => 0 + ); + $r ++; + + $this->menu[$r] = array ( + 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', + 'type' => 'left', + 'titre' => 'MenuTools', + 'mainmenu' => 'accounting', + 'url' => '/accountingex/admin/productaccount.php', + 'langs' => 'accountingex@accountingex', + 'position' => 405, + 'enabled' => 1, + 'perms' => '$user->rights->accountingex->admin', + 'target' => '', + 'user' => 0 + ); + $r ++; } - - - /** + + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO - */ - function init($options='') - { - // Prevent pb of modules not correctly disabled - //$this->remove($options); + */ + function init($options='') + { + $sql = array(); + + return $this->_init($sql,$options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options='') + { $sql = array(); - return $this->_init($sql,$options); - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function remove($options='') - { - global $conf; - - $sql = array("DELETE FROM ".MAIN_DB_PREFIX."const where name='MAIN_COMPANY_CODE_ALWAYS_REQUIRED' and entity IN ('0','".$conf->entity."')"); - return $this->_remove($sql,$options); - } + } } diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index cbe07b2fbdf..a0e557720e1 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -14,14 +14,12 @@ -- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; -- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE -- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as defailt NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); -ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER active; - -- Defined only to have specific list for countries that can't use generic list (like argentina that need type A or B) ALTER TABLE llx_c_typent ADD COLUMN fk_country integer NULL AFTER libelle; @@ -29,10 +27,36 @@ INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) values (11,'AC_INT','system','Intervention on site',NULL, 1, 4); - ALTER TABLE llx_user ADD COLUMN fk_user_creat integer AFTER tms; ALTER TABLE llx_user ADD COLUMN fk_user_modif integer AFTER fk_user_creat; +-- Add module accounting Expert +ALTER TABLE llx_bookkeeping RENAME TO llx_accounting_bookkeeping; -- To update old user of module Accounting Expert + + +CREATE TABLE llx_accounting_bookkeeping +( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + doc_date date NOT NULL, + doc_type varchar(30) NOT NULL, -- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur + doc_ref varchar(30) NOT NULL, -- facture_client/reglement_client/... reference number + fk_doc integer NOT NULL, -- facture_client/reglement_client/... rowid + fk_docdet integer NOT NULL, -- facture_client/reglement_client/... line rowid + code_tiers varchar(24), -- code tiers + numero_compte varchar(32) DEFAULT NULL, + label_compte varchar(128) NOT NULL, + debit double NOT NULL, + credit double NOT NULL, + montant double NOT NULL, + sens varchar(1) DEFAULT NULL, + fk_user_author integer NOT NULL, + import_key varchar(14), + code_journal varchar(10) DEFAULT NULL, + piece_num integer NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER active; +ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number; ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_accountingaccount add column datec datetime NOT NULL AFTER entity; @@ -40,7 +64,6 @@ ALTER TABLE llx_accountingaccount add column tms timestamp AFTER datec; ALTER TABLE llx_accountingaccount add column fk_user_author integer DEFAULT NULL AFTER label; ALTER TABLE llx_accountingaccount add column fk_user_modif integer DEFAULT NULL AFTER fk_user_author; - -- Drop old table DROP TABLE llx_compta; DROP TABLE llx_compta_account; @@ -61,8 +84,6 @@ ALTER TABLE llx_product MODIFY COLUMN accountancy_code_buy varchar(32); ALTER TABLE llx_user MODIFY COLUMN accountancy_code varchar(32); -ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number; - ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_date; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql new file mode 100644 index 00000000000..856d4d058d7 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -0,0 +1,39 @@ +-- ============================================================================ +-- Copyright (C) 2013-2014 Olivier Geffroy +-- Copyright (C) 2013-2014 Alexandre Spangaro +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +CREATE TABLE llx_accounting_bookkeeping +( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + doc_date date NOT NULL, + doc_type varchar(30) NOT NULL, -- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur + doc_ref varchar(30) NOT NULL, -- facture_client/reglement_client/... reference number + fk_doc integer NOT NULL, -- facture_client/reglement_client/... rowid + fk_docdet integer NOT NULL, -- facture_client/reglement_client/... line rowid + code_tiers varchar(24), -- code tiers + numero_compte varchar(32) DEFAULT NULL, + label_compte varchar(128) NOT NULL, + debit double NOT NULL, + credit double NOT NULL, + montant double NOT NULL, + sens varchar(1) DEFAULT NULL, + fk_user_author integer NOT NULL, + import_key varchar(14), + code_journal varchar(10) DEFAULT NULL, + piece_num integer NOT NULL +) ENGINE=innodb; diff --git a/htdocs/langs/en_US/accounting.lang b/htdocs/langs/en_US/accounting.lang new file mode 100644 index 00000000000..41ccb3b9197 --- /dev/null +++ b/htdocs/langs/en_US/accounting.lang @@ -0,0 +1,161 @@ +# Dolibarr language file - en_US - Accounting Expert +CHARSET=UTF-8 + +Module150000Name=Accounting Expert +Module150000Desc=Advanced management of the accounting + +Accounting=Accounting +Globalparameters=Global parameters +Chartofaccounts=Chart of accounts +Fiscalyear=Fiscal years +Menuaccount=Accounting accounts +Menuthirdpartyaccount=Thirdparty accounts +MenuTools=Tools + +ConfigAccountingExpert=Configuration of the module accounting expert +Journaux=Journaux +Exports=Exports +About=About +Contributors=Contributors +Investors=Investors +Modelcsv=Model of export +Selectmodelcsv=Select a model of export +Modelcsv_normal=Classic export +Modelcsv_CEGID=Export towards CEGID Expert +BackToChartofaccounts=Return chart of accounts + +Definechartofaccounts=Define a chart of accounts +Selectchartofaccounts=Select a chart of accounts +Validate=Validate +Addanaccount=Add an accounting account +AccountAccounting=Accounting account +Ventilation=Ventilation +ToDispatch=To dispatch +Dispatched=Dispatched + +CustomersVentilation=Ventilation customers +SuppliersVentilation=Ventilation suppliers +TradeMargin=Trade margin +Reports=Reports +ByCustomerInvoice=By invoices customers +ByMonth=By Month +NewAccount=New accounting account +Update=Update +List=List +Create=Create +UpdateAccount=Modification of an accounting account +UpdateMvts=Modification of a movement +WriteBookKeeping=Record accounts in general ledger +Bookkeeping=General ledger +AccountBalanceByMonth=Account balance by month + +VentilationComptable=Accounting ventilation +VentilationComptableSupplier=Accounting ventilation supplier +Intitule=Label +Line=Line + +CAHTF=Total purchase supplier HT +InvoiceLines=Lines of invoice to be ventilated +InvoiceLinesDone=Ventilated lines of invoice +IntoAccount=In the accounting account + +Ventilate=Ventilate +VentilationAuto=Automatic ventilation + +Processing=Processing +EndProcessing=The end of processing +AnyLineVentilate=Any lines to ventilate +SelectedLines=Selected lines +Lineofinvoice=Line of invoice +VentilatedinAccount=Ventilated successfully in the accounting account +NotVentilatedinAccount=Not ventilated in the accounting account + +ACCOUNTINGEX_SEPARATORCSV=Separator CSV + +ACCOUNTINGEX_LIMIT_LIST_VENTILATION=Number of elements to be ventilated shown by page (maximum recommended : 50) +ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO=Begin the sorting of the pages of ventilation "Has to ventilate" by the most recent elements +ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE=Begin the sorting of the pages of ventilation "Ventilated" by the most recent elements + +AccountLength=Length of the accounting accounts shown in Dolibarr +AccountLengthDesc=Function allowing to feign a length of accounting account by replacing spaces by the zero figure. This function touches only the display, it does not modify the accounting accounts registered in Dolibarr. For the export, this function is necessary to be compatible with certain software. +ACCOUNTINGEX_LENGTH_GACCOUNT=Length of the general accounts +ACCOUNTINGEX_LENGTH_AACCOUNT=Length of the third party accounts + +ACCOUNTINGEX_SELL_JOURNAL=Sell journal +ACCOUNTINGEX_PURCHASE_JOURNAL=Purchase journal +ACCOUNTINGEX_BANK_JOURNAL=Bank journal +ACCOUNTINGEX_CASH_JOURNAL=Cash journal +ACCOUNTINGEX_MISCELLANEOUS_JOURNAL=Miscellaneous journal +ACCOUNTINGEX_SOCIAL_JOURNAL=Social journal + +ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH=Account of transfer +ACCOUNTINGEX_ACCOUNT_SUSPENSE=Account of wait + +COMPTA_PRODUCT_BUY_ACCOUNT=Accounting account by default for bought products (if not defined in the product sheet) +COMPTA_PRODUCT_SOLD_ACCOUNT=Accounting account by default for the sold products (if not defined in the product sheet) +COMPTA_SERVICE_BUY_ACCOUNT=Accounting account by default for the bought services (if not defined in the service sheet) +COMPTA_SERVICE_SOLD_ACCOUNT=Accounting account by default for the sold services (if not defined in the service sheet) + +Doctype=Type of document +Docdate=Date +Docref=Reference +Numerocompte=Account +Code_tiers=Thirdparty +Labelcompte=Label account +Debit=Debit +Credit=Credit +Amount=Amount +Sens=Sens +Codejournal=Journal + +DelBookKeeping=Delete the records of the general ledger + +SellsJournal=Sells journal +PurchasesJournal=Purchases journal +DescSellsJournal=Sells journal +DescPurchasesJournal=Purchases journal +BankJournal=Bank journal +DescBankJournal=Banl journal including all the types of payments other than cash +CashJournal=Cash journal +DescCashJournal=Cash journal including the type of payment cash + +CashPayment=Cash Payment + +SupplierInvoicePayment=Payment of invoice supplier +CustomerInvoicePayment=Payment of invoice customer + +ThirdPartyAccount=Thirdparty account + +NumMvts=Number of movement +ListeMvts=List of the movement +ErrorDebitCredit=Debit and Credit cannot have a value at the same time + +ReportThirdParty=List thirdparty account +DescThirdPartyReport=Consult here the list of the thirdparty customers and the suppliers and their accounting accounts + +ListAccounts=List of the accounting accounts + +Pcgversion=Version of the plan +Pcgtype=Class of account +Pcgsubtype=Under class of account +Accountparent=Root of the account +Active=Statement + +NewFiscalYear=New fiscal year + +DescVentilCustomer=Consult here the annual accounting ventilation of your invoices customers +TotalVente=Total turnover HT +TotalMarge=Total sales margin +DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their accounting account +DescVentilTodoCustomer=Ventilate your lines of customer invoice with an accounting account +ChangeAccount=Change the accounting account for lines selected by the account: +Vide=- +DescVentilSupplier=Consult here the annual accounting ventilation of your invoices suppliers +DescVentilTodoSupplier=Ventilate your lines of invoice supplier with an accounting account +DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account + +ValidateHistory=Validate Automatically + +ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used + +FicheVentilation=Ventilation card \ No newline at end of file diff --git a/htdocs/langs/es_ES/accounting.lang b/htdocs/langs/es_ES/accounting.lang new file mode 100644 index 00000000000..af388dd6cff --- /dev/null +++ b/htdocs/langs/es_ES/accounting.lang @@ -0,0 +1,161 @@ +# Dolibarr language file - es_ES - Experto de la contabilidad +CHARSET=UTF-8 + +Module150000Name= Desglose contable +Module150000Desc= Gestión desglose contable + +Accounting=Contabilidad +Globalparameters=Configuración global +Chartofaccounts=Cuentas +Fiscalyear=Los años fiscales +Menuaccount=Contabilidad Cuentas +Menuthirdpartyaccount=Cuentas de terceros +MenuTools=Instrumentos + +ConfigAccountingExpert=Módulo de configuración experto en contabilidad +Journaux=Periódicos +Exports=Exportaciones +About=acerca de +Contributors=Contributors +Investors=Investors +Modelcsv=Plantilla de Exportación +Selectmodelcsv=Seleccione una plantilla de exportación +Modelcsv_normal=clásico exportación +Modelcsv_CEGID=Exportar a Cegid Expert +BackToChartofaccounts=Plan contable Volver + +Definechartofaccounts=Definir la contabilidad +Selectchartofaccounts=Seleccione una contabilidad +Validate=validar +Addanaccount=Añadir una cuenta contable +AccountAccounting=cuenta de Contabilidad +Ventilation=ventilación +ToDispatch=Para llevar a cabo +Dispatched=Realizado + +CustomersVentilation=Los clientes de ventilación +SuppliersVentilation=proveedores de ventilación +TradeMargin=margen de beneficio +Reports=relaciones +ByCustomerInvoice=Por las facturas de los clientes +ByMonth=por mes +NewAccount=Nueva cuenta contable +Update=Actualización +List=lista +Create=crear +UpdateAccount=Editar una cuenta +UpdateMvts=Modificación de un movimiento +WriteBookKeeping=Asientos contables en el libro mayor +Bookkeeping=libro mayor +AccountBalanceByMonth=Saldo Mensual + +VentilationComptable=desglose de Contabilidad +VentilationComptableSupplier=Proveedor de cuentas de ventilación +Intitule=título +Line=línea + +CAHTF=Total HT proveedor compra +InvoiceLines=Líneas de factura para ventilar +InvoiceLinesDone=Líneas de factura rotos +IntoAccount=En la cuenta + +Ventilate=ventilar +VentilationAuto=ventilación automática + +Processing=Tratamiento +EndProcessing=Final del tratamiento +AnyLineVentilate=No hay línea para ventilar +SelectedLines=Las líneas seleccionadas +Lineofinvoice=Línea de la factura +VentilatedinAccount=Ventilada con éxito en la cuenta contable +NotVentilatedinAccount=Cuenta sin ventilación en la contabilidad + +ACCOUNTINGEX_SEPARATORCSV=separador CSV + +ACCOUNTINGEX_LIMIT_LIST_VENTILATION=(El máximo recomendado: 50) Número de elementos que se muestran por página para ventilar +ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO=Páginas de inicio de clasificación de ventilación "desglose" de las pruebas más recientes +ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE=Páginas de inicio de clasificación de ventilación "ventilada" por la evidencia más reciente + +AccountLength=Cuentas contables longitud mostrada en Dolibarr +AccountLengthDesc=Función para simular una longitud de cuenta contable sustituyendo espacios con el número cero. Esta función sólo afecta a la pantalla, no cambia las cuentas contables registrados en Dolibarr. Para la exportación, esta función se requiere para ser compatible con algunos programas. +ACCOUNTINGEX_LENGTH_GACCOUNT=Longitud de las cuentas generales +ACCOUNTINGEX_LENGTH_AACCOUNT=Duración de subcuentas + +ACCOUNTINGEX_SELL_JOURNAL=Diario de Ventas +ACCOUNTINGEX_PURCHASE_JOURNAL=Diario de Compras +ACCOUNTINGEX_BANK_JOURNAL=Diario del Banco +ACCOUNTINGEX_CASH_JOURNAL=Diario de Caso +ACCOUNTINGEX_MISCELLANEOUS_JOURNAL=Diario de Operaciones diversas +ACCOUNTINGEX_SOCIAL_JOURNAL=Diario Social + +ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH=En caso de transferencia +ACCOUNTINGEX_ACCOUNT_SUSPENSE=Cuenta Suspense + +COMPTA_PRODUCT_BUY_ACCOUNT=Cuenta predeterminada de contabilidad para los productos comprados (si no se define en el producto) +COMPTA_PRODUCT_SOLD_ACCOUNT=Cuenta predeterminada de contabilidad para los productos vendidos (si no se define en el producto) +COMPTA_SERVICE_BUY_ACCOUNT=Cuenta predeterminada de contabilidad para los servicios adquiridos (si no está definido en la hoja de servicio) +COMPTA_SERVICE_SOLD_ACCOUNT=Cuenta predeterminada de contabilidad para servicios vendidos (si no se define en la ficha de servicio) + +Doctype=Tipo de documento +Docdate=fecha +Docref=referencia +Numerocompte=cuenta +Code_tiers=tercera +Labelcompte=cuenta de fraseología +Debit=débito +Credit=crédito +Amount=cantidad +Sens=sentido +Codejournal=periódico + +DelBookKeeping=Eliminar el libro mayor + +SellsJournal=Sell journal +PurchasesJournal=Purchase journal +DescSellsJournal=Sell journal +DescPurchasesJournal=Purchase journal +BankJournal=Diario de banco +DescBankJournal=Descripción de la revista del Banco +CashJournal=Libro de Caja +DescCashJournal=Descripción Libro de Caja + +CashPayment=especies Reglas + +SupplierInvoicePayment=Reglamento Factura +CustomerInvoicePayment=Factura del cliente Reglamento + +ThirdPartyAccount=Thirdparty account + +NumMvts=Number of movement +ListeMvts=List of the movement +ErrorDebitCredit=Debit and Credit cannot have a value at the same time + +ReportThirdParty=List thirdparty account +DescThirdPartyReport=Consult here the list of the thirdparty customers and the suppliers and their accounting accounts + +ListAccounts=List of the accounting accounts + +Pcgversion=Version of the plan +Pcgtype=Class of account +Pcgsubtype=Under class of account +Accountparent=Root of the account +Active=Statement + +NewFiscalYear=New fiscal year + +DescVentilCustomer=Consult here the annual accounting ventilation of your invoices customers +TotalVente=Total turnover HT +TotalMarge=Total sales margin +DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their accounting account +DescVentilTodoCustomer=Ventilate your lines of customer invoice with an accounting account +ChangeAccount=Change the accounting account for lines selected by the account: +Vide=- +DescVentilSupplier=Consult here the annual accounting ventilation of your invoices suppliers +DescVentilTodoSupplier=Ventilate your lines of invoice supplier with an accounting account +DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account + +ValidateHistory=Validate Automatically + +ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used + +FicheVentilation=Ventilation card \ No newline at end of file diff --git a/htdocs/langs/fr_FR/accounting.lang b/htdocs/langs/fr_FR/accounting.lang new file mode 100644 index 00000000000..41b2366590e --- /dev/null +++ b/htdocs/langs/fr_FR/accounting.lang @@ -0,0 +1,161 @@ +# Dolibarr language file - fr_FR - Accounting Expert +CHARSET=UTF-8 + +Module150000Name=Comptabilité Expert +Module150000Desc=Gestion avancée de la comptabilité + +Accounting=Comptabilité +Globalparameters=Paramètres globaux +Chartofaccounts=Plan comptable +Fiscalyear=Exercices fiscaux +Menuaccount=Comptes comptables +Menuthirdpartyaccount=Comptes tiers +MenuTools=Outils + +ConfigAccountingExpert=Configuration du module comptabilité expert +Journaux=Journaux +Exports=Exports +About=A propos +Contributors=Contributeurs +Investors=Investisseurs +Modelcsv=Modèle d'export +Selectmodelcsv=Sélectionnez un modèle d'export +Modelcsv_normal=Export classique +Modelcsv_CEGID=Export vers CEGID Expert +BackToChartofaccounts=Retour plan comptable + +Definechartofaccounts=Définir un plan comptable +Selectchartofaccounts=Sélectionnez un plan comptable +Validate=Valider +Addanaccount=Ajouter un compte comptable +AccountAccounting=Compte comptable +Ventilation=Ventilation +ToDispatch=A effectuer +Dispatched=Effectuée + +CustomersVentilation=Ventilation clients +SuppliersVentilation=Ventilation fournisseurs +TradeMargin=Marge commerciale +Reports=Rapports +ByCustomerInvoice=Par factures clients +ByMonth=Par mois +NewAccount=Nouveau compte comptable +Update=Mettre à jour +List=Liste +Create=Créer +UpdateAccount=Modification d'un compte +UpdateMvts=Modification d'un mouvement +WriteBookKeeping=Comptabiliser les écritures dans le grand livre +Bookkeeping=Grand livre +AccountBalanceByMonth=Balance mensuelle + +VentilationComptable=Ventilation comptable +VentilationComptableSupplier=Ventilation comptable fournisseur +Intitule=Intitulé +Line=Ligne + +CAHTF=Total achat fournisseur HT +InvoiceLines=Lignes de facture à ventiler +InvoiceLinesDone=Lignes de facture ventilées +IntoAccount=Dans le compte comptable + +Ventilate=Ventiler +VentilationAuto=Ventilation automatique + +Processing=Traitement en cours +EndProcessing=Fin de traitement +AnyLineVentilate=Aucune ligne à ventiler +SelectedLines=Lignes sélectionnées +Lineofinvoice=Ligne de facture +VentilatedinAccount=Ventilée avec succès dans le compte comptable +NotVentilatedinAccount=Non ventilée dans le compte comptable + +ACCOUNTINGEX_SEPARATORCSV=Séparateur CSV + +ACCOUNTINGEX_LIMIT_LIST_VENTILATION=Nombre d'éléments à ventiler affichés par page (maximum conseillé : 50) +ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO=Commencer le tri des pages de ventilation "A ventiler" par les éléments les plus récents +ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE=Commencer le tri des pages de ventilation "Ventilées" par les éléments les plus récents + +AccountLength=Longueur des comptes comptables affichés dans Dolibarr +AccountLengthDesc=Fonction permettant de simuler une longueur de compte comptable en remplaçant les espaces par le chiffre zéro. Cette fonction touche uniquement à l'affichage, elle ne modifie pas les comptes comptables enregistrés dans Dolibarr. Pour l'export, cette fonction est nécessaire pour être compatible avec certains logiciels. +ACCOUNTINGEX_LENGTH_GACCOUNT=Longueur des comptes généraux +ACCOUNTINGEX_LENGTH_AACCOUNT=Longueur des comptes tiers + +ACCOUNTINGEX_SELL_JOURNAL=Journal des Ventes +ACCOUNTINGEX_PURCHASE_JOURNAL=Journal des Achats +ACCOUNTINGEX_BANK_JOURNAL=Journal de Banque +ACCOUNTINGEX_CASH_JOURNAL=Journal de Caisse +ACCOUNTINGEX_MISCELLANEOUS_JOURNAL=Journal des Opérations Diverses +ACCOUNTINGEX_SOCIAL_JOURNAL=Journal Social + +ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH=Compte de transfert espèce +ACCOUNTINGEX_ACCOUNT_SUSPENSE=Compte d'attente + +COMPTA_PRODUCT_BUY_ACCOUNT=Compte comptable par défaut pour les produits achetés (si non défini dans la fiche produit) +COMPTA_PRODUCT_SOLD_ACCOUNT=Compte comptable par défaut pour les produits vendus (si non défini dans la fiche produit) +COMPTA_SERVICE_BUY_ACCOUNT=Compte comptable par défaut pour les services achetés (si non défini dans la fiche service) +COMPTA_SERVICE_SOLD_ACCOUNT=Compte comptable par défaut pour les services vendus (si non défini dans la fiche service) + +Doctype=Type de document +Docdate=Date +Docref=Référence +Numerocompte=Compte +Code_tiers=Tiers +Labelcompte=Libellé compte +Debit=Débit +Credit=Crédit +Amount=Montant +Sens=Sens +Codejournal=Journal + +DelBookKeeping=Supprimer les écritures du grand livre + +SellsJournal=Journal des ventes +PurchasesJournal=Journal des achats +DescSellsJournal=Journal des ventes +DescPurchasesJournal=Journal des achats +BankJournal=Journal de banque +DescBankJournal=Journal de banque comprenant tous les types de règlements autres que espèce +CashJournal=Journal de caisse +DescCashJournal=Journal de caisse comprenant le type de règlement "espèce" + +CashPayment=Règlement espèce + +SupplierInvoicePayment=Règlement de facture fournisseur +CustomerInvoicePayment=Règlement de facture client + +ThirdPartyAccount=Compte tiers + +NumMvts=Numero de mouvement +ListeMvts=Liste du mouvement +ErrorDebitCredit=Debit et Credit ne peuvent avoir une valeur en même temps + +ReportThirdParty=Liste compte tiers +DescThirdPartyReport=Consultez ici la liste des tiers clients et fournisseurs et leurs codes comptables + +ListAccounts=Liste des comptes comptables + +Pcgversion=Version du plan +Pcgtype=Classe de compte +Pcgsubtype=Sous classe de compte +Accountparent=Racine du compte +Active=État + +NewFiscalYear=Nouvel exercice fiscal + +DescVentilCustomer=Consultez ici la ventilation comptable annuelle de vos factures clients +TotalVente=Total chiffre affaires HT +TotalMarge=Total marge commerciale +DescVentilDoneCustomer=Consultez ici la liste des lignes de factures clients et leur compte comptable +DescVentilTodoCustomer=Ventilez vos lignes de facture client avec un compte comptable +ChangeAccount=Changer le compte comptable pour les lignes sélectionnées par le compte : +Vide=- +DescVentilSupplier=Consultez ici la ventilation comptable annuelle de vos factures fournisseurs +DescVentilTodoSupplier=Ventilez vos lignes de facture fournisseur avec un compte comptable +DescVentilDoneSupplier=Consultez ici la liste des lignes de factures fournisseur et leur compte comptable + +ValidateHistory=Valider Automatiquement + +ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas supprimer ce compte comptable car il est utilisé + +FicheVentilation=Fiche ventilation diff --git a/htdocs/theme/amarok/img/object_accounting.png b/htdocs/theme/amarok/img/object_accounting.png new file mode 100644 index 0000000000000000000000000000000000000000..b5600221f02fc922e0c2bda2149f123a6d707d35 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSL74G){)!Z!ppU1EV~B-+@(+Kdgca-8w;OdbEAY;!dSiR;fM5s*+lJc?4$OOV zDzq0fxwDu!M5tsO$Zx*nCU4P{#qe6i^{~OlMh}Kd3}$mPKK!?5_?j)8|83)j^+0nO NJYD@<);T3K0RT{uGx`7k literal 0 HcmV?d00001 diff --git a/htdocs/theme/auguria/img/object_accounting.png b/htdocs/theme/auguria/img/object_accounting.png new file mode 100644 index 0000000000000000000000000000000000000000..b5600221f02fc922e0c2bda2149f123a6d707d35 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSL74G){)!Z!ppU1EV~B-+@(+Kdgca-8w;OdbEAY;!dSiR;fM5s*+lJc?4$OOV zDzq0fxwDu!M5tsO$Zx*nCU4P{#qe6i^{~OlMh}Kd3}$mPKK!?5_?j)8|83)j^+0nO NJYD@<);T3K0RT{uGx`7k literal 0 HcmV?d00001 diff --git a/htdocs/theme/bureau2crea/img/object_accounting.png b/htdocs/theme/bureau2crea/img/object_accounting.png new file mode 100644 index 0000000000000000000000000000000000000000..b5600221f02fc922e0c2bda2149f123a6d707d35 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSL74G){)!Z!ppU1EV~B-+@(+Kdgca-8w;OdbEAY;!dSiR;fM5s*+lJc?4$OOV zDzq0fxwDu!M5tsO$Zx*nCU4P{#qe6i^{~OlMh}Kd3}$mPKK!?5_?j)8|83)j^+0nO NJYD@<);T3K0RT{uGx`7k literal 0 HcmV?d00001 diff --git a/htdocs/theme/cameleo/img/object_accounting.png b/htdocs/theme/cameleo/img/object_accounting.png new file mode 100644 index 0000000000000000000000000000000000000000..b5600221f02fc922e0c2bda2149f123a6d707d35 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSL74G){)!Z!ppU1EV~B-+@(+Kdgca-8w;OdbEAY;!dSiR;fM5s*+lJc?4$OOV zDzq0fxwDu!M5tsO$Zx*nCU4P{#qe6i^{~OlMh}Kd3}$mPKK!?5_?j)8|83)j^+0nO NJYD@<);T3K0RT{uGx`7k literal 0 HcmV?d00001 diff --git a/htdocs/theme/eldy/img/object_accounting.png b/htdocs/theme/eldy/img/object_accounting.png new file mode 100644 index 0000000000000000000000000000000000000000..b5600221f02fc922e0c2bda2149f123a6d707d35 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSL74G){)!Z!ppU1EV~B-+@(+Kdgca-8w;OdbEAY;!dSiR;fM5s*+lJc?4$OOV zDzq0fxwDu!M5tsO$Zx*nCU4P{#qe6i^{~OlMh}Kd3}$mPKK!?5_?j)8|83)j^+0nO NJYD@<);T3K0RT{uGx`7k literal 0 HcmV?d00001 From cdd716eb9d126c784a34c5ab35cae7ad78ce2c46 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 10:44:40 +0200 Subject: [PATCH 037/123] 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 0674667932a71965b8ffa25d71a6edffac916109 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 10:44:40 +0200 Subject: [PATCH 038/123] 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 2667e328e58..ed255b5785f 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 $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 071c405bad5b7630bcbd463beba78631bfdb743f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 10:44:40 +0200 Subject: [PATCH 039/123] 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 b1e9ccffd52..5585f2ccc55 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1217,7 +1217,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 61ae2f3f37fab514d8c355f6d08c565a13f71010 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 27 Aug 2014 11:34:24 +0200 Subject: [PATCH 040/123] fix : missing translation --- htdocs/langs/en_US/products.lang | 3 ++- htdocs/product/class/product.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 684ee5ef20a..1e3027acd25 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -80,11 +80,12 @@ ContractStatusClosed=Closed ContractStatusRunning=Running ContractStatusExpired=expired ContractStatusOnHold=Not running -ContractStatusToRun=A mettre en service +ContractStatusToRun=To get running ContractNotRunning=This contract is not running ErrorProductAlreadyExists=A product with reference %s already exists. ErrorProductBadRefOrLabel=Wrong value for reference or label. ErrorProductClone=There was a problem while trying to clone the product or service. +ErrorPriceCantBeLowerThanMinPrice=Error Price Can't Be Lower Than Minimum Price. Suppliers=Suppliers SupplierRef=Supplier's product ref. ShowProduct=Show product diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a32a8aa9127..c3b337c4a16 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1213,7 +1213,7 @@ class Product extends CommonObject if ($newvat == '') $newvat=$this->tva_tx; if (! empty($newminprice) && ($newminprice > $newprice)) { - $this->error='ErrorPricCanBeLowerThanMinPrice'; + $this->error='ErrorPriceCantBeLowerThanMinPrice'; return -1; } From 08c621037c76f0a1656f41ecec8dd5f878a5459a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Wed, 27 Aug 2014 11:41:18 +0200 Subject: [PATCH 041/123] fix : missing code for extrafields --- htdocs/fourn/class/fournisseur.commande.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f083318948e..dcd19b080b5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2010-2013 Philippe Grand + * Copyright (C) 2010-2014 Philippe Grand * Copyright (C) 2012 Marcos García * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador @@ -191,6 +191,13 @@ class CommandeFournisseur extends CommonOrder $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); + + // Retreive all extrafield + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); if ($this->statut == 0) $this->brouillon = 1; From 76cb6f760a93018d8192e038f68f7de04139a676 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 19:02:13 +0200 Subject: [PATCH 042/123] 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 b74c4bedf4d..a4d97e7defb 100644 --- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php @@ -79,7 +79,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 34561906fcb34aa3cd88a47ef48855e6bdaa333d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 19:02:13 +0200 Subject: [PATCH 043/123] 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 a446318649ed655967f0f42a8f71fd48ab5103db Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Aug 2014 19:02:13 +0200 Subject: [PATCH 044/123] 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 d03763f6c37ed9a1fa9bfe56906c4092a146f87b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 Aug 2014 06:30:01 +0200 Subject: [PATCH 045/123] Update Accounting Expert integration --- htdocs/accountancy/admin/account.php | 24 ++++---- .../accountancy/admin/{fiche.php => card.php} | 25 ++++---- htdocs/accountancy/admin/export.php | 24 ++++---- htdocs/accountancy/admin/importaccounts.php | 32 +++++----- htdocs/accountancy/admin/index.php | 38 ++++++------ htdocs/accountancy/admin/journaux.php | 28 +++++---- htdocs/accountancy/admin/productaccount.php | 18 +++--- .../accountancy/admin/thirdpartyaccount.php | 16 +++-- .../bookkeeping/balancebymonth.php | 14 ++--- .../bookkeeping/{fiche.php => card.php} | 21 ++++--- .../bookkeeping/{liste.php => list.php} | 22 +++---- .../{listebyyear.php => listbyyear.php} | 14 ++--- .../class/accountancysystem.class.php | 6 +- .../class/accountingaccount.class.php | 6 +- .../accountancy/class/bookkeeping.class.php | 40 ++++++------- .../class/html.formventilation.class.php | 7 ++- .../customer/{fiche.php => card.php} | 28 ++++----- htdocs/accountancy/customer/index.php | 22 +++---- .../customer/{lignes.php => lines.php} | 26 ++++----- .../customer/{liste.php => list.php} | 30 +++++----- htdocs/accountancy/journal/bankjournal.php | 38 ++++++------ htdocs/accountancy/journal/cashjournal.php | 42 +++++++------- htdocs/accountancy/journal/index.php | 11 ++-- .../accountancy/journal/purchasesjournal.php | 26 ++++----- htdocs/accountancy/journal/sellsjournal.php | 30 +++++----- .../supplier/{fiche.php => card.php} | 22 +++---- htdocs/accountancy/supplier/index.php | 21 +++---- .../supplier/{lignes.php => lines.php} | 28 ++++----- .../supplier/{liste.php => list.php} | 32 +++++----- htdocs/admin/dict.php | 58 ++++++------------- htdocs/core/modules/modAccounting.class.php | 14 ----- .../{accounting.lang => accountancy.lang} | 0 .../{accounting.lang => accountancy.lang} | 0 .../{accounting.lang => accountancy.lang} | 0 34 files changed, 354 insertions(+), 409 deletions(-) rename htdocs/accountancy/admin/{fiche.php => card.php} (94%) rename htdocs/accountancy/bookkeeping/{fiche.php => card.php} (93%) rename htdocs/accountancy/bookkeeping/{liste.php => list.php} (91%) rename htdocs/accountancy/bookkeeping/{listebyyear.php => listbyyear.php} (90%) rename htdocs/accountancy/customer/{fiche.php => card.php} (85%) rename htdocs/accountancy/customer/{lignes.php => lines.php} (90%) rename htdocs/accountancy/customer/{liste.php => list.php} (90%) rename htdocs/accountancy/supplier/{fiche.php => card.php} (89%) rename htdocs/accountancy/supplier/{lignes.php => lines.php} (89%) rename htdocs/accountancy/supplier/{liste.php => list.php} (88%) rename htdocs/langs/en_US/{accounting.lang => accountancy.lang} (100%) rename htdocs/langs/es_ES/{accounting.lang => accountancy.lang} (100%) rename htdocs/langs/fr_FR/{accounting.lang => accountancy.lang} (100%) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index f0bbd02f330..d8a26ca1ec5 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -17,7 +17,7 @@ */ /** - * \file accountingex/admin/account.php + * \file htdocs/accountancy/admin/account.php * \ingroup Accounting Expert * \brief List accounting account */ @@ -35,12 +35,12 @@ if (! $res) // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -dol_include_once("/accountingex/class/accountingaccount.class.php"); -dol_include_once("/accountingex/class/html.formventilation.class.php"); +dol_include_once("/accountancy/class/accountingaccount.class.php"); +dol_include_once("/accountancy/class/html.formventilation.class.php"); // Langs $langs->load("compta"); -$langs->load("accountingex@accountingex"); +$langs->load("accountancy"); $mesg = ''; $action = GETPOST('action'); @@ -48,10 +48,8 @@ $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -130,7 +128,7 @@ if (strlen(trim($_GET["search_pcgsubtype"]))) { $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); -dol_syslog('accountingex/admin/account.php:: $sql=' . $sql); +dol_syslog('accountancy/admin/account.php:: $sql=' . $sql); $result = $db->query($sql); if ($result) { @@ -144,7 +142,7 @@ if ($result) { print '
'; - print '' . $langs->trans("Addanaccount") . ''; + print '' . $langs->trans("Addanaccount") . ''; print '' . $langs->trans("ImportAccount") . ''; print '

'; @@ -178,7 +176,7 @@ if ($result) { $var = ! $var; print ''; - print '' . $obj->account_number . ''; + print '' . $obj->account_number . ''; print '' . $obj->label . ''; print '' . $obj->account_parent . ''; print '' . $obj->pcg_type . ''; @@ -197,10 +195,10 @@ if ($result) { print ''; if ($user->rights->accountingex->admin) { - print ''; + print ''; print img_edit(); print ' '; - print ''; + print ''; print img_delete(); print ''; } diff --git a/htdocs/accountancy/admin/fiche.php b/htdocs/accountancy/admin/card.php similarity index 94% rename from htdocs/accountancy/admin/fiche.php rename to htdocs/accountancy/admin/card.php index 76fc955fca2..68cdaf704a4 100644 --- a/htdocs/accountancy/admin/fiche.php +++ b/htdocs/accountancy/admin/card.php @@ -18,9 +18,9 @@ */ /** - * \file accountingex/admin/fiche.php - * \ingroup Accounting Expert - * \brief Page fiche de compte + * \file htdocs/accountancy/admin/card.php + * \ingroup Accounting Expert + * \brief Card accounting account */ $res = @include ("../main.inc.php"); if (! $res && file_exists("../main.inc.php")) @@ -34,12 +34,12 @@ if (! $res) // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -dol_include_once("/accountingex/class/accountingaccount.class.php"); -dol_include_once("/accountingex/class/html.formventilation.class.php"); +dol_include_once("/accountancy/class/accountingaccount.class.php"); +dol_include_once("/accountancy/class/html.formventilation.class.php"); // Langs $langs->load("bills"); -$langs->load("accountingex@accountingex"); +$langs->load("accountancy"); $mesg = ''; $action = GETPOST('action'); @@ -47,17 +47,16 @@ $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); + $accounting = new AccountingAccount($db); -// action +// Action if ($action == 'add') { $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql); + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result = $db->query($sql); $obj = $db->fetch_object($result); @@ -89,7 +88,7 @@ if ($action == 'add') { $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql); + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); $obj = $db->fetch_object($result2); diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index a326b7058ad..2b042720b60 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/accountingex/admin/export.php + * \file htdocs/accountancy/admin/export.php * \ingroup Accounting Expert * \brief Setup page to configure accounting expert module */ @@ -41,20 +41,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("compta"); $langs->load("bills"); -$langs->load('admin'); -$langs->load('accountingex@accountingex'); +$langs->load("admin"); +$langs->load("accountancy"); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); $action = GETPOST('action', 'alpha'); -// Other parameters ACCOUNTINGEX_* +// Other parameters ACCOUNTING_* $list = array ( - 'ACCOUNTINGEX_SEPARATORCSV' + 'ACCOUNTING_SEPARATORCSV' ); /* @@ -67,7 +65,7 @@ if ($action == 'update') { if (! empty($modelcsv)) { - if (! dolibarr_set_const($db, 'ACCOUNTINGEX_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { + if (! dolibarr_set_const($db, 'ACCOUNTING_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { $error ++; } } else { @@ -121,12 +119,12 @@ print "" . $langs->trans("Selectmodelcsv") . ""; print ""; print ''; $var = True; - while ( $i < min($num_lignes, $limit) ) { + while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; print ""; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index d25dffe4c25..83fb8820f08 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -21,7 +21,7 @@ */ /** - * \file htdocs/accountingex/admin/index.php + * \file htdocs/accountancy/admin/index.php * \ingroup Accounting Expert * \brief Setup page to configure accounting expert module */ @@ -43,30 +43,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("compta"); $langs->load("bills"); -$langs->load('admin'); -$langs->load('accountingex@accountingex'); +$langs->load("admin"); +$langs->load("accountancy"); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); $action = GETPOST('action', 'alpha'); -// Other parameters COMPTA_* & ACCOUNTINGEX_* +// Other parameters COMPTA_* & ACCOUNTING_* $list = array ( - 'ACCOUNTINGEX_LIMIT_LIST_VENTILATION', - 'ACCOUNTINGEX_LENGTH_GACCOUNT', - 'ACCOUNTINGEX_LENGTH_AACCOUNT', + 'ACCOUNTING_LIMIT_LIST_VENTILATION', + 'ACCOUNTING_LENGTH_GACCOUNT', + 'ACCOUNTING_LENGTH_AACCOUNT', 'COMPTA_ACCOUNT_CUSTOMER', 'COMPTA_ACCOUNT_SUPPLIER', 'COMPTA_PRODUCT_BUY_ACCOUNT', 'COMPTA_PRODUCT_SOLD_ACCOUNT', 'COMPTA_SERVICE_BUY_ACCOUNT', 'COMPTA_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTINGEX_ACCOUNT_SUSPENSE', - 'ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH' + 'ACCOUNTING_ACCOUNT_SUSPENSE', + 'ACCOUNTING_ACCOUNT_TRANSFER_CASH' ); /* @@ -126,7 +124,7 @@ if ($action == 'update') if ($action == 'setlistsorttodo') { $setlistsorttodo = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); if (! $res > 0) $error ++; @@ -139,7 +137,7 @@ if ($action == 'setlistsorttodo') { if ($action == 'setlistsortdone') { $setlistsortdone = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); if (! $res > 0) $error ++; if (! $error) { @@ -217,7 +215,7 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system"; $sql .= " WHERE active = 1"; $sql .= " AND fk_pays = " . $mysoc->country_id; -dol_syslog('accountingex/admin/index.php:: $sql=' . $sql); +dol_syslog('accountancy/admin/index.php:: $sql=' . $sql); $resql = $db->query($sql); $var = True; @@ -267,8 +265,8 @@ foreach ($list as $key) } print ""; -print '' . $langs->trans("ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO") . ''; -if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO)) { +print '' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; +if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; @@ -280,8 +278,8 @@ if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO)) { print ''; print ""; -print '' . $langs->trans("ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE") . ''; -if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE)) { +print '' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . ''; +if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; diff --git a/htdocs/accountancy/admin/journaux.php b/htdocs/accountancy/admin/journaux.php index f7b354090e9..139b8b37ae8 100644 --- a/htdocs/accountancy/admin/journaux.php +++ b/htdocs/accountancy/admin/journaux.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountingex/admin/journaux.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/journaux.php + * \ingroup Accounting Expert + * \brief Setup page to configure accounting expert module */ // Dolibarr environment @@ -42,23 +42,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; dol_include_once("/core/lib/bank.lib.php"); require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load('accountingex@accountingex'); +$langs->load("accountancy"); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); $action = GETPOST('action', 'alpha'); -// Other parameters ACCOUNTINGEX_* +// Other parameters ACCOUNTING_* $list = array ( - 'ACCOUNTINGEX_SELL_JOURNAL', - 'ACCOUNTINGEX_PURCHASE_JOURNAL', - 'ACCOUNTINGEX_SOCIAL_JOURNAL', - 'ACCOUNTINGEX_CASH_JOURNAL', - 'ACCOUNTINGEX_MISCELLANEOUS_JOURNAL' + 'ACCOUNTING_SELL_JOURNAL', + 'ACCOUNTING_PURCHASE_JOURNAL', + 'ACCOUNTING_SOCIAL_JOURNAL', + 'ACCOUNTING_CASH_JOURNAL', + 'ACCOUNTING_MISCELLANEOUS_JOURNAL' ); /* @@ -134,7 +132,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."lx_bank_account as ba"; $sql .= " WHERE ba.clos = 0" ; $sql .= " ORDER BY label"; -dol_syslog('accountingex/admin/journaux.php:: $sql='.$sql); +dol_syslog('accountancy/admin/journaux.php:: $sql='.$sql); $resql = $db->query($sql); if ($resql) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 89bc1996771..55e7b54031e 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -19,9 +19,9 @@ */ /** - * \file accountingex/admin/productaccount.php - * \ingroup Accounting Expert - * \brief Onglet de gestion de parametrages des ventilations + * \file htdocs/accountancy/admin/productaccount.php + * \ingroup Accounting Expert + * \brief Onglet de gestion de parametrages des ventilations */ // Dolibarr environment @@ -43,13 +43,11 @@ dol_include_once("/product/class/product.class.php"); $langs->load("companies"); $langs->load("compta"); $langs->load("main"); -$langs->load("accountingex@accountingex"); +$langs->load("accountancy"); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); llxHeader('', $langs->trans("Accounts")); @@ -70,7 +68,7 @@ $sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1"; -dol_syslog('accountingex/admin/productaccount.php:: $sql=' . $sql); +dol_syslog('accountancy/admin/productaccount.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/accountancy/admin/thirdpartyaccount.php b/htdocs/accountancy/admin/thirdpartyaccount.php index c9af52fcc51..7c4745aac86 100644 --- a/htdocs/accountancy/admin/thirdpartyaccount.php +++ b/htdocs/accountancy/admin/thirdpartyaccount.php @@ -18,9 +18,9 @@ */ /** - * \file accountingex/admin/thirdpartyaccount.php - * \ingroup Accounting Expert - * \brief Onglet de gestion de parametrages des ventilations + * \file htdocs/accountancy/admin/thirdpartyaccount.php + * \ingroup Accounting Expert + * \brief Onglet de gestion de parametrages des ventilations */ // Dolibarr environment @@ -41,13 +41,11 @@ dol_include_once("/core/lib/date.lib.php"); $langs->load("companies"); $langs->load("compta"); $langs->load("main"); -$langs->load("accountingex@accountingex"); +$langs->load("accountancy"); // Security check -if ($user->societe_id > 0) - accessforbidden(); -if (! $user->rights->accountingex->admin) - accessforbidden(); +if (!$user->admin) + accessforbidden(); // Date range $year = GETPOST("year"); @@ -164,7 +162,7 @@ $sql .= ")"; $sql .= "ORDER BY name ASC"; -dol_syslog('accountingex/admin/thirdpartyaccount.php:: $sql=' . $sql); +dol_syslog('accountancy/admin/thirdpartyaccount.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 5ce55fef7f6..7506ad27a39 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -19,9 +19,9 @@ */ /** - * \file accountingex/bookkeeping/balancebymonth.php - * \ingroup Accounting Expert - * \brief Balance by month + * \file htdocs/accountancy/bookkeeping/balancebymonth.php + * \ingroup Accounting Expert + * \brief Balance by month */ // Dolibarr environment @@ -37,14 +37,14 @@ if (! $res) // Class dol_include_once("/core/lib/date.lib.php"); -dol_include_once("accountingex/core/lib/account.lib.php"); +dol_include_once("accountancy/core/lib/account.lib.php"); // Langs $langs->load("main"); $langs->load("compta"); $langs->load("bills"); $langs->load("other"); -$langs->load("accountingex@accountingex"); +$langs->load("accountancy"); // Filter $year = $_GET["year"]; @@ -71,7 +71,7 @@ $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; $sql .= " WHERE fd.fk_code_ventilation = 0"; $sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; -dol_syslog('accountingex/bookkeeping/balancebymonth.php:: $sql=' . $sql); +dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql=' . $sql); $result = $db->query($sql); if ($result) { $row = $db->fetch_row($result); @@ -101,7 +101,7 @@ $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; $sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; -$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " GROUP BY bk.numero_compte"; diff --git a/htdocs/accountancy/bookkeeping/fiche.php b/htdocs/accountancy/bookkeeping/card.php similarity index 93% rename from htdocs/accountancy/bookkeeping/fiche.php rename to htdocs/accountancy/bookkeeping/card.php index b558f70e480..f6a9f347dc0 100644 --- a/htdocs/accountancy/bookkeeping/fiche.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -18,7 +18,7 @@ */ /** - * \file accountingex/bookkeeping/fiche.php + * \file htdocs/accountancy/bookkeeping/card.php * \ingroup Accounting Expert * \brief Page to show account */ @@ -35,10 +35,10 @@ if (! $res) die("Include of main fails"); // Class -dol_include_once("accountingex/class/bookkeeping.class.php"); +dol_include_once("accountancy/class/bookkeeping.class.php"); // Langs -$langs->load("accountingex@accountingex"); +$langs->load("accounting"); // Security check $id = GETPOST('id', 'int'); @@ -190,7 +190,6 @@ else if ($action == "confirm_create") { llxHeader(); $html = new Form($db); -$nbligne = 0; /* * Confirmation to delete the command @@ -205,16 +204,16 @@ if ($action == 'create') { print_fiche_titre($langs->trans("CreateMvts")); $code_journal_array = array ( - $conf->global->ACCOUNTINGEX_SELL_JOURNAL => $conf->global->ACCOUNTINGEX_SELL_JOURNAL, - $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL => $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL, - $conf->global->ACCOUNTINGEX_BANK_JOURNAL => $conf->global->ACCOUNTINGEX_BANK_JOURNAL, - $conf->global->ACCOUNTINGEX_SOCIAL_JOURNAL => $conf->global->ACCOUNTINGEX_SOCIAL_JOURNAL + $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, + $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, + $conf->global->ACCOUNTING_BANK_JOURNAL => $conf->global->ACCOUNTING_BANK_JOURNAL, + $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL ); $book = new BookKeeping($db); $next_num_mvt = $book->next_num_mvt(); - print '
'; + print ''; print '' . "\n"; print '' . "\n"; @@ -337,10 +336,10 @@ if ($action == 'create') { print ''; if ($user->rights->accoutingex->access) { - print ''; + print ''; print img_edit(); print ' '; - print ''; + print ''; print img_delete(); print ''; } diff --git a/htdocs/accountancy/bookkeeping/liste.php b/htdocs/accountancy/bookkeeping/list.php similarity index 91% rename from htdocs/accountancy/bookkeeping/liste.php rename to htdocs/accountancy/bookkeeping/list.php index f587663e71c..5826256db51 100644 --- a/htdocs/accountancy/bookkeeping/liste.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -19,8 +19,8 @@ */ /** - * \file accountingex/bookkeeping/liste.php - * \ingroup Accounting Expert + * \file htdocs/accountancy/bookkeeping/list.php + * \ingroup Accounting Expert * \brief List operation of book keeping */ @@ -36,8 +36,8 @@ if (! $res) die("Include of main fails"); // Class -dol_include_once("/accountingex/class/html.formventilation.class.php"); -dol_include_once("/accountingex/class/bookkeeping.class.php"); +dol_include_once("/accountancy/class/html.formventilation.class.php"); +dol_include_once("/accountancy/class/bookkeeping.class.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $page = GETPOST("page"); @@ -64,7 +64,7 @@ if ($action == 'delbookkeeping') { if (! empty($import_key)) { $object = new BookKeeping($db); $result = $object->delete_by_importkey($import_key); - Header("Location: liste.php"); + Header("Location: list.php"); if ($result < 0) { setEventMessage($object->errors, 'errors'); } @@ -106,7 +106,7 @@ else { */ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num "; - $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; if (dol_strlen(trim(GETPOST("search_doc_type")))) { @@ -131,13 +131,13 @@ else { $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); - dol_syslog('accountingex/bookkeeping/liste.php:: $sql=' . $sql); + dol_syslog('accountancy/bookkeeping/list.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - print_barre_liste($langs->trans("Bookkeeping"), $page, "liste.php", "", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); print ''; print ''; @@ -149,7 +149,7 @@ else { print '
'; - print 'Nouveau mouvement comptable'; + print '' . $langs->trans("NewAccountingMvt") . ''; print '
'; print ''; @@ -174,7 +174,7 @@ else { print "\n"; print ''; - print ''; + print ''; print ''; print ' '; print ''; @@ -211,7 +211,7 @@ else { print '' . price($obj->montant) . ''; print '' . $obj->sens . ''; print '' . $obj->code_journal . ''; - print '' . img_edit() . ''; + print '' . img_edit() . ''; print "\n"; $i ++; } diff --git a/htdocs/accountancy/bookkeeping/listebyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php similarity index 90% rename from htdocs/accountancy/bookkeeping/listebyyear.php rename to htdocs/accountancy/bookkeeping/listbyyear.php index 2e17e1205ab..45c25f72fbe 100644 --- a/htdocs/accountancy/bookkeeping/listebyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -19,7 +19,7 @@ */ /** - * \file accountingex/bookkeeping/listebyyear.php + * \file htdocs/accountancy/bookkeeping/listbyyear.php * \ingroup Accounting Expert * \brief Book keeping by year */ @@ -40,7 +40,7 @@ dol_include_once("/core/lib/date.lib.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Langs -$langs->load("accountingex@accountingex"); +$langs->load("accountancy"); $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); @@ -65,8 +65,8 @@ $offset = $conf->liste_limit * $page; llxHeader('', $langs->trans("Bookkeeping")); -$textprevyear = "" . img_previous() . ""; -$textnextyear = " " . img_next() . ""; +$textprevyear = "" . img_previous() . ""; +$textnextyear = " " . img_next() . ""; /* * Mode Liste @@ -74,12 +74,12 @@ $textnextyear = " " */ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal"; -$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; // $sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y,1,false))."'"; // $sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); -dol_syslog('accountingex/bookkeeping/listebyyear.php:: $sql=' . $sql); +dol_syslog('accountancy/bookkeeping/listbyyear.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -122,7 +122,7 @@ if ($resql) { print '' . price($obj->montant) . ''; print '' . $obj->sens . ''; print '' . $obj->code_journal . ''; - print '' . img_edit() . ''; + print '' . img_edit() . ''; print "\n"; $i ++; diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 63b59a95aaf..08d195aedcf 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -18,9 +18,9 @@ */ /** - * \file accountingex/class/accountancysystem.class.php - * \ingroup Accounting Expert - * \brief File of class to manage accountancy systems + * \file htdocs/accountancy/class/accountancysystem.class.php + * \ingroup Accounting Expert + * \brief File of class to manage accountancy systems */ /** diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 9cb29dc1e0b..34c23cb0a51 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -18,9 +18,9 @@ */ /** - * \file accountingex/class/Accountingaccount.class.php - * \ingroup Accounting Expert - * \brief Fichier de la classe des comptes comptable + * \file htdocs/accountancy/class/Accountingaccount.class.php + * \ingroup Accounting Expert + * \brief Fichier de la classe des comptes comptable */ /** diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0ea235599b6..b1bc5b158f1 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -19,9 +19,9 @@ */ /** - * \file accountingex/class/bookkeeping.class.php - * \ingroup Accounting Expert - * \brief Fichier de la classe des comptes comptable + * \file htdocs/accountancy/class/bookkeeping.class.php + * \ingroup Accounting Expert + * \brief Fichier de la classe des comptes comptable */ /** @@ -63,7 +63,7 @@ class BookKeeping { * \brief Load record in memory */ function fetch_per_mvt($piecenum) { - $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type FROM " . MAIN_DB_PREFIX . "bookkeeping WHERE "; + $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; $sql .= " piece_num = '" . $piecenum . "'"; dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG); @@ -93,7 +93,7 @@ class BookKeeping { $sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, "; $sql .= "numero_compte, label_compte, debit, credit, "; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; - $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE rowid = '" . $id . "'"; dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG); @@ -130,7 +130,7 @@ class BookKeeping { * \brief Return next num mvt */ function next_num_mvt() { - $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "bookkeeping"; + $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; dol_syslog(get_class($this) . "next_num_mvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -153,7 +153,7 @@ class BookKeeping { $sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, "; $sql .= "numero_compte, label_compte, debit, credit, "; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; - $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $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); @@ -193,8 +193,8 @@ class BookKeeping { } /** - * \brief Insere une ligne dans bookkeeping - * \param user utilisateur qui effectue l'insertion + * \brief Insert line into bookkeeping + * \param user User who inserted operation */ function create() { global $conf, $user, $langs; @@ -203,7 +203,7 @@ class BookKeeping { // first check if line not yet in bookkeeping $sql = "SELECT count(*)"; - $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $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 . "'"; @@ -217,7 +217,7 @@ class BookKeeping { // Determine piece_num $sqlnum = "SELECT piece_num"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $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 . "'"; @@ -231,7 +231,7 @@ class BookKeeping { dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -249,7 +249,7 @@ class BookKeeping { if (empty($this->date_create)) $this->date_create = $now(); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "bookkeeping (doc_date, "; + $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)"; $sql .= " VALUES ('" . $this->doc_date . "','" . $this->doc_type . "','" . $this->doc_ref . "'," . $this->fk_doc . ","; @@ -260,7 +260,7 @@ class BookKeeping { 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 . "bookkeeping"); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); if ($id > 0) { $this->id = $id; @@ -293,7 +293,7 @@ class BookKeeping { // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE import_key = '" . $importkey . "'"; $resql = $this->db->query($sql); @@ -364,7 +364,7 @@ class BookKeeping { // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "bookkeeping("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping("; $sql .= "doc_date,"; $sql .= "doc_type,"; @@ -414,7 +414,7 @@ class BookKeeping { } if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "bookkeeping"); + $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 @@ -491,7 +491,7 @@ class BookKeeping { // Put here code to add a control on parameters values // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "bookkeeping SET"; + $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") . ","; @@ -577,7 +577,7 @@ class BookKeeping { } if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "bookkeeping"; + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE rowid=" . $this->id; dol_syslog(get_class($this) . "::delete sql=" . $sql); @@ -610,7 +610,7 @@ class BookKeeping { $sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, "; $sql .= "numero_compte, label_compte, debit, credit, "; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; - $sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $resql = $this->db->query($sql); diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 16aeb01dd02..d6f5ce17404 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -18,8 +18,9 @@ */ /** - * \file accountingex/class/html.formventilation.class.php - * \brief Class for HML form + * \file htdocs/accountancy/class/html.formventilation.class.php + * \ingroup Accounting Expert + * \brief Class for HML form */ class FormVentilation extends Form { var $db; @@ -47,7 +48,7 @@ class FormVentilation extends Form { $date_array = array (); - $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'bookkeeping '; + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; $out = ''; print ''; @@ -164,7 +164,7 @@ if ($result) { $form = new Form($db); $var = True; - while ( $i < min($num_lignes, $limit) ) { + while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; print ""; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 28573c63677..11c3eb3f80b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23,0,26); +$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24); // Name of SQL tables of dictionaries $tabname=array(); @@ -96,10 +96,8 @@ $tabname[19]= MAIN_DB_PREFIX."c_effectif"; $tabname[20]= MAIN_DB_PREFIX."c_input_method"; $tabname[21]= MAIN_DB_PREFIX."c_availability"; $tabname[22]= MAIN_DB_PREFIX."c_input_reason"; -$tabname[23]= MAIN_DB_PREFIX."accountingaccount"; -$tabname[24]= MAIN_DB_PREFIX."accounting_system"; -$tabname[25]= MAIN_DB_PREFIX."c_revenuestamp"; -$tabname[26]= MAIN_DB_PREFIX."c_type_resource"; +$tabname[23]= MAIN_DB_PREFIX."c_revenuestamp"; +$tabname[24]= MAIN_DB_PREFIX."c_type_resource"; // Dictionary labels $tablib=array(); @@ -125,10 +123,8 @@ $tablib[19]= "DictionaryStaff"; $tablib[20]= "DictionaryOrderMethods"; $tablib[21]= "DictionaryAvailability"; $tablib[22]= "DictionarySource"; -$tablib[23]= "DictionaryAccountancyplan"; -$tablib[24]= "DictionaryAccountancysystem"; -$tablib[25]= "DictionaryRevenueStamp"; -$tablib[26]= "DictionaryResourceType"; +$tablib[23]= "DictionaryRevenueStamp"; +$tablib[24]= "DictionaryResourceType"; // Requests to extract data $tabsql=array(); @@ -154,10 +150,8 @@ $tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF $tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method"; $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; -$tabsql[23]= "SELECT rowid as rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number as accountancy_code, account_parent, label, active FROM ".MAIN_DB_PREFIX."accountingaccount"; -$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, c.code as country_code, c.label as country, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_pays=c.rowid and c.active=1"; -$tabsql[25]= "SELECT t.rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; -$tabsql[26]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; +$tabsql[23]= "SELECT t.rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; +$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -183,10 +177,8 @@ $tabsqlsort[19]="id ASC"; $tabsqlsort[20]="code ASC, libelle ASC"; $tabsqlsort[21]="code ASC, label ASC"; $tabsqlsort[22]="code ASC, label ASC"; -$tabsqlsort[23]="fk_pcg_version ASC, accountancy_code ASC"; -$tabsqlsort[24]="pcg_version ASC"; -$tabsqlsort[25]="country ASC, taux ASC"; -$tabsqlsort[26]="code ASC,label ASC"; +$tabsqlsort[23]="country ASC, taux ASC"; +$tabsqlsort[24]="code ASC,label ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); @@ -212,10 +204,8 @@ $tabfield[19]= "code,libelle"; $tabfield[20]= "code,libelle"; $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; -$tabfield[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label"; -$tabfield[24]= "pcg_version,country_id,country,label"; -$tabfield[25]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; -$tabfield[26]= "code,label"; +$tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; +$tabfield[24]= "code,label"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); @@ -241,10 +231,8 @@ $tabfieldvalue[19]= "code,libelle"; $tabfieldvalue[20]= "code,libelle"; $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; -$tabfieldvalue[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label"; -$tabfieldvalue[24]= "pcg_version,country,label"; -$tabfieldvalue[25]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[26]= "code,label"; +$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldvalue[24]= "code,label"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); @@ -270,10 +258,8 @@ $tabfieldinsert[19]= "code,libelle"; $tabfieldinsert[20]= "code,libelle"; $tabfieldinsert[21]= "code,label"; $tabfieldinsert[22]= "code,label"; -$tabfieldinsert[23]= "fk_pcg_version,account_number,account_parent,pcg_type,pcg_subtype,label"; -$tabfieldinsert[24]= "pcg_version,fk_pays,label"; -$tabfieldinsert[25]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldinsert[26]= "code,label"; +$tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[24]= "code,label"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on @@ -302,9 +288,7 @@ $tabrowid[20]= ""; $tabrowid[21]= "rowid"; $tabrowid[22]= "rowid"; $tabrowid[23]= ""; -$tabrowid[24]= ""; -$tabrowid[25]= ""; -$tabrowid[25]= ""; +$tabrowid[23]= ""; // Condition to show dictionary in setup page $tabcond=array(); @@ -330,10 +314,8 @@ $tabcond[19]= ! empty($conf->societe->enabled); $tabcond[20]= ! empty($conf->fournisseur->enabled); $tabcond[21]= ! empty($conf->propal->enabled); $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); -$tabcond[23]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy plan should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor. -$tabcond[24]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy system should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor. -$tabcond[25]= true; -$tabcond[26]= ! empty($conf->resource->enabled); +$tabcond[23]= true; +$tabcond[24]= ! empty($conf->resource->enabled); // List of help for fields $tabhelp=array(); @@ -361,8 +343,6 @@ $tabhelp[21] = array(); $tabhelp[22] = array(); $tabhelp[23] = array(); $tabhelp[24] = array(); -$tabhelp[25] = array(); -$tabhelp[26] = array(); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); @@ -390,8 +370,6 @@ $tabfieldcheck[21] = array(); $tabfieldcheck[22] = array(); $tabfieldcheck[23] = array(); $tabfieldcheck[24] = array(); -$tabfieldcheck[25] = array(); -$tabfieldcheck[26] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 7a83486f286..49d137a014f 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -204,20 +204,6 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r ++; - $this->rights[$r][0] = 150002; // Permission id (must not be already used) - $this->rights[$r][1] = 'Administration_module'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'admin'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r ++; - - $this->rights[$r][0] = 150010; // Permission id (must not be already used) - $this->rights[$r][1] = 'Développement'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'dev'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r ++; - // Main menu entries $this->menus = array (); $r = 0; diff --git a/htdocs/langs/en_US/accounting.lang b/htdocs/langs/en_US/accountancy.lang similarity index 100% rename from htdocs/langs/en_US/accounting.lang rename to htdocs/langs/en_US/accountancy.lang diff --git a/htdocs/langs/es_ES/accounting.lang b/htdocs/langs/es_ES/accountancy.lang similarity index 100% rename from htdocs/langs/es_ES/accounting.lang rename to htdocs/langs/es_ES/accountancy.lang diff --git a/htdocs/langs/fr_FR/accounting.lang b/htdocs/langs/fr_FR/accountancy.lang similarity index 100% rename from htdocs/langs/fr_FR/accounting.lang rename to htdocs/langs/fr_FR/accountancy.lang From add4528e6cf1aa143083e5b6d317de0402ca001e Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 Aug 2014 06:48:22 +0200 Subject: [PATCH 046/123] Update perms --- htdocs/accountancy/admin/account.php | 2 +- htdocs/accountancy/admin/card.php | 4 +- htdocs/accountancy/bookkeeping/card.php | 6 +-- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/journal/bankjournal.php | 2 +- htdocs/accountancy/journal/cashjournal.php | 2 +- htdocs/accountancy/journal/index.php | 2 +- .../accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/core/modules/modAccounting.class.php | 53 +++++++++++++------ 12 files changed, 51 insertions(+), 30 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index d8a26ca1ec5..5aba91751e4 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -194,7 +194,7 @@ if ($result) { print ''; print ''; print ''; print ''; } +/* + * Salaries + */ + +print ''; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; +$sql.= " WHERE p.entity = ".$conf->entity; +if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + +$sql.= " GROUP BY u.rowid"; +$sql.= " ORDER BY u.firstname"; + +dol_syslog("get payment salaries sql=".$sql); +$result=$db->query($sql); +$subtotal_ht = 0; +$subtotal_ttc = 0; +if ($result) +{ + $num = $db->num_rows($result); + $var=true; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; + + $var = !$var; + print ""; + + print "\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''; + print ''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print ""; + print ''; + print ''; + } +} +else +{ + dol_print_error($db); +} +print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''; +print ''; +print ''; /* * VAT diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index b3a42d85a6b..fdc9b0472f0 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * 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 @@ -469,6 +470,44 @@ $parameters["mode"] = $modecompta; $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +/* + * Salaries + */ +$subtotal_ht = 0; +$subtotal_ttc = 0; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " GROUP BY p.label, dm"; + +dol_syslog("get social salaries payments sql=".$sql); +$result=$db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $var=false; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount; + + $i++; + } + } +} +else +{ + dol_print_error($db); +} + /* * Show result array */ From 328b8b9643d7b2c0fed0c182ff69acf3f8221373 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 28 Aug 2014 15:29:31 +0200 Subject: [PATCH 062/123] Fix: Salary payments are not reflected on the reporting sheets Conflicts: ChangeLog --- ChangeLog | 8 ++++ htdocs/compta/resultat/clientfourn.php | 64 ++++++++++++++++++++++++++ htdocs/compta/resultat/index.php | 39 ++++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1946c2df9dd..e7c05ea3295 100644 --- a/ChangeLog +++ b/ChangeLog @@ -93,7 +93,15 @@ Dolibarr better: - Table llx_c_pays were renamed into llx_c_country. - Triggers *_BUILDDOC are removed. Building a doc is not a business event. For action after creation of a pdf or odt, hook "afterPDFCreation" or "afterODTCreation" must be used instead. + +***** ChangeLog for 3.6.1 compared to 3.6.* ***** +For users: +- Fix: Can upload files on services. +- Fix: sql errors on updat fichinter +- Fix: debian script syntax error +- Fix: error "menu param is not inside list" into pos module. +- Fix: Salary payments are not reflected on the reporting sheets ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 5dcd09814ad..14a0e8528b4 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * 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 @@ -538,6 +539,69 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti print ''; } +/* + * Salaries + */ + +print ''; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; +$sql.= " WHERE p.entity = ".$conf->entity; +if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + +$sql.= " GROUP BY u.rowid"; +$sql.= " ORDER BY u.firstname"; + +dol_syslog("get payment salaries sql=".$sql); +$result=$db->query($sql); +$subtotal_ht = 0; +$subtotal_ttc = 0; +if ($result) +{ + $num = $db->num_rows($result); + $var=true; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; + + $var = !$var; + print ""; + + print "\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''; + print ''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print ""; + print ''; + print ''; + } +} +else +{ + dol_print_error($db); +} +print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''; +print ''; +print ''; /* * VAT diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index c61c8b76e08..74224c024b0 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * 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 @@ -469,6 +470,44 @@ $parameters["mode"] = $modecompta; $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +/* + * Salaries + */ +$subtotal_ht = 0; +$subtotal_ttc = 0; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " GROUP BY p.label, dm"; + +dol_syslog("get social salaries payments sql=".$sql); +$result=$db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $var=false; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount; + + $i++; + } + } +} +else +{ + dol_print_error($db); +} + /* * Show result array */ From 4fdd98c4a75b719d3b0729fadca6d9eca138ac50 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:34:50 +0200 Subject: [PATCH 063/123] 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 714da050346bdd0415e5c6b8c9e282d3d27882e9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:34:50 +0200 Subject: [PATCH 064/123] 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 8806879aa4b..db840afb925 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -270,7 +270,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 615122bf3735d05dd030fa1e1b3c12f36c39b6fb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:34:50 +0200 Subject: [PATCH 065/123] 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 21d272a4198..6b3b1774a63 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -270,7 +270,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 139cf10c7c00b4e523eb54a3a7bb0de9134d5b2d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:52:20 +0200 Subject: [PATCH 066/123] 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 6b3b1774a63..7ffe021fe92 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 @@ -514,11 +514,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 2c46c20dfb6dac5b65071cf10e71380c0f36630b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:52:20 +0200 Subject: [PATCH 067/123] 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 db840afb925..9299702a1bb 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 @@ -514,11 +514,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 48f9ef25740d6e188e2ccf3f5b3c14732911e030 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 15:52:20 +0200 Subject: [PATCH 068/123] 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 b182bf1eb77ecb51bf18dcc97265da4e58243757 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 15:57:34 +0200 Subject: [PATCH 069/123] Output log to make upgrade tack easier --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 104bb1d00c2..cd22137f625 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,9 +93,9 @@ script: - php upgrade.php 3.5.0 3.6.0 >> upgrade.log - php upgrade2.php 3.5.0 3.6.0 >> upgrade2.log - php upgrade.php 3.6.0 3.7.0 >> upgrade.log + - cat upgrade.log - php upgrade2.php 3.6.0 3.7.0 >> upgrade2.log -# - cat upgrade.log -# - cat upgrade2.log + - cat upgrade2.log - cd ../.. - date - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php From 4d506d29d98ae918c23792a8ac79b7c5159a6358 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 16:14:35 +0200 Subject: [PATCH 070/123] Removed log output (log too long) --- .travis.yml | 4 ++-- build/debian/README.howto | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd22137f625..548a8c53380 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,9 +93,9 @@ script: - php upgrade.php 3.5.0 3.6.0 >> upgrade.log - php upgrade2.php 3.5.0 3.6.0 >> upgrade2.log - php upgrade.php 3.6.0 3.7.0 >> upgrade.log - - cat upgrade.log +# - cat upgrade.log - php upgrade2.php 3.6.0 3.7.0 >> upgrade2.log - - cat upgrade2.log +# - cat upgrade2.log - cd ../.. - date - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php diff --git a/build/debian/README.howto b/build/debian/README.howto index d0bdd4574f4..928a1b181f9 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -153,7 +153,13 @@ from origin/upstream and origin/pristine. * Into root dir, launch: > debian/get-orig-source.sh -If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0 " to solve this. +If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this. + +* Edit tgz file to remove +- includes/sRGB.icc +And rename file into +dolibarr-x.y.z+dsfgw.tgz +(x.y.z = version, w start from 1 and is increased for each new import) * Staying into git root directory, run > git-import-orig -vv ../tcpdf_x.y.z+dfsg.orig.tar.xz @@ -229,7 +235,7 @@ from origin/upstream and origin/pristine. * If new upstream is available onto sourceforge, launch: > debian/get-orig-source.sh -If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0 " to solve this. +If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this. * Edit tgz file to remove - ckeditor From 5e95daad91cabd64eb0ceb7b78d5f83332b84e93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 16:18:17 +0200 Subject: [PATCH 071/123] Fix: Sql syntax error --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index a2d168ed0fd..09d84de0bfe 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -973,7 +973,7 @@ CREATE TABLE llx_holiday_types ( deleteAt DATETIME, nbCongesDeducted varchar(255) NOT NULL, nbCongesEveryMonth varchar(255) NOT NULL -); +) ENGINE=innodb; -- Change on table c_civilite ALTER TABLE llx_c_civilite DROP INDEX uk_c_civilite; @@ -1001,7 +1001,7 @@ CREATE TABLE llx_fichinterdet_extrafields tms timestamp, fk_object integer NOT NULL, import_key varchar(14) -- import key -) ENGINE=innodb +) ENGINE=innodb; ALTER TABLE llx_fichinterdet_extrafields ADD INDEX idx_ficheinterdet_extrafields (fk_object); From 711e7e6fc6e72311cbf7af4b7d2a054aa3977eaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 16:59:10 +0200 Subject: [PATCH 072/123] Fix: phpunit test Fix: debian readme to upgrade tcpdf lib. --- build/debian/README.howto | 12 ++++++------ htdocs/core/modules/modSociete.class.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index 928a1b181f9..fea942a573f 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -158,17 +158,17 @@ If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VER * Edit tgz file to remove - includes/sRGB.icc And rename file into -dolibarr-x.y.z+dsfgw.tgz +tcpdf_x.y.z+dfsg.tar.xz (x.y.z = version, w start from 1 and is increased for each new import) * Staying into git root directory, run -> git-import-orig -vv ../tcpdf_x.y.z+dfsg.orig.tar.xz +> git-import-orig -vv ../tcpdf_x.y.z+dfsg.tar.xz Note: If there was errors solved manually, you may need to make a git commit * Add an entry into debian/changelog -> dch -v x.y.z-dsfg-1 "My comment" will add entry. -For example: dch -v x.y.z-dsfg-1 "New upstream release." for a new version +> dch -v x.y.z+dsfg-1 "My comment" will add entry. +For example: dch -v x.y.z+dsfg-1 "New upstream release." for a new version Then modify changelog to replace "version" or "unstable" with "UNRELEASED". Warning: Date must have format reported by "date -R" @@ -254,8 +254,8 @@ x.y.z+dsfgw Note: If there was errors solved manually after get-orig-sources.sh, you may need to make a git commit * Add an entry into debian/changelog -> dch -v x.y.z-w "My comment" will add entry. -For example: dch -v x.y.z-w "New upstream release." for a new version (x.y.z = version, w start from 1 and increaed for each new import) +> dch -v x.y.z+dfsg-w "My comment" will add entry. +For example: dch -v x.y.z+dfsg-w "New upstream release." for a new version (x.y.z = version, w start from 1 and increaed for each new import) Then modify changelog to replace "version" or "unstable" with "UNRELEASED". Then check/modify also the user/date signature: - Date must have format reported by "date -R" diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 28a5fcaebe3..63cb9c610b4 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -124,7 +124,7 @@ class modSociete extends DolibarrModules $this->const[$r][4] = 1; $r++; */ - + $this->const[$r][0] = "SOCIETE_ADD_REF_IN_LIST"; $this->const[$r][1] = "yesno"; $this->const[$r][2] = "0"; @@ -320,7 +320,7 @@ class modSociete extends DolibarrModules $this->export_label[$r]='ExportDataset_company_2'; $this->export_icon[$r]='contact'; $this->export_permission[$r]=array(array("societe","contact","export")); - $this->export_fields_array[$r]=array('c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction','c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town",'d.nom'=>'State','p.libelle'=>"Country",'p.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail",'s.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", 's.client'=>'Customer 0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'Supplier 0 or 1'); + $this->export_fields_array[$r]=array('c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction','c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town",'d.nom'=>'State','co.label'=>"Country",'co.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail",'s.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", 's.client'=>'Customer 0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'Supplier 0 or 1'); $this->export_TypeFields_array[$r]=array('c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean",'c.address'=>"Text",'c.cp'=>"Text",'c.ville'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text",'c.fax'=>"Text",'c.email'=>"Text",'s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Status",'s.client'=>"Text",'s.fournisseur'=>"Text"); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company", 's.client'=>"company", 's.fournisseur'=>"company"); // We define here only fields that use another picto if (empty($conf->fournisseur->enabled)) From 1aad1b6acd7decfce50a4d19602d6e1ab373950d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 28 Aug 2014 19:32:41 +0200 Subject: [PATCH 073/123] 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 074/123] 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 bc686a7995d0044d1e369b5c2439f2353a3bd5dd Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 29 Aug 2014 06:43:05 +0200 Subject: [PATCH 075/123] Test Correct travis --- htdocs/core/modules/modAccounting.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 3d4174be73e..308c765f5da 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -32,11 +32,10 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modAccounting extends DolibarrModules { /** - * Constructor. - * Define names, constants, directories, boxes, permissions + * Constructor. Define names, constants, directories, boxes, permissions * - * @param DoliDB $db - */ + * @param DoliDB $db Database handler + */ function __construct($db) { global $conf; From e4dbf6a9e4d60bb1047999b1c8a329f1aa5fd516 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Aug 2014 11:02:21 +0200 Subject: [PATCH 076/123] Removed useless file --- build/makepack-dolibarrlang.pl | 300 --------------------------------- 1 file changed, 300 deletions(-) delete mode 100755 build/makepack-dolibarrlang.pl diff --git a/build/makepack-dolibarrlang.pl b/build/makepack-dolibarrlang.pl deleted file mode 100755 index 6066a678d7c..00000000000 --- a/build/makepack-dolibarrlang.pl +++ /dev/null @@ -1,300 +0,0 @@ -#!/usr/bin/perl -#---------------------------------------------------------------------------- -# \file build/makepack-dolibarrlang.pl -# \brief Package builder (tgz, zip, rpm, deb, exe) -# \author (c)2005 Laurent Destailleur -#---------------------------------------------------------------------------- - -use Cwd; - -$PROJECT = "dolibarr"; - -@LISTETARGET = ("TGZ"); # Possible packages -%REQUIREMENTTARGET = ( # Tool requirement for each package - "TGZ" => "tar", - "ZIP" => "7z", - "EXE" => "makensis.exe" -); -%ALTERNATEPATH = ( - "7z" => "7-ZIP", - "makensis.exe" => "NSIS" -); - -use vars qw/ $REVISION $VERSION /; -$REVISION = '1.10'; -$VERSION = "1.0 (build $REVISION)"; - -#------------------------------------------------------------------------------ -# MAIN -#------------------------------------------------------------------------------ -( $DIR = $0 ) =~ s/([^\/\\]+)$//; -( $PROG = $1 ) =~ s/\.([^\.]*)$//; -$Extension = $1; -$DIR ||= '.'; -$DIR =~ s/([^\/\\])[\\\/]+$/$1/; - -# Detect OS type -# -------------- -if ( "$^O" =~ /linux/i || ( -d "/etc" && -d "/var" && "$^O" !~ /cygwin/i ) ) { - $OS = 'linux'; - $CR = ''; -} -elsif ( -d "/etc" && -d "/Users" ) { $OS = 'macosx'; $CR = ''; } -elsif ( "$^O" =~ /cygwin/i || "$^O" =~ /win32/i ) { - $OS = 'windows'; - $CR = "\r"; -} -if ( !$OS ) { - print "$PROG.$Extension was not able to detect your OS.\n"; - print "Can't continue.\n"; - print "$PROG.$Extension aborted.\n"; - sleep 2; - exit 1; -} - -# Define buildroot -# ---------------- -if ( $OS =~ /linux/ ) { - $TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp"; -} -if ( $OS =~ /macos/ ) { - $TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "/tmp"; -} -if ( $OS =~ /windows/ ) { - $TEMP = $ENV{"TEMP"} || $ENV{"TMP"} || "c:/temp"; - $PROGPATH = $ENV{"ProgramFiles"}; -} -if ( !$TEMP || !-d $TEMP ) { - print "Error: A temporary directory can not be find.\n"; - print "Check that TEMP or TMP environment variable is set correctly.\n"; - print "makepack-dolibarrlang.pl aborted.\n"; - sleep 2; - exit 2; -} -$BUILDROOT = "$TEMP/dolibarr-buildroot"; - -my $copyalreadydone = 0; -my $batch = 0; - -print "Makepack langs version $VERSION\n"; -print "Enter language code to package (en_US, fr_FR, ...) : "; -$PROJECT = ; -chomp($PROJECT); - -# Ask and set version $MAJOR and $MINOR -print "Enter value for version: "; -$PROJVERSION = ; -chomp($PROJVERSION); -( $MAJOR, $MINOR ) = split( /\./, $PROJVERSION, 2 ); -if ( $MINOR eq '' ) { - print "Enter value for minor version: "; - $MINOR = ; - chomp($MINOR); -} - -$FILENAME = "$PROJECT"; -$FILENAMETGZ = "lang_$PROJECT-$MAJOR.$MINOR"; -if ( -d "/usr/src/redhat" ) { - - # redhat - $RPMDIR = "/usr/src/redhat"; -} -if ( -d "/usr/src/RPM" ) { - - # mandrake - $RPMDIR = "/usr/src/RPM"; -} - -$SOURCE = "$DIR/../../dolibarr"; -$DESTI = "$SOURCE/build"; - -# Choose package targets -#----------------------- -$target = "ZIP"; # Les langs sont au format zip -if ($target) { - $CHOOSEDTARGET{ uc($target) } = 1; -} -else { - my $found = 0; - my $NUM_SCRIPT; - while ( !$found ) { - my $cpt = 0; - printf( " %d - %3s (%s)\n", - $cpt, "All", "Need " . join( ",", values %REQUIREMENTTARGET ) ); - foreach my $target (@LISTETARGET) { - $cpt++; - printf( " %d - %3s (%s)\n", - $cpt, $target, "Need " . $REQUIREMENTTARGET{$target} ); - } - - # Are asked to select the file to move - print "Choose one package number or several separated with space: "; - $NUM_SCRIPT = ; - chomp($NUM_SCRIPT); - if ( $NUM_SCRIPT =~ s/-//g ) { - - # Do not do copy - $copyalreadydone = 1; - } - if ( $NUM_SCRIPT !~ /^[0-$cpt\s]+$/ ) { - print "This is not a valid package number list.\n"; - $found = 0; - } - else { - $found = 1; - } - } - print "\n"; - if ($NUM_SCRIPT) { - foreach my $num ( split( /\s+/, $NUM_SCRIPT ) ) { - $CHOOSEDTARGET{ $LISTETARGET[ $num - 1 ] } = 1; - } - } - else { - foreach my $key (@LISTETARGET) { - $CHOOSEDTARGET{$key} = 1; - } - } -} - -# Test if requirement is ok -#-------------------------- -foreach my $target ( keys %CHOOSEDTARGET ) { - foreach my $req ( split( /[,\s]/, $REQUIREMENTTARGET{$target} ) ) { - - # Test - print "Test requirement for target $target: Search '$req'... "; - $ret = `"$req" 2>&1`; - $coderetour = $?; - $coderetour2 = $coderetour >> 8; - if ( - $coderetour != 0 - && ( ( $coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i ) - || ( $coderetour2 == 127 && $OS !~ /windows/ ) ) - && $PROGPATH - ) - { - - # Not found error, we try in PROGPATH - $ret = `"$PROGPATH/$ALTERNATEPATH{$req}/$req\" 2>&1`; - $coderetour = $?; - $coderetour2 = $coderetour >> 8; - $REQUIREMENTTARGET{$target} = "$PROGPATH/$ALTERNATEPATH{$req}/$req"; - } - - if ( - $coderetour != 0 - && ( ( $coderetour2 == 1 && $OS =~ /windows/ && $ret !~ /Usage/i ) - || ( $coderetour2 == 127 && $OS !~ /windows/ ) ) - ) - { - - # Not found error - print -"Not found\nCan't build target $target. Requirement '$req' not found in PATH\n"; - $CHOOSEDTARGET{$target} = -1; - last; - } - else { - - # Pas erreur ou erreur autre que programme absent - print " Found " . $REQUIREMENTTARGET{$target} . "\n"; - } - } -} - -print "\n"; - -# Check if there is at least on target to build -#---------------------------------------------- -$nboftargetok = 0; -foreach my $target ( keys %CHOOSEDTARGET ) { - if ( $CHOOSEDTARGET{$target} < 0 ) { next; } - $nboftargetok++; -} - -if ($nboftargetok) { - - # Update buildroot - #----------------- - if ( !$copyalreadydone ) { - print "Delete directory $BUILDROOT\n"; - $ret = `rm -fr "$BUILDROOT"`; - mkdir "$BUILDROOT"; - mkdir "$BUILDROOT/htdocs"; - mkdir "$BUILDROOT/htdocs/langs"; - mkdir "$BUILDROOT/htdocs/langs/$PROJECT"; - - print "Copy $SOURCE into $BUILDROOT\n"; - mkdir "$BUILDROOT"; - $ret = - `cp -pr "$SOURCE/htdocs/langs/$PROJECT" "$BUILDROOT/htdocs/langs"`; - } - print "Clean $BUILDROOT\n"; - $ret = -`rm -fr $BUILDROOT/htdocs/langs/$PROJECT/Thumbs.db $BUILDROOT/htdocs/langs/$PROJECT/*/Thumbs.db $BUILDROOT/htdocs/langs/$PROJECT/*/*/Thumbs.db $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/Thumbs.db`; - $ret = -`rm -fr $BUILDROOT/htdocs/langs/$PROJECT/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/*/CVS* $BUILDROOT/htdocs/langs/$PROJECT/*/*/*/*/*/CVS*`; - - # Build package for each target - #------------------------------ - foreach my $target ( keys %CHOOSEDTARGET ) - { - if ( $CHOOSEDTARGET{$target} < 0 ) { next; } - - print "\nBuild package for target $target\n"; - - if ( $target eq 'TGZ' ) - { - unlink $FILENAMETGZ . tgz; - - # unlink $BUILDROOT/$FILENAMETGZ.tgz; - print "Compress $BUILDROOT/htdocs into $FILENAMETGZ.tgz...\n"; - $cmd = -"tar --exclude-vcs --exclude-from \"$DESTI/tgz/tar.exclude\" --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$FILENAMETGZ.tgz\" htdocs"; - $ret = `$cmd`; - -# $cmd="tar --exclude-vcs --exclude-from \"$DESTI/tgz/tar.exclude\" --directory \"$BUILDROOT\" --mode=go-w --group=500 --owner=500 -czvf \"$BUILDROOT/$FILENAMETGZ.tgz\" htdocs\n"; -# $ret=`$cmd`; - if ( $OS =~ /windows/i ) { - print "Move $FILENAMETGZ.tgz to $DESTI/$FILENAMETGZ.tgz\n"; - $ret = `mv "$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`; - - # $ret=`mv "$BUILDROOT/$FILENAMETGZ.tgz" "$DESTI/$FILENAMETGZ.tgz"`; - } - next; - } - - if ( $target eq 'ZIP' ) - { - unlink $FILENAMEZIP . zip; - print "Compress $FILENAMETGZ into $FILENAMEZIP.zip...\n"; - chdir("$BUILDROOT"); - -#print "cd $BUILDROOTNT & 7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*\n"; -#$ret=`cd $BUILDROOTNT & 7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*`; - $ret = - `7z a -r -tzip -mx $BUILDROOT/$FILENAMEZIP.zip $FILENAMETGZ\\*.*`; - print "Move $FILENAMEZIP.zip to $DESTI\n"; - rename( "$BUILDROOT/$FILENAMEZIP.zip", "$DESTI/$FILENAMEZIP.zip" ); - next; - } - } -} - -print "\n----- Summary -----\n"; -foreach my $target ( keys %CHOOSEDTARGET ) { - if ( $CHOOSEDTARGET{$target} < 0 ) { - print "Package $target not built (bad requirement).\n"; - } - else { - print "Package $target built succeessfully in $DESTI\n"; - } -} - -if ( !$btach ) { - print "\nPress key to finish..."; - my $WAITKEY = ; -} - -0; From a518a7256ce8729748dc74c40e46722caa846bdb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Aug 2014 11:17:38 +0200 Subject: [PATCH 077/123] maj copyright --- build/exe/doliwamp/doliwamp.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 0037e091973..da727786896 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -32,7 +32,7 @@ AppPublisherURL=http://www.nltechno.com AppSupportURL=http://www.dolibarr.org AppUpdatesURL=http://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares. -AppCopyright=Copyright (C) 2008-2013 Laurent Destailleur, NLTechno +AppCopyright=Copyright (C) 2008-2014 Laurent Destailleur, NLTechno DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING From 4fe83ebbf908a23a6a4730a4bafefa4c96d55d62 Mon Sep 17 00:00:00 2001 From: Damian Serrano Thode Date: Fri, 29 Aug 2014 11:34:07 +0200 Subject: [PATCH 078/123] 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 5dc35ec13769392e795623a8084c2b316e2d3bed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Aug 2014 20:25:54 +0200 Subject: [PATCH 079/123] Fix: Missing field tobuy into service export. Fix: Filter on date into export. Fix: Tooltip help. --- htdocs/core/modules/modProduct.class.php | 1 + htdocs/core/modules/modService.class.php | 9 +++++---- htdocs/exports/export.php | 6 ++++-- htdocs/langs/en_US/exports.lang | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 05c934a8ea6..87dbc3e6dde 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -219,6 +219,7 @@ class modProduct extends DolibarrModules 'pr.price_min'=>"MinPriceHT",'pr.price_min_ttc'=>"MinPriceTTC", 'pr.tva_tx'=>'VATRate', 'pr.date_price'=>'DateCreation'); + //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", 'pr.price_ttc'=>"product", diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index cd4823d7eab..363fcaf6467 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -137,13 +137,13 @@ class modService extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock')); //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Number')); + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Number')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); - $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); + $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service')); if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service')); // Add extra fields @@ -182,6 +182,7 @@ class modService extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); + //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", 'pr.price_ttc'=>"product", diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 8ac1f6e6d48..45e78b2ecd3 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -839,7 +839,8 @@ if ($step == 4 && $datatoexport) if (isset($objexport->array_export_fields[0][$code])) { $list.=($list?', ':''); - $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; + if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/',$array_filtervalue[$code])) $list.=$langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code])?$array_filtervalue[$code]:''); + else $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; } } } @@ -1070,7 +1071,8 @@ if ($step == 5 && $datatoexport) if (isset($objexport->array_export_fields[0][$code])) { $list.=($list?', ':''); - $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; + if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/',$array_filtervalue[$code])) $list.=$langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code])?$array_filtervalue[$code]:''); + else $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; } } } diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 79d5bec834f..d396746ccad 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -125,7 +125,7 @@ BankAccountNumber=Account number BankAccountNumberKey=Key SpecialCode=Special code ExportStringFilter=%% allows replacing one or more characters in the text -ExportDateFilter='YYYY' 'YYYYMM' 'YYYYMMDD': filters by one year/month/day
'YYYY+YYYY' 'YYYYMM+YYYYMM' 'YYYYMMDD+YYYYMMDD': filters over a range of years/months/days
'>YYYY' '>YYYYMM' '>YYYYMMDD': filters on the following years/months/days
'<YYYY' '<YYYYMM' '<YYYYMMDD': filters on the previous years/months/days +ExportDateFilter=YYYY, YYYYMM, YYYYMMDD : filters by one year/month/day
YYYY+YYYY, YYYYMM+YYYYMM, YYYYMMDD+YYYYMMDD : filters over a range of years/months/days
> YYYY, > YYYYMM, > YYYYMMDD : filters on all following years/months/days
< YYYY, < YYYYMM, < YYYYMMDD : filters on all previous years/months/days ExportNumericFilter='NNNNN' filters by one value
'NNNNN+NNNNN' filters over a range of values
'>NNNNN' filters by lower values
'>NNNNN' filters by higher values ## filters SelectFilterFields=If you want to filter on some values, just input values here. From 47339d0e6202762b987f82c9d6f788eaef5405bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Aug 2014 20:25:54 +0200 Subject: [PATCH 080/123] Fix: Missing field tobuy into service export. Fix: Filter on date into export. Fix: Tooltip help. --- htdocs/core/modules/modProduct.class.php | 1 + htdocs/core/modules/modService.class.php | 9 +++++---- htdocs/exports/export.php | 6 ++++-- htdocs/langs/en_US/exports.lang | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 05c934a8ea6..87dbc3e6dde 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -219,6 +219,7 @@ class modProduct extends DolibarrModules 'pr.price_min'=>"MinPriceHT",'pr.price_min_ttc'=>"MinPriceTTC", 'pr.tva_tx'=>'VATRate', 'pr.date_price'=>'DateCreation'); + //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", 'pr.price_ttc'=>"product", diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 2b9bb8d44f8..13fe1ed47d5 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -137,13 +137,13 @@ class modService extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock')); //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Number')); + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Number')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); - $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); + $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'service')); if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'service')); // Add extra fields @@ -182,6 +182,7 @@ class modService extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); + //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", 'pr.price_ttc'=>"product", diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index d244a209b92..a6d82b10a86 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -840,7 +840,8 @@ if ($step == 4 && $datatoexport) if (isset($objexport->array_export_fields[0][$code])) { $list.=($list?', ':''); - $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; + if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/',$array_filtervalue[$code])) $list.=$langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code])?$array_filtervalue[$code]:''); + else $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; } } } @@ -1071,7 +1072,8 @@ if ($step == 5 && $datatoexport) if (isset($objexport->array_export_fields[0][$code])) { $list.=($list?', ':''); - $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; + if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/',$array_filtervalue[$code])) $list.=$langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code])?$array_filtervalue[$code]:''); + else $list.=$langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code])?$array_filtervalue[$code]:'')."'"; } } } diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 79d5bec834f..d396746ccad 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -125,7 +125,7 @@ BankAccountNumber=Account number BankAccountNumberKey=Key SpecialCode=Special code ExportStringFilter=%% allows replacing one or more characters in the text -ExportDateFilter='YYYY' 'YYYYMM' 'YYYYMMDD': filters by one year/month/day
'YYYY+YYYY' 'YYYYMM+YYYYMM' 'YYYYMMDD+YYYYMMDD': filters over a range of years/months/days
'>YYYY' '>YYYYMM' '>YYYYMMDD': filters on the following years/months/days
'<YYYY' '<YYYYMM' '<YYYYMMDD': filters on the previous years/months/days +ExportDateFilter=YYYY, YYYYMM, YYYYMMDD : filters by one year/month/day
YYYY+YYYY, YYYYMM+YYYYMM, YYYYMMDD+YYYYMMDD : filters over a range of years/months/days
> YYYY, > YYYYMM, > YYYYMMDD : filters on all following years/months/days
< YYYY, < YYYYMM, < YYYYMMDD : filters on all previous years/months/days ExportNumericFilter='NNNNN' filters by one value
'NNNNN+NNNNN' filters over a range of values
'>NNNNN' filters by lower values
'>NNNNN' filters by higher values ## filters SelectFilterFields=If you want to filter on some values, just input values here. From 1a7c88751c163417a989bbbdd47512f52e8e05ea Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 05:19:48 +0200 Subject: [PATCH 081/123] Correct travis --- htdocs/core/lib/accounting.lib.php | 39 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index e11aa0770b2..e1c853b057c 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -18,16 +18,15 @@ */ /** - * \file accountingex/core/lib/account.lib.php - * \ingroup Accounting Expert - * \brief Ensemble de fonctions de base pour les comptes comptables + * \file htdocs/core/lib/account.lib.php + * \ingroup Accounting Expert + * \brief Library of accountancy functions */ /** - * Prepare array with list of tabs + * Prepare array with list of admin tabs * - * @param Object $object to tabs - * @return array of tabs to shoc + * @return array Array of tabs to show */ function admin_accounting_prepare_head($object) { global $langs, $conf; @@ -64,8 +63,7 @@ function admin_accounting_prepare_head($object) { /** * Prepare array with list of tabs * - * @param Object $object to tabs - * @return array of tabs to shoc + * @return array Array of tabs to show */ function accounting_prepare_head($object) { global $langs, $conf; @@ -90,14 +88,13 @@ function accounting_prepare_head($object) { } /** - * Return general account with defined length + * Return general accounting account with defined length * - * @param $account - * - * @return $account + * @param string $account Accounting account + * @return string String with defined length */ function length_accountg($account) { - global $conf, $langs; + global $conf; $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT; @@ -122,11 +119,10 @@ function length_accountg($account) { } /** - * Return auxiliary account with defined length + * Return auxiliary accounting account with defined length * - * @param $account - * - * @return $account + * @param string $account Accounting account + * @return string String with defined length */ function length_accounta($accounta) { global $conf, $langs; @@ -153,6 +149,15 @@ function length_accounta($accounta) { } } +/** + * Return accounting account with defined length for Sage Export Software + * + * @param string $txt Accounting account + * @param int $len Length + * @param int $end Number of characters + * + * @return string Formated string + */ /** * Return account with defined length for Sage export software * From b25db97c2815dc574e5faf2e960d90e899184e0b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 05:30:37 +0200 Subject: [PATCH 082/123] 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 cc9f26a0352661529c0818ad7c4866cd885953c6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 05:44:12 +0200 Subject: [PATCH 083/123] Correct travis --- htdocs/core/lib/accounting.lib.php | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index e1c853b057c..a030d96224f 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -18,17 +18,18 @@ */ /** - * \file htdocs/core/lib/account.lib.php - * \ingroup Accounting Expert - * \brief Library of accountancy functions + * \file htdocs/core/lib/account.lib.php + * \ingroup Accounting Expert + * \brief Library of accountancy functions */ /** - * Prepare array with list of admin tabs + * Prepare array with list of admin tabs * - * @return array Array of tabs to show + * @return array Array of tabs to show */ -function admin_accounting_prepare_head($object) { +function admin_accounting_prepare_head() +{ global $langs, $conf; $h = 0; @@ -61,17 +62,19 @@ function admin_accounting_prepare_head($object) { } /** - * Prepare array with list of tabs + * Prepare array with list of tabs * - * @return array Array of tabs to show + * @param Object $object Accounting account + * @return array Array of tabs to show */ -function accounting_prepare_head($object) { +function accounting_prepare_head($object) +{ global $langs, $conf; $h = 0; $head = array (); - $head[$h][0] = dol_buildpath('/accountancy/admin/fiche.php', 1) . '?id=' . $object->id; + $head[$h][0] = dol_buildpath('/accountancy/admin/card.php', 1) . '?id=' . $object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h ++; @@ -93,7 +96,8 @@ function accounting_prepare_head($object) { * @param string $account Accounting account * @return string String with defined length */ -function length_accountg($account) { +function length_accountg($account) +{ global $conf; $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT; @@ -124,7 +128,8 @@ function length_accountg($account) { * @param string $account Accounting account * @return string String with defined length */ -function length_accounta($accounta) { +function length_accounta($accounta) +{ global $conf, $langs; $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT; @@ -158,14 +163,8 @@ function length_accounta($accounta) { * * @return string Formated string */ -/** - * Return account with defined length for Sage export software - * - * @param $account - * - * @return $account - */ -function length_exportsage($txt, $len, $end) { +function length_exportsage($txt, $len, $end) +{ // $txt = utf8_decode($txt); // problem with this function, but we need to have the number of letter if (strlen($txt) == $len) { From d6b2cb0b31d386f1373b632dde6c6cf1227590bf Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 06:05:02 +0200 Subject: [PATCH 084/123] Correct travis --- htdocs/accountancy/journal/bankjournal.php | 4 +--- htdocs/accountancy/journal/cashjournal.php | 4 +--- htdocs/accountancy/journal/purchasesjournal.php | 4 +--- htdocs/accountancy/journal/sellsjournal.php | 4 +--- htdocs/core/lib/accounting.lib.php | 4 ++-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 01a925cdeac..259dc35a5b0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -478,9 +478,7 @@ if ($action == 'export_csv') { $builddate = time(); $description = $langs->trans("DescBankJournal") . '
'; $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' => '' - )); + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); print ''; diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php index 72a9e79140e..1eee5de5fb5 100644 --- a/htdocs/accountancy/journal/cashjournal.php +++ b/htdocs/accountancy/journal/cashjournal.php @@ -464,9 +464,7 @@ if ($action == 'export_csv') { $builddate = time(); $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' => '' - )); + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); print ''; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index daf3b4d0532..bcb45646f14 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -372,9 +372,7 @@ if ($action == 'export_csv') { else $description .= $langs->trans("DepositsAreIncluded"); $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' => '' - )); + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); print ''; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 40b4377e7af..09cbe5924aa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -378,9 +378,7 @@ if ($action == 'export_csv') { else $description .= $langs->trans("DepositsAreIncluded"); $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' => '' - )); + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); print ''; diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index a030d96224f..e7313c73aee 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -93,7 +93,7 @@ function accounting_prepare_head($object) /** * Return general accounting account with defined length * - * @param string $account Accounting account + * @param string $account General accounting account * @return string String with defined length */ function length_accountg($account) @@ -125,7 +125,7 @@ function length_accountg($account) /** * Return auxiliary accounting account with defined length * - * @param string $account Accounting account + * @param string $accounta Auxiliary accounting account * @return string String with defined length */ function length_accounta($accounta) From 74ef9d5c59f224c63e05e239e2a66bc7a2056d8a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 06:22:18 +0200 Subject: [PATCH 085/123] Changelog --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index e7c05ea3295..c9af73628a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -64,6 +64,9 @@ For users: - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message - Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe. +New experimental module: +- New: Module Accounting Expert to manage accountancy + For translators: - Update language files. - New: When a translation is not available we always jump to en_US and only en_US. From 6bad77d8fb8d737a4979fa6d825ac1baf27424b8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 06:46:42 +0200 Subject: [PATCH 086/123] Move script --- .../accountancy/export-thirdpartyaccount.php | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) rename htdocs/accountancy/admin/thirdpartyaccount.php => scripts/accountancy/export-thirdpartyaccount.php (92%) diff --git a/htdocs/accountancy/admin/thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php similarity index 92% rename from htdocs/accountancy/admin/thirdpartyaccount.php rename to scripts/accountancy/export-thirdpartyaccount.php index 7c4745aac86..7fb4a7c56e0 100644 --- a/htdocs/accountancy/admin/thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -18,25 +18,14 @@ */ /** - * \file htdocs/accountancy/admin/thirdpartyaccount.php + * \file htdocs/accountancy/admin/export-thirdpartyaccount.php * \ingroup Accounting Expert - * \brief Onglet de gestion de parametrages des ventilations + * \brief Page to detect empty accounting account */ -// Dolibarr environment -$res = @include ("../main.inc.php"); -if (! $res && file_exists("../main.inc.php")) - $res = @include ("../main.inc.php"); -if (! $res && file_exists("../../main.inc.php")) - $res = @include ("../../main.inc.php"); -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"); +require_once($path."../../htdocs/master.inc.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("companies"); $langs->load("compta"); @@ -47,7 +36,7 @@ $langs->load("accountancy"); if (!$user->admin) accessforbidden(); - // Date range +// Date range $year = GETPOST("year"); if (empty($year)) { $year_current = strftime("%Y", dol_now()); @@ -124,10 +113,11 @@ print ' - function launch_export() { + function launch_export() + { $("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv"); $("div.fiche div.tabBar form input[type=\"submit\"]").click(); - $("div.fiche div.tabBar form input[name=\"action\"]").val(""); + $("div.fiche div.tabBar form input[name=\"action\"]").val(); } '; From d3a14c514a6281ec85b9dd95f84191d9a6b098f6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 07:11:28 +0200 Subject: [PATCH 087/123] Correct travis --- .../class/html.formventilation.class.php | 87 +++++++++++-------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index d6f5ce17404..e9d65943eac 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -18,30 +18,35 @@ */ /** - * \file htdocs/accountancy/class/html.formventilation.class.php - * \ingroup Accounting Expert - * \brief Class for HML form + * \file htdocs/accountancy/class/html.formventilation.class.php + * \ingroup Accounting Expert + * \brief File of class with all html predefined components */ -class FormVentilation extends Form { + +/** + * Class to manage generation of HTML components for bank module + */ +class FormVentilation extends Form +{ var $db; var $error; /** - * Constructor - * - * @param DoliDB $db handler - */ - function __construct($db) { - $this->db = $db; - return 1; - } - + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + /** - * Return select filter with date of transaction + * Return select filter with date of transaction * - * @param string $htmlname of input - * @param string $selectedkey value - * @return string select input + * @param string $htmlname Name of select field + * @param string $selectedkey Value + * @return string HTML edit field */ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey) { global $langs; @@ -83,15 +88,17 @@ class FormVentilation extends Form { } /** - * Return list of the accounts with label + * Return list of accounts with label by chart of accounts * - * @param string $selectedid pcg_type - * @param string $htmlname of combo list - * @param int $showempty en empty line - * - * @return string with HTML select + * @param string $selectedid Preselected chart of accounts + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $events Event options + * + * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) { + function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) + { global $conf, $user, $langs; $out = ''; @@ -142,15 +149,17 @@ class FormVentilation extends Form { } /** - * Return list of pcg with label + * Return list of accounts with label by class of accounts * - * @param string $selectedid pcg_type - * @param string $htmlname of combo list - * @param int $showempty en empty line - * - * @return string with HTML select + * @param string $selectedid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $events Event options + * + * @return string String with HTML select */ - function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) { + function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) + { global $conf, $user, $langs; $out = ''; @@ -194,15 +203,17 @@ class FormVentilation extends Form { } /** - * Return subtype list of pcg with label + * Return list of accounts with label by sub_class of accounts * - * @param string $selectedid pcg_type - * @param string $htmlname of combo list - * @param int $showempty en empty line - * - * @return string with HTML select + * @param string $selectedid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $events Event options + * + * @return string String with HTML select */ - function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) { + function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) + { global $conf, $user, $langs; $out = ''; From 3b8a3ccb142845dc71552793072f169287421be7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 30 Aug 2014 07:37:01 +0200 Subject: [PATCH 088/123] Correct travis --- .../class/html.formventilation.class.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index e9d65943eac..b6d49e0c36a 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -48,12 +48,13 @@ 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 = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; $out = '
'; - if ($user->rights->accountingex->admin) { + if ($user->admin) { print ''; print img_edit(); print ' '; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 68cdaf704a4..b2dfd751726 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -273,13 +273,13 @@ if ($action == 'create') { print '
'; - if ($user->rights->accountingex->admin) { + if ($user->admin) { print '' . $langs->trans('Modify') . ''; } else { print '' . $langs->trans('Modify') . ''; } - if ($user->rights->accountingex->admin) { + if ($user->admin) { print '' . $langs->trans('Delete') . ''; } else { print '' . $langs->trans('Delete') . ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f6a9f347dc0..ffb88af7658 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -44,7 +44,7 @@ $langs->load("accounting"); $id = GETPOST('id', 'int'); if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); $action = GETPOST('action'); @@ -320,7 +320,7 @@ if ($action == 'create') { print '
' . $line->sens . ''; - if ($user->rights->accountingex->access) { + if ($user->rights->accounting->access) { print ''; } print ''; @@ -335,7 +335,7 @@ if ($action == 'create') { print '' . $line->sens . ''; - if ($user->rights->accoutingex->access) { + if ($user->rights->accouting->access) { print ''; print img_edit(); print ' '; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 8c3a590b4b5..798d70e85ff 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -52,7 +52,7 @@ $account_parent = GETPOST('account_parent'); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountancy->access) +if (! $user->rights->accounting->access) accessforbidden(); $formventilation = new FormVentilation($db); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6444c8d5fbe..01a925cdeac 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -74,7 +74,7 @@ $action = GETPOST('action'); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); /* diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php index 0abd1c95cd3..72a9e79140e 100644 --- a/htdocs/accountancy/journal/cashjournal.php +++ b/htdocs/accountancy/journal/cashjournal.php @@ -71,7 +71,7 @@ $date_endyear = GETPOST('date_endyear'); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); $action = GETPOST('action'); diff --git a/htdocs/accountancy/journal/index.php b/htdocs/accountancy/journal/index.php index 254c98a9fb8..74d85467212 100644 --- a/htdocs/accountancy/journal/index.php +++ b/htdocs/accountancy/journal/index.php @@ -45,7 +45,7 @@ $langs->load("accountancy"); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); llxHeader('', 'Journaux', ''); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 83f4fcbf88e..daf3b4d0532 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -64,7 +64,7 @@ $date_endyear = GETPOST('date_endyear'); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); $action = GETPOST('action'); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index fc7b57509ac..40b4377e7af 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -65,7 +65,7 @@ $date_endyear = GETPOST('date_endyear'); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); $action = GETPOST('action'); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 1273ff8660c..4283b088d15 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -53,7 +53,7 @@ $langs->load("accountancy"); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); $formventilation = new FormVentilation($db); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index de6914b1fdc..3f990eb0dfd 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -54,7 +54,7 @@ $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accountingex->access) +if (! $user->rights->accounting->access) accessforbidden(); $formventilation = new FormVentilation($db); diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 49d137a014f..ae525ccaa75 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -54,7 +54,7 @@ class modAccounting extends DolibarrModules $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); $this->special = 0; - $this->picto = 'accountingex@accountingex'; + $this->picto = 'accounting'; // Defined if the directory /mymodule/inc/triggers/ contains triggers or not // $this->triggers = 1; @@ -65,7 +65,7 @@ class modAccounting extends DolibarrModules ); // Config pages - $this->config_page_url = array('index.php@accounting'); + $this->config_page_url = array('index.php@accountancy'); // Dependencies $this->depends = array ("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled @@ -77,10 +77,10 @@ class modAccounting extends DolibarrModules ); // Minimum version of PHP required by module $this->need_dolibarr_version = array ( 3, - 4 + 6 ); // Minimum version of Dolibarr required by module $this->langfiles = array ( - "accountingex@accountingex" + "accountancy" ); // Constants @@ -182,11 +182,7 @@ class modAccounting extends DolibarrModules $this->tabs = array(); // Css - $this->module_parts = array ( - 'css' => array ( - '/accountingex/css/accountingex.css.php' - ) - ); + $this->module_parts = array (); // Boxes $this->boxes = array (); @@ -197,12 +193,37 @@ class modAccounting extends DolibarrModules $this->rights = array (); // Permission array used by this module $r = 0; - $this->rights[$r][0] = 150001; // Permission id (must not be already used) - $this->rights[$r][1] = 'Acces_module'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'access'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $r ++; + $this->rights[$r][0] = 50401; + $this->rights[$r][1] = 'Access_accountancy'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'access'; + $this->rights[$r][5] = ''; + $r++; + + $this->rights[$r][0] = 50411; + $this->rights[$r][1] = 'Lire les mouvements comptables'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvements'; + $this->rights[$r][5] = 'lire'; + $r++; + + $this->rights[$r][0] = 50412; + $this->rights[$r][1] = 'Creer/modifier/annuler les mouvements comptables'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvements'; + $this->rights[$r][5] = 'creer'; + $r++; + + $this->rights[$r][0] = 50420; + $this->rights[$r][1] = 'Lire CA, bilans, resultats, journaux, grands livres'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'comptarapport'; + $this->rights[$r][5] = 'lire'; + $r++; // Main menu entries $this->menus = array (); @@ -218,7 +239,7 @@ class modAccounting extends DolibarrModules 'langs' => 'accountingex@accountingex', 'position' => 100, 'perms' => '$user->rights->accountingex->access', - 'enabled' => '$conf->accountingexpert->enabled', + 'enabled' => '$conf->accounting->enabled', 'target' => '', 'user' => 0 ); From 6f8234dd60ac9bbbfe595e103754a97895c3547d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 Aug 2014 07:13:33 +0200 Subject: [PATCH 047/123] Update Eldy menu --- htdocs/core/menus/standard/eldy.lib.php | 24 +- htdocs/core/modules/modAccounting.class.php | 351 +------------------- 2 files changed, 30 insertions(+), 345 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b1e9ccffd52..0cc34ecb20e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -858,18 +858,22 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } } - // Compta simple - if (! empty($conf->comptabilite->enabled) && ($conf->global->MAIN_FEATURES_LEVEL >= 2)) - { - $newmenu->add("/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Dispatch"),0,$user->rights->compta->ventilation->lire, '', $mainmenu, 'ventil'); - if (empty($leftmenu) || $leftmenu=="ventil") $newmenu->add("/compta/ventilation/liste.php",$langs->trans("ToDispatch"),1,$user->rights->compta->ventilation->lire); - if (empty($leftmenu) || $leftmenu=="ventil") $newmenu->add("/compta/ventilation/lignes.php",$langs->trans("Dispatched"),1,$user->rights->compta->ventilation->lire); - } - - // Compta expert + // Accounting Expert if (! empty($conf->accounting->enabled)) { - + $langs->load("accountancy"); + + $newmenu->add("/accountancy/customer/index.php?leftmenu=ventil_customer",$langs->trans("CustomersVentilation"),0,$user->rights->accounting->ventilation->read, '', $mainmenu, 'ventil_customer'); + if (empty($leftmenu) || $leftmenu=="ventil_customer") $newmenu->add("/accountancy/customer/list.php",$langs->trans("ToDispatch"),1,$user->rights->accounting->ventilation->read); + if (empty($leftmenu) || $leftmenu=="ventil_customer") $newmenu->add("/accountancy/customer/lines.php",$langs->trans("Dispatched"),1,$user->rights->accounting->ventilation->read); + + $newmenu->add("/accountancy/supplier/index.php?leftmenu=ventil_supplier",$langs->trans("SuppliersVentilation"),0,$user->rights->accounting->ventilation->read, '', $mainmenu, 'ventil_supplier'); + if (empty($leftmenu) || $leftmenu=="ventil_customer") $newmenu->add("/accountancy/supplier/list.php",$langs->trans("ToDispatch"),1,$user->rights->accounting->ventilation->read); + if (empty($leftmenu) || $leftmenu=="ventil_customer") $newmenu->add("/accountancy/supplier/lines.php",$langs->trans("Dispatched"),1,$user->rights->accounting->ventilation->read); + + $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping",$langs->trans("Bookkeeping"),0,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookeeping'); + if (empty($leftmenu) || $leftmenu=="bookeeping") $newmenu->add("/accountancy/bookkeeping/listbyyear.php",$langs->trans("ByYear"),1,$user->rights->accounting->mouvements->lire); + if (empty($leftmenu) || $leftmenu=="bookeeping") $newmenu->add("/accountancy/bookkeeping/balancebymonth.php.php",$langs->trans("AccountBalanceByMonth"),1,$user->rights->accounting->mouvements->lire); } // Rapports diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index ae525ccaa75..3d4174be73e 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -200,6 +200,22 @@ class modAccounting extends DolibarrModules $this->rights[$r][4] = 'access'; $this->rights[$r][5] = ''; $r++; + + $this->rights[$r][0] = 50402; + $this->rights[$r][1] = 'Read ventilation'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'ventilation'; + $this->rights[$r][5] = 'read'; + $r++; + + $this->rights[$r][0] = 50403; + $this->rights[$r][1] = 'Dispatched ventilation'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'ventilation'; + $this->rights[$r][5] = 'dispatch'; + $r++; $this->rights[$r][0] = 50411; $this->rights[$r][1] = 'Lire les mouvements comptables'; @@ -228,341 +244,6 @@ class modAccounting extends DolibarrModules // Main menu entries $this->menus = array (); $r = 0; - - $this->menu[$r] = array ( - 'fk_menu' => 0, - 'type' => 'top', - 'titre' => 'Accounting', - 'mainmenu' => 'accounting', - 'leftmenu' => '0', - 'url' => '/accountingex/customer/index.php', - 'langs' => 'accountingex@accountingex', - 'position' => 100, - 'perms' => '$user->rights->accountingex->access', - 'enabled' => '$conf->accounting->enabled', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting', - 'type' => 'left', - 'titre' => 'CustomersVentilation', - 'leftmenu' => 'CustomersVentilation', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/customer/index.php', - 'langs' => 'accountingex@accountingex', - 'position' => 101, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation', - 'type' => 'left', - 'titre' => 'ToDispatch', - 'leftmenu' => 'ToDispatchCustomer', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/customer/liste.php', - 'langs' => 'accountingex@accountingex', - 'position' => 102, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation', - 'type' => 'left', - 'titre' => 'Dispatched', - 'leftmenu' => 'DispatchedCustomer', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/customer/lignes.php', - 'langs' => 'accountingex@accountingex', - 'position' => 103, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting', - 'type' => 'left', - 'titre' => 'SuppliersVentilation', - 'leftmenu' => 'SuppliersVentilation', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/supplier/index.php', - 'langs' => 'accountingex@accountingex', - 'position' => 110, - 'enabled' => '$conf->fournisseur->enabled', - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation', - 'type' => 'left', - 'titre' => 'ToDispatch', - 'leftmenu' => 'ToDispatchSupplier', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/supplier/liste.php', - 'langs' => 'accountingex@accountingex', - 'position' => 111, - 'enabled' => '$conf->fournisseur->enabled', - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation', - 'type' => 'left', - 'titre' => 'Dispatched', - 'leftmenu' => 'DispatchedSupplier', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/supplier/lignes.php', - 'langs' => 'accountingex@accountingex', - 'position' => 112, - 'enabled' => '$conf->fournisseur->enabled', - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting', - 'type' => 'left', - 'titre' => 'Journaux', - 'leftmenu' => 'Journaux', - 'mainmenu' => 'accounting', - // 'url'=>'', - 'langs' => 'accountingex@accountingex', - 'position' => 120, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', - 'type' => 'left', - 'titre' => 'SellsJournal', - 'leftmenu' => 'SellsJournal', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/journal/sellsjournal.php', - 'langs' => 'accountingex@accountingex', - 'position' => 121, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', - 'type' => 'left', - 'titre' => 'PurchasesJournal', - 'leftmenu' => 'PurchasesJournal', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/journal/purchasesjournal.php', - 'langs' => 'accountingex@accountingex', - 'position' => 122, - 'enabled' => '$conf->fournisseur->enabled', - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', - 'type' => 'left', - 'titre' => 'CashJournal', - 'leftmenu' => 'CashJournal', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/journal/cashjournal.php', - 'langs' => 'accountingex@accountingex', - 'position' => 123, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux', - 'type' => 'left', - 'titre' => 'BankJournal', - 'leftmenu' => 'BankJournal', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/journal/bankjournal.php', - 'langs' => 'accountingex@accountingex', - 'position' => 200, - 'enabled' => '$conf->banque->enabled', - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting', - 'type' => 'left', - 'titre' => 'Bookkeeping', - 'leftmenu' => 'Bookkeeping', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/bookkeeping/liste.php', - 'langs' => 'accountingex@accountingex', - 'position' => 300, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping', - 'type' => 'left', - 'titre' => 'ByYear', - 'leftmenu' => 'ByYear', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/bookkeeping/listebyyear.php', - 'langs' => 'accountingex@accountingex', - 'position' => 301, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping', - 'type' => 'left', - 'titre' => 'AccountBalanceByMonth', - 'leftmenu' => 'AccountBalanceByMonth', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/bookkeeping/balancebymonth.php', - 'langs' => 'accountingex@accountingex', - 'position' => 302, - 'enabled' => 1, - 'perms' => 1, - 'target' => '', - 'user' => 0 - ); - $r ++; - - // Parameters Menu - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting', - 'type' => 'left', - 'titre' => 'Parameters', - 'leftmenu' => 'Parameters', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/admin/index.php', - 'langs' => 'accountingex@accountingex', - 'position' => 400, - 'enabled' => 1, - 'perms' => '$user->rights->accountingex->admin', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', - 'type' => 'left', - 'titre' => 'Globalparameters', - 'leftmenu' => 'Globalparameters', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/admin/index.php', - 'langs' => 'accountingex@accountingex', - 'position' => 401, - 'enabled' => 1, - 'perms' => '$user->rights->accountingex->admin', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters', - 'type' => 'left', - 'titre' => 'Chartofaccounts', - 'leftmenu' => 'Chartofaccounts', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/admin/account.php', - 'langs' => 'accountingex@accountingex', - 'position' => 402, - 'enabled' => 1, - 'perms' => '$user->rights->accountingex->admin', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters', - 'type' => 'left', - 'titre' => 'Menuaccount', - 'leftmenu' => 'Menuaccount', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/admin/account.php', - 'langs' => 'accountingex@accountingex', - 'position' => 403, - 'enabled' => 1, - 'perms' => '$user->rights->accountingex->admin', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', - 'type' => 'left', - 'titre' => 'Menuthirdpartyaccount', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/admin/thirdpartyaccount.php', - 'langs' => 'accountingex@accountingex', - 'position' => 404, - 'enabled' => 1, - 'perms' => '$user->rights->accountingex->admin', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters', - 'type' => 'left', - 'titre' => 'MenuTools', - 'mainmenu' => 'accounting', - 'url' => '/accountingex/admin/productaccount.php', - 'langs' => 'accountingex@accountingex', - 'position' => 405, - 'enabled' => 1, - 'perms' => '$user->rights->accountingex->admin', - 'target' => '', - 'user' => 0 - ); - $r ++; } /** From 9b3a3a47c284c682678fc15ddc3bd0610481545d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 Aug 2014 07:18:28 +0200 Subject: [PATCH 048/123] Add link chart of accounts in administration --- htdocs/accountancy/admin/account.php | 2 +- htdocs/core/menus/standard/empty.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 5aba91751e4..e3fd4da9dd1 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -52,7 +52,7 @@ if (!$user->admin) accessforbidden(); $sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortorder = GETPOST("sortorder", 'sortorder'); $limit = $conf->liste_limit; $page = GETPOST("page", 'int'); if ($page == - 1) { diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index a6063c84d18..74b195a1749 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -115,6 +115,7 @@ class MenuManager $this->menu->add("/admin/modules.php", $langs->trans("Modules"),1); $this->menu->add("/admin/menus.php", $langs->trans("Menus"),1); $this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); + $this->menu->add("/aaccountancy/account.php", $langs->trans("Chartofaccounts"),1); $this->menu->add("/admin/fiscalyear.php", $langs->trans("Fiscalyear"),1); $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); $this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1); From 84dff915c19ec9c4f2ac4c4d881c3fdc4e070487 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 Aug 2014 07:21:40 +0200 Subject: [PATCH 049/123] Typo --- htdocs/accountancy/bookkeeping/balancebymonth.php | 2 +- htdocs/accountancy/bookkeeping/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 7506ad27a39..e3ff328ca43 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -37,7 +37,7 @@ if (! $res) // Class dol_include_once("/core/lib/date.lib.php"); -dol_include_once("accountancy/core/lib/account.lib.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Langs $langs->load("main"); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index ffb88af7658..e4264ca9a2c 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -34,7 +34,7 @@ if (! $res && file_exists("../../../main.inc.php")) if (! $res) die("Include of main fails"); - // Class +// Class dol_include_once("accountancy/class/bookkeeping.class.php"); // Langs From bb45b8bbc5dbbc1ef5c352e4536e7360d15680de Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 Aug 2014 07:37:29 +0200 Subject: [PATCH 050/123] Typo & admin menu --- htdocs/core/menus/standard/eldy.lib.php | 1 + htdocs/core/menus/standard/empty.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 125bba1e656..de110ff126f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -501,6 +501,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto,1); $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"),1); $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"),1); + $newmenu->add("/accountancy/admin/account.php?mainmenu=home", $langs->trans("Chartofaccounts"),1); $newmenu->add("/admin/fiscalyear.php?mainmenu=home", $langs->trans("Fiscalyear"),1); if (! in_array($langs->defaultlang,array('en_US','en_GB','en_NZ','en_AU','fr_FR','fr_BE','es_ES','ca_ES'))) { diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 74b195a1749..d8b8d0f04cb 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -115,7 +115,7 @@ class MenuManager $this->menu->add("/admin/modules.php", $langs->trans("Modules"),1); $this->menu->add("/admin/menus.php", $langs->trans("Menus"),1); $this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); - $this->menu->add("/aaccountancy/account.php", $langs->trans("Chartofaccounts"),1); + $this->menu->add("/accountancy/admin/account.php", $langs->trans("Chartofaccounts"),1); $this->menu->add("/admin/fiscalyear.php", $langs->trans("Fiscalyear"),1); $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); $this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1); From a486b4e4157bf03525f6a8fcfc44e075b915a950 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 11:20:13 +0200 Subject: [PATCH 051/123] Fix error management: When an error is returned by hooks into dol_move_uploaded_file, message must be returned by function as if it were an error for any other reason. --- htdocs/core/lib/files.lib.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0dc5a2c4456..8590f63803f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -597,7 +597,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable global $conf, $db, $user, $langs; global $object, $hookmanager; - $error=0; + $reshook=0; $file_name = $dest_file; if (empty($nohook)) @@ -663,8 +663,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } // Security: - // On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans - // les noms de fichiers. + // On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file)) { dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING); @@ -677,7 +676,13 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable $reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object); } - if (empty($reshook)) + if ($reshook < 0) // At least one blocking error returned by one hook + { + $errmsg = join(',', $hookmanager->errors); + if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. + return $errmsg; + } + elseif (empty($reshook)) { // The file functions must be in OS filesystem encoding. $src_file_osencoded=dol_osencode($src_file); @@ -710,8 +715,8 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable return -3; // Unknown error } } - else - return $reshook; + + return 1; // Success } /** @@ -802,12 +807,12 @@ function dol_delete_dir($dir,$nophperrors=0) } /** - * Remove a directory $dir and its subdirectories (or only files and subdirectories) + * Remove a directory $dir and its subdirectories (or only files and subdirectories) * * @param string $dir Dir to delete * @param int $count Counter to count nb of deleted elements * @param int $nophperrors Disable all PHP output errors - * @param int $onlysub Delete only files and subdir, not main directory + * @param int $onlysub Delete only files and subdir, not main directory * @return int Number of files and directory removed */ function dol_delete_dir_recursive($dir,$count=0,$nophperrors=0,$onlysub=0) @@ -837,7 +842,7 @@ function dol_delete_dir_recursive($dir,$count=0,$nophperrors=0,$onlysub=0) } } closedir($handle); - + if (empty($onlysub)) { dol_delete_dir($dir,$nophperrors); From 338fc5f2f862f5f094d64bf0259ed15e8a7f8e0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 11:46:47 +0200 Subject: [PATCH 052/123] Fix: Bad unique key --- htdocs/install/mysql/tables/llx_c_type_resource.key.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql index 5a76ff0cfa6..68f5b74a42a 100644 --- a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql +++ b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql @@ -17,5 +17,5 @@ -- ======================================================================== -ALTER TABLE llx_c_type_contact ADD UNIQUE INDEX uk_c_type_contact_id (element, source, code); +ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (libelle, code); From dcce6731fec61b9dc554cd259e6cc8cedb128f98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 12:19:24 +0200 Subject: [PATCH 053/123] Fix: Sql errors --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index cbe07b2fbdf..b3a35bbfa6e 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -76,7 +76,7 @@ ALTER TABLE llx_societe ADD COLUMN localtax2_value double(6,3) after localtax2_a -- Change on table c_pays ALTER TABLE llx_c_pays RENAME TO llx_c_country; -ALTER TABLE llx_c_country CHANGE libelle label VARCHAR(50); +ALTER TABLE llx_c_country CHANGE COLUMN libelle label VARCHAR(50); ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_pays FOREIGN KEY (fk_pays) REFERENCES llx_c_country (rowid); ALTER TABLE llx_c_regions ADD CONSTRAINT fk_c_regions_fk_pays FOREIGN KEY (fk_pays) REFERENCES llx_c_country (rowid); @@ -978,13 +978,13 @@ CREATE TABLE llx_holiday_types ( -- Change on table c_civilite ALTER TABLE llx_c_civilite DROP INDEX uk_c_civilite; ALTER TABLE llx_c_civilite RENAME TO llx_c_civility; -ALTER TABLE llx_c_civility CHANGE civilite label VARCHAR(50); +ALTER TABLE llx_c_civility CHANGE COLUMN civilite label VARCHAR(50); ALTER TABLE llx_c_civility ADD UNIQUE INDEX uk_c_civility(code); -ALTER TABLE llx_adherent CHANGE civilite civility VARCHAR(6); -ALTER TABLE llx_socpeople CHANGE civilite civility VARCHAR(6); -ALTER TABLE llx_user CHANGE civilite civility VARCHAR(6); +ALTER TABLE llx_adherent CHANGE COLUMN civilite civility VARCHAR(6); +ALTER TABLE llx_socpeople CHANGE COLUMN civilite civility VARCHAR(6); +ALTER TABLE llx_user CHANGE COLUMN civilite civility VARCHAR(6); -ALTER TABLE llx_c_type_fees CHANGE libelle label VARCHAR(30); +ALTER TABLE llx_c_type_fees CHANGE COLUMN libelle label VARCHAR(30); ALTER TABLE llx_c_type_fees ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER label; ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_element (fk_element); From 4a91476be3f898b4a1df69cf555d60452bd482dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 12:26:43 +0200 Subject: [PATCH 054/123] Try cut and paste to solve pb on class project. --- htdocs/projet/class/project.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7f8fd52c500..750c4531cb0 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -53,6 +53,7 @@ class Project extends CommonObject var $statuts; var $oldcopy; + /** * Constructor * @@ -252,7 +253,7 @@ class Project extends CommonObject $result = 1; } else - { + { $this->db->rollback(); $result = -1; } From 911cccba80d0eaf047757cda68b5d08c189f0848 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 12:31:57 +0200 Subject: [PATCH 055/123] Disable rule FunctionDoubleUnderscore that seems to be bugged. --- dev/codesniffer/ruleset.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 6b498e7d167..72590c15741 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -243,6 +243,10 @@ + + + 0 + 0 @@ -253,13 +257,13 @@ 0 + 0 0 - From 8bdf02b340999d7b33b165cd185ce79ee3fb6f32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 14:48:16 +0200 Subject: [PATCH 056/123] Doxygen --- htdocs/fichinter/class/fichinter.class.php | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 80375648e26..49db958fa32 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -167,17 +167,17 @@ class Fichinter extends CommonObject $resql=$this->db->query($sql); if (! $resql) $error++; } - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - + $result=$this->insertExtraFields(); if ($result < 0) { $error++; } - } - + } + // Add linked object if (! $error && $this->origin && $this->origin_id) { @@ -864,11 +864,12 @@ class Fichinter extends CommonObject * @param string $desc Line description * @param date $date_intervention Intervention date * @param int $duration Intervention duration + * @param array $array_option Array option * @return int >0 if ok, <0 if ko */ - function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_option=0) + function addline($user,$fichinterid, $desc, $date_intervention, $duration, $array_option='') { - dol_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration"); + dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); if ($this->statut == 0) { @@ -887,15 +888,14 @@ class Fichinter extends CommonObject } $result=$line->insert($user); - + if ($result >= 0) { - $this->db->commit(); return 1; } else - { + { $this->error=$this->db->error(); $this->db->rollback(); return -1; @@ -1007,7 +1007,7 @@ class FichinterLigne extends CommonObjectLine public $element='fichinterdet'; public $table_element='fichinterdet'; public $fk_element='fk_fichinter'; - + /** * Constructor * @@ -1103,8 +1103,8 @@ class FichinterLigne extends CommonObjectLine $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet'); - + $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet'); + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $this->id=$this->rowid; @@ -1113,11 +1113,11 @@ class FichinterLigne extends CommonObjectLine { $error++; } - } - - + } + + $result=$this->update_total(); - + if ($result > 0) { $this->rang=$rangToUse; @@ -1175,7 +1175,7 @@ class FichinterLigne extends CommonObjectLine $resql=$this->db->query($sql); if ($resql) { - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $this->id=$this->rowid; @@ -1185,7 +1185,7 @@ class FichinterLigne extends CommonObjectLine $error++; } } - + $result=$this->update_total(); if ($result > 0) { From 22fb37f856796f7d14408f7902ae5483f29cc7c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 15:00:09 +0200 Subject: [PATCH 057/123] Fix: Sql syntax for extrafield table of interventions --- .../install/mysql/migration/3.6.0-3.7.0.sql | 18 +++++++------ .../llx_fichinterdet_extrafields.key.sql | 20 +++++++++++++++ .../tables/llx_fichinterdet_extrafields.sql | 25 +++++++++++++++++++ htdocs/install/pgsql/functions/functions.sql | 1 + 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_fichinterdet_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_fichinterdet_extrafields.sql diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index e018cabfe47..a2d168ed0fd 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -995,12 +995,14 @@ ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_d -- add extrafield on ficheinter lines -CREATE TABLE IF NOT EXISTS `llx_fichinterdet_extrafields` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `fk_object` int(11) NOT NULL, - `import_key` varchar(14) DEFAULT NULL, - PRIMARY KEY (`rowid`), - KEY `idx_ficheinter_extrafields` (`fk_object`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +CREATE TABLE llx_fichinterdet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb + +ALTER TABLE llx_fichinterdet_extrafields ADD INDEX idx_ficheinterdet_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_fichinterdet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_fichinterdet_extrafields.key.sql new file mode 100644 index 00000000000..e80db336c75 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_fichinterdet_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_fichinterdet_extrafields ADD INDEX idx_ficheinterdet_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_fichinterdet_extrafields.sql b/htdocs/install/mysql/tables/llx_fichinterdet_extrafields.sql new file mode 100644 index 00000000000..4c44e62e1db --- /dev/null +++ b/htdocs/install/mysql/tables/llx_fichinterdet_extrafields.sql @@ -0,0 +1,25 @@ +-- =================================================================== +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +CREATE TABLE llx_fichinterdet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 89395436c43..04d7b445499 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -83,6 +83,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_extrafields FOR EACH CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture_fourn FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_fichinter FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_fichinterdet_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_livraison FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_localtax FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_menu FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); From 3e2ed270e12f7bf0d879d109100de8b1821f4378 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 15:07:33 +0200 Subject: [PATCH 058/123] Fix: sql request with pgsql --- htdocs/compta/salaries/index.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 0a4a2d99943..b2fc3e1b4a3 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -71,8 +71,8 @@ $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type,"; -$sql.= " s.num_payment, pst.code as payment_code"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; +$sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; @@ -87,7 +87,7 @@ if ($filtre) { if ($typeid) { $sql .= " AND s.fk_typepayment=".$typeid; } -$sql.= " GROUP BY s.rowid, s.fk_typepayment, s.amount, s.datev, s.label"; +//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev, s.fk_typepayment, s.num_payment, pst.code"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); @@ -174,6 +174,7 @@ else } -$db->close(); llxFooter(); + +$db->close(); From d3a3e8786ec5b7c2665bb828f74902874c5d290d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 15:07:33 +0200 Subject: [PATCH 059/123] Fix: sql request with pgsql --- htdocs/compta/salaries/index.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index c7ee207f853..3567263e802 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -71,8 +71,8 @@ $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type,"; -$sql.= " s.num_payment, pst.code as payment_code"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; +$sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; @@ -87,7 +87,7 @@ if ($filtre) { if ($typeid) { $sql .= " AND s.fk_typepayment=".$typeid; } -$sql.= " GROUP BY s.rowid, s.fk_typepayment, s.amount, s.datev, s.label"; +//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev, s.fk_typepayment, s.num_payment, pst.code"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); @@ -176,6 +176,7 @@ else } -$db->close(); llxFooter(); + +$db->close(); From 1505ade3db5d8309813a5e9800b7680c076cd944 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Aug 2014 15:14:06 +0200 Subject: [PATCH 060/123] Fix error management: When an error is returned by hooks into dol_move_uploaded_file, message must be returned by function as if it were an error for any other reason. Conflicts: htdocs/core/lib/files.lib.php --- htdocs/core/lib/files.lib.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a6082fa0c29..c90e58f556c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -597,7 +597,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable global $conf, $db, $user, $langs; global $object, $hookmanager; - $error=0; + $reshook=0; $file_name = $dest_file; if (empty($nohook)) @@ -663,8 +663,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } // Security: - // On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans - // les noms de fichiers. + // On interdit fichiers caches, remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/^\./',$dest_file) || preg_match('/\.\./',$dest_file) || preg_match('/[<>|]/',$dest_file)) { dol_syslog("Refused to deliver file ".$dest_file, LOG_WARNING); @@ -677,7 +676,13 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable $reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object); } - if (empty($reshook)) + if ($reshook < 0) // At least one blocking error returned by one hook + { + $errmsg = join(',', $hookmanager->errors); + if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. + return $errmsg; + } + elseif (empty($reshook)) { // The file functions must be in OS filesystem encoding. $src_file_osencoded=dol_osencode($src_file); @@ -710,8 +715,8 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable return -3; // Unknown error } } - else - return $reshook; + + return 1; // Success } /** From 0e1f22fe26173cefb9f376f5d9ac3228adae754e Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 28 Aug 2014 15:16:14 +0200 Subject: [PATCH 061/123] Fix: Salary payments are not reflected on the reporting sheets --- ChangeLog | 1 + htdocs/compta/resultat/clientfourn.php | 64 ++++++++++++++++++++++++++ htdocs/compta/resultat/index.php | 39 ++++++++++++++++ 3 files changed, 104 insertions(+) diff --git a/ChangeLog b/ChangeLog index f92c959db50..dad4cb65c1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ For users: - Fix: sql errors on updat fichinter - Fix: debian script syntax error - Fix: error "menu param is not inside list" into pos module. +- Fix: Salary payments are not reflected on the reporting sheets ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d68aa528122..26589be3c5d 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * 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 @@ -538,6 +539,69 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti print '
'.$langs->trans("Salaries").'
 ".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."'.price(-$obj->amount).''.price(-$obj->amount).'
 '.$langs->trans("None").'
'.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
'.$langs->trans("Salaries").'
 ".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."'.price(-$obj->amount).''.price(-$obj->amount).'
 '.$langs->trans("None").'
'.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
"; 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 { From 1375e20fe22eba7a64d9af75ea541d7cff67fa68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 09:45:29 +0200 Subject: [PATCH 117/123] Fix: doxygen --- .../class/accountancyaccount.class.php | 95 ------------------- .../class/accountingaccount.class.php | 67 +++++++------ 2 files changed, 39 insertions(+), 123 deletions(-) delete mode 100644 htdocs/accountancy/class/accountancyaccount.class.php diff --git a/htdocs/accountancy/class/accountancyaccount.class.php b/htdocs/accountancy/class/accountancyaccount.class.php deleted file mode 100644 index 229bc79ba41..00000000000 --- a/htdocs/accountancy/class/accountancyaccount.class.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/accountancy/class/accountancyaccount.class.php - * \ingroup accounting - * \brief Fichier de la classe des comptes comptables - */ - - -/** - * \class AccountancyAccount - * \brief Classe permettant la gestion des comptes - */ -class AccountancyAccount -{ - var $db; - var $error; - - var $rowid; - var $fk_pcg_version; - var $pcg_type; - var $pcg_subtype; - var $label; - var $account_number; - var $account_parent; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } - - - /** - * Insert account into database - * - * @param User $user User making add - * @return int <0 if KO, Id line added if OK - */ - function create($user) - { - $now=dol_now(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount"; - $sql.= " (date_creation, fk_user_author, numero,intitule)"; - $sql.= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->numero."','".$this->intitule."')"; - - $resql = $this->db->query($sql); - if ($resql) - { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingaccount"); - - if ($id > 0) - { - $this->id = $id; - $result = $this->id; - } - else - { - $result = -2; - $this->error="AccountancyAccount::Create Erreur $result"; - dol_syslog($this->error, LOG_ERR); - } - } - else - { - $result = -1; - $this->error="AccountancyAccount::Create Erreur $result"; - dol_syslog($this->error, LOG_ERR); - } - - return $result; - } - -} diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 4c54e609caf..f39dde7cb81 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -43,21 +43,24 @@ class AccountingAccount var $active; /** - * \brief Constructeur de la classe - * \param DB handler acces base de donnees - * \param id id compte (0 par defaut) + * Constructor + * + * @param DoliDB $db Database handle */ - function __construct($db, $rowid = '') { + function __construct($db) + { $this->db = $db; - - if ($rowid != '') - return $this->fetch($rowid); } /** - * \brief Load record in memory + * Load record in memory + * + * @param int $rowid Id + * @param string $account_number Account number + * @return int <0 if KO, >0 if OK */ - function fetch($rowid = null, $account_number = null) { + function fetch($rowid = null, $account_number = null) + { if ($rowid || $account_number) { $sql = "SELECT * FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE "; if ($rowid) { @@ -93,10 +96,14 @@ class AccountingAccount } /** - * \brief insert line in accountingaccount - * \param user utilisateur qui effectue l'insertion + * Insert line in accountingaccount + * + * @param User $user Use making action + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) { + function create($user, $notrigger = 0) + { global $conf, $langs; $error = 0; @@ -192,10 +199,11 @@ class AccountingAccount /** * Update record * - * @param User $user update - * @return int if KO, >0 if OK + * @param User $user Use making update + * @return int <0 if KO, >0 if OK */ - function update($user) { + function update($user) + { global $langs; $this->db->begin(); @@ -227,10 +235,10 @@ class AccountingAccount /** * Check usage of accounting code * - * @param User $user update - * @return int if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function checkUsage() { + function checkUsage() + { global $langs; $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; @@ -259,11 +267,12 @@ class AccountingAccount /** * Delete object in database * - * @param User $user that deletes - * @param int $notrigger triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user User that deletes + * @param int $notrigger 0=triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) { + function delete($user, $notrigger = 0) + { global $conf, $langs; $error = 0; @@ -356,10 +365,11 @@ class AccountingAccount /** * Account desactivate * - * @param User $user update - * @return int if KO, >0 if OK + * @param int $id Id + * @return int <0 if KO, >0 if OK */ - function account_desactivate($id) { + function account_desactivate($id) + { global $langs; $result = $this->checkUsage(); @@ -390,10 +400,11 @@ class AccountingAccount /** * Account activate * - * @param User $user update - * @return int if KO, >0 if OK + * @param int $id Id + * @return int <0 if KO, >0 if OK */ - function account_activate($id) { + function account_activate($id) + { global $langs; $this->db->begin(); From ca322942aec803e9facdcf8b3c427bd4a0dd034e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 09:49:50 +0200 Subject: [PATCH 118/123] I remove the extend into commonobjectline to common object. For the moment, if we need a method for line already into object, i prefer to see method duplicated. --- htdocs/core/class/commonobjectline.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 3ba7cbf52ca..675e1cf0794 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -26,7 +26,7 @@ * Parent class for class inheritance lines of business objects * This class is useless for the moment so no inherit are done on it */ -abstract class CommonObjectLine extends CommonObject +abstract class CommonObjectLine { /** * Call trigger based on this instance From be0c7ba28f9d4da498f31a93e2918391e57c561e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 09:55:06 +0200 Subject: [PATCH 119/123] Fix: Bad title --- htdocs/core/lib/fichinter.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 7242a8e3bab..b8d2e87fdff 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -127,7 +127,7 @@ function fichinter_admin_prepare_head() $h++; $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][1] = $langs->trans("ExtraFieldsLines"); $head[$h][2] = 'attributesdet'; $h++; From be3f4587540cb09d7d7b54f40aba7ac73ebf6e46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 11:30:13 +0200 Subject: [PATCH 120/123] Fix: Pb with pgsql --- dev/skeletons/build_class_from_table.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 6acbc1feb35..0b2e96daaac 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -254,11 +254,11 @@ foreach($property as $key => $prop) $varprop.="\t\t\$sql.= \" "; if ($prop['istime']) { - $varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':$this->db->idate('; + $varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':"\'".$this->db->idate('; $varprop.="\$this->".$prop['field'].""; - $varprop.='))."'; + $varprop.=')."\'")."'; if ($i < count($property)) $varprop.=","; - $varprop.="\";"; + $varprop.='";'; } elseif ($prop['ischar']) { From 1eaf61542603032bbeabecb776c2507adcedfca3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 14:32:59 +0200 Subject: [PATCH 121/123] Fix: no br after title --- htdocs/compta/bank/index.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index c9b70e94257..fdac94091eb 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copytight (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -51,7 +51,6 @@ $link=''; if ($statut == '') $link=''.$langs->trans("IncludeClosedAccount").''; if ($statut == 'all') $link=''.$langs->trans("OnlyOpenedAccount").''; print_fiche_titre($langs->trans("AccountsArea"),$link); -print '
'; // On charge tableau des comptes financiers (ouverts par defaut) From 7021f4fb018aa647b53c05497cd8e621bb1494d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 16:09:14 +0200 Subject: [PATCH 122/123] Fix: Message show when dir is out of sync with database cache was wrong. --- htdocs/core/ajax/ajaxdirpreview.php | 2 +- htdocs/core/ajax/ajaxdirtree.php | 3 ++- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/ecm/class/ecmdirectory.class.php | 14 +++++++------- htdocs/ecm/tpl/enablefiletreeajax.tpl.php | 5 ++++- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 63641d00ab8..997e27adb20 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -207,7 +207,6 @@ if ($type == 'directory') if ($section === '0') { $filearray=array(); - $textifempty='
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; } else $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); @@ -216,6 +215,7 @@ if ($type == 'directory') $param.='§ion='.$section; $textifempty = $langs->trans('NoFileFound'); } + else if ($section === '0') $textifempty='
'.$langs->trans("DirNotSynchronizedSyncFirst").'

'; else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index b4ceaeaced1..ae70d1a418a 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -145,7 +145,8 @@ if (file_exists($fullpathselecteddir)) { if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) { - $val['fullrelativename']=$file; $val['id']=0; + $val['fullrelativename']=$file; + $val['id']=0; $val['label']=$file; $val['description']=''; $nboffilesinsubdir=$langs->trans("Unknown"); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7ffe021fe92..05a1e40b756 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -759,7 +759,7 @@ class FormFile if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $var=true; + $var=false; foreach($filearray as $key => $file) // filearray must be only files here { if ($file['name'] != '.' diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 52c698c240f..aae1e275d8f 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -154,7 +154,7 @@ class EcmDirectory // extends CommonObject // Call trigger $result=$this->call_trigger('MYECMDIR_CREATE',$user); - if ($result < 0) { $error++; } + if ($result < 0) { $error++; } // End call triggers if (! $error) @@ -219,7 +219,7 @@ class EcmDirectory // extends CommonObject { // Call trigger $result=$this->call_trigger('MYECMDIR_MODIFY',$user); - if ($result < 0) { $error++; } + if ($result < 0) { $error++; } // End call triggers } @@ -356,10 +356,10 @@ class EcmDirectory // extends CommonObject { $this->db->rollback(); return -2; - } + } // End call triggers } - + if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output . "/" . $relativepath; @@ -511,7 +511,7 @@ class EcmDirectory // extends CommonObject /** - * Reconstruit l'arborescence des categories sous la forme d'un tableau + * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: * id Id de la categorie * id_mere Id de la categorie mere @@ -693,7 +693,7 @@ class EcmDirectory // extends CommonObject return -1; } } - + /** * Call trigger based on this instance * @@ -725,6 +725,6 @@ class EcmDirectory // extends CommonObject return $result; } - + } diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index 301fa5f955b..b348cb03c72 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -42,7 +42,7 @@ $(document).ready(function() { }, // Called if we click on a dir (not a file) function(elem) { - id=elem.attr('id').substr(12); + id=elem.attr('id').substr(12); // We get id that is 'fmdirlia_id_xxx' (id we want is xxx) jQuery("#formuserfile_section_dir").val(elem.attr('rel')); jQuery("#formuserfile_section_id").val(id); jQuery('#formuserfile').show(); @@ -65,6 +65,9 @@ $(document).ready(function() { function loadandshowpreview(filedirname,section) { //alert('filedirname='+filedirname); + //console.log(filedirname); + //console.log(section); + $('#ecmfileview').empty(); var url = '?action=preview&module=ecm§ion='+section+'&file='+urlencode(filedirname); From b1b69336ae6e196c924bc94d51b0e348564f91be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Sep 2014 18:48:42 +0200 Subject: [PATCH 123/123] New: Add proposals into referer page of thirdparty --- ChangeLog | 1 + htdocs/societe/consumption.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6a076df6cfc..34ac811e0b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.7 compared to 3.6.* ***** For users: +- New: Add proposals into referer page of thirdparty. - New: On contact list can set filter on both active and not active (no more exclusive select). - New: Each user can include its own external ics calendar into dolibarr agenda view. - New: Intervention documents are now available in ECM module. diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 776ea1fd355..91453c877a7 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -131,8 +131,9 @@ if ($object->client) $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; $thirdTypeArray['customer']=$langs->trans("customer"); - if($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->trans('Invoices'); if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->trans('Orders'); + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->trans('Proposals'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->trans('Invoices'); } if ($object->fournisseur) @@ -177,6 +178,19 @@ if ($type_element == 'invoice') $doc_number='f.facnumber'; $thirdTypeSelect='customer'; } +if ($type_element == 'propal') +{ + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $documentstatic=new Propal($db); + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as datePrint, '; + $tables_from = MAIN_DB_PREFIX."propal as c,".MAIN_DB_PREFIX."propaldet as d"; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where.= " AND d.fk_propal = c.rowid"; + $where.= " AND c.entity = ".$conf->entity; + $datePrint = 'c.datep'; + $doc_number='c.ref'; + $thirdTypeSelect='customer'; +} if ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';