From 1baf25de3c279f3b2663238d7aecd0fc355cab07 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 27 Jan 2016 12:04:00 +0100 Subject: [PATCH 01/38] FIX ISSUE #4506 : make working the PROPAL_CLONE_ON_CREATE_PAGE hidden constant --- htdocs/comm/propal.php | 3 ++- htdocs/comm/propal/class/propal.class.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 08106bc2151..a637e4a87fa 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -293,7 +293,8 @@ if (empty($reshook)) $object->note = GETPOST('note'); $object->statut = 0; - $id = $object->create_from($user); + // the create is done below and further more the existing create_from function is quite hilarating + //$id = $object->create_from($user); } else { setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 372ac5d5a61..c7e4724d027 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -946,6 +946,7 @@ class Propal extends CommonObject */ function create_from($user) { + // i love this function because $this->products is not used in create function... $this->products=$this->lines; return $this->create($user); From 6260c1ae9e259f25d14cfc109ad4e6eed3184e37 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 3 Feb 2016 11:33:13 +0100 Subject: [PATCH 02/38] FIX: Check stock of batch on shippment --- htdocs/expedition/card.php | 3 ++- htdocs/expedition/class/expedition.class.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 3bf17f76a4f..c7d91a28ce5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -8,6 +8,7 @@ * Copyright (C) 2013 Marcos García * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Francis Appels + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -237,7 +238,7 @@ if (empty($reshook)) $ret=$object->addline_batch($batch_line[$i]); if ($ret < 0) { - $mesg='
'.$object->error.'
'; + $mesg='
'.$object->errorsToString().'
'; $error++; } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index cb77607261b..7dcf66d28ec 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2015 Francis Appels + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -857,6 +858,7 @@ class Expedition extends CommonObject */ function addline_batch($dbatch) { + global $conf,$langs; $num = count($this->lines); if ($dbatch['qty']>0) { @@ -882,7 +884,17 @@ class Expedition extends CommonObject if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { - // TODO + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $prod_batch = new Productbatch($this->db); + $prod_batch->fetch($value['id_batch']); + + if ($prod_batch->qty < $linebatch->dluo_qty) + { + $this->errors[] = $langs->trans('ErrorStockIsNotEnough'); + dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR); + $this->db->rollback(); + return -1; + } } //var_dump($linebatch); @@ -895,6 +907,7 @@ class Expedition extends CommonObject //var_dump($line); $this->lines[$num] = $line; + return 1; } } From ede4453164c2432d1145626a8c5a4cf9335d07e2 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Fri, 5 Feb 2016 12:59:32 +0100 Subject: [PATCH 03/38] Fix: Avoid errors when batch stock is negative --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index c7d91a28ce5..ea82a63732a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -882,7 +882,7 @@ if ($action == 'create') if ($defaultqty<=0) { $defaultqty=0; } else { - $defaultqty -= min($defaultqty,$substock); + $defaultqty -= ($substock > 0 ? min($defaultqty,$substock) : 0); } $subj++; } From 36c7697b63ef561f261853327fd0ef98aa49562f Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Feb 2016 13:43:06 +0100 Subject: [PATCH 04/38] FIX: retrieve correct pu_ttc (set by printObjectLine function) like in 3.7 --- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index d61831cfec2..7d570531213 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -124,7 +124,7 @@ $coldisplay=-1; // We remove first td if ($inputalsopricewithtax) { $coldisplay++; - print 'situation_counter > 1) print ' readonly'; print '>'; } From f0aef885893cd217904eddb63c7a907e76abed4b Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Feb 2016 13:49:19 +0100 Subject: [PATCH 05/38] better fix --- htdocs/core/class/commonobject.class.php | 4 +++- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1cf042e9d13..a78a1cfea49 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3051,6 +3051,8 @@ abstract class CommonObject $text.= ' - '.(! empty($line->label)?$line->label:$label); $description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. } + + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer @@ -3074,7 +3076,7 @@ abstract class CommonObject if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; else $placeholder=' title="'.$langs->trans("Label").'"'; - $pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 7d570531213..d61831cfec2 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -124,7 +124,7 @@ $coldisplay=-1; // We remove first td if ($inputalsopricewithtax) { $coldisplay++; - print 'situation_counter > 1) print ' readonly'; print '>'; } From bf7181a0640df531b033c507e501bb206392733f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Feb 2016 18:37:01 +0100 Subject: [PATCH 06/38] All messages separated with , into errorsToString --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c281d9bebbd..019be7fcc09 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -381,7 +381,7 @@ abstract class CommonObject */ function errorsToString() { - return $this->error.(is_array($this->errors)?(($this->error!=''?' ':'').join(',',$this->errors)):''); + return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); } /** From 7a6c7f10a6c14bcd93003a0e7ee29277d9d65535 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Feb 2016 19:14:40 +0100 Subject: [PATCH 07/38] FIX: add missing global def for ttc column --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 99e497046e0..704bc097db7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2540,7 +2540,7 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs,$user,$object,$hookmanager; + global $conf,$langs,$user,$object,$hookmanager,$inputalsopricewithtax; print ''; From c4c7ea2f221199b1566dad96c038d2f197184776 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Feb 2016 02:49:19 +0100 Subject: [PATCH 08/38] FIX Relative discount decimals are not saved --- htdocs/comm/remise.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 6d0d1dedb2a..224004b6735 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -30,6 +30,8 @@ $langs->load("companies"); $langs->load("orders"); $langs->load("bills"); +$id=GETPOST("id",'int'); + $socid = GETPOST('id','int'); // Security check if ($user->societe_id > 0) @@ -52,9 +54,9 @@ if (GETPOST('cancel') && ! empty($backtopage)) if (GETPOST("action") == 'setremise') { - $soc = New Societe($db); - $soc->fetch($_GET["id"]); - $result=$soc->set_remise_client($_POST["remise"],$_POST["note"],$user); + $soc = new Societe($db); + $soc->fetch($id); + $result=$soc->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user); if ($result > 0) { From a15d03a67644e0247a9efa00884a7c7d76c2a85f Mon Sep 17 00:00:00 2001 From: philippe grand Date: Mon, 8 Feb 2016 10:06:32 +0100 Subject: [PATCH 09/38] fix : Strict Standards: Only variables should be passed by reference --- htdocs/core/modules/modSociete.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index fb8623695e6..ab48d6807ec 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -297,7 +297,11 @@ class modSociete extends DolibarrModules case 'sellist': $tmp=''; $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); + if ($tmpparam['options'] && is_array($tmpparam['options'])) + { + $stack=array_keys($tmpparam['options']); + $tmp=array_shift($stack); + } if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; break; } From 29910840610a658e5fa8364e523bd039c84b73d0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 8 Feb 2016 10:50:40 +0100 Subject: [PATCH 10/38] fx accountancy --- htdocs/accountancy/journal/purchasesjournal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 86232bb2029..7d9778f72b8 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -94,6 +94,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 "; +$sql .= " AND fd.fk_code_ventilation > 0 "; if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } From 9b10f030bf5eb5143107a7a1ecea51ba4b3d5890 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 8 Feb 2016 12:20:40 +0100 Subject: [PATCH 11/38] Fix: missing signature and uniformize code between card and script --- htdocs/comm/mailing/card.php | 15 +++++++++------ scripts/emailings/mailing-send.php | 25 +++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e1d357b6c3a..dc17c68e387 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 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 @@ -222,6 +222,8 @@ if (empty($reshook)) $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = (!empty($user->signature))?$user->signature:''; + // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $substitutionarray=array( '__ID__' => $obj->source_id, @@ -234,6 +236,7 @@ if (empty($reshook)) '__OTHER3__' => $other3, '__OTHER4__' => $other4, '__OTHER5__' => $other5, + '__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter) '__CHECK_READ__' => '', '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' ); @@ -1093,10 +1096,10 @@ else } print ''; - + dol_fiche_end(); - - + + print "\n"; print '
'."\n"; @@ -1108,7 +1111,7 @@ else print_fiche_titre($langs->trans("EMail"),'',''); dol_fiche_head(); - + print ''; // Subject @@ -1175,7 +1178,7 @@ else print '
'; dol_fiche_end(); - + print '
'; print ''; print '     '; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 9896db73352..1c25d78ba55 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -1,8 +1,9 @@ #!/usr/bin/php - * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2016 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 @@ -141,15 +142,15 @@ if ($resql) $sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname) ." <".$obj2->email.">"); // Make subtsitutions on topic and body - $other=explode(';',$obj2->other); - $other1=$other[0]; - $other2=$other[1]; - $other3=$other[2]; - $other4=$other[3]; - $other5=$other[4]; - // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) - $signature = (!empty($user->signature))?$user->signature:''; - + $other=explode(';',$obj->other); + $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = (!empty($user->signature))?$user->signature:''; + + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, @@ -251,7 +252,7 @@ if ($resql) $error++; } } - + if (!empty($conf->global->MAILING_DELAY)) { sleep($conf->global->MAILING_DELAY); } From 0b2560130758506c8bc94e01bbc5138bc92a92d9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 8 Feb 2016 12:31:40 +0100 Subject: [PATCH 12/38] Fix: wrong object name --- htdocs/comm/mailing/card.php | 2 +- scripts/emailings/mailing-send.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index dc17c68e387..3bca65a3ee7 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -222,7 +222,7 @@ if (empty($reshook)) $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $signature = (!empty($user->signature))?$user->signature:''; + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $substitutionarray=array( diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 1c25d78ba55..8baf85ee5fe 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -142,18 +142,18 @@ if ($resql) $sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname) ." <".$obj2->email.">"); // Make subtsitutions on topic and body - $other=explode(';',$obj->other); + $other=explode(';',$obj2->other); $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $signature = (!empty($user->signature))?$user->signature:''; + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray=array( - '__ID__' => $obj->source_id, - '__EMAIL__' => $obj->email, + '__ID__' => $obj2->source_id, + '__EMAIL__' => $obj2->email, '__LASTNAME__' => $obj2->lastname, '__FIRSTNAME__' => $obj2->firstname, '__MAILTOEMAIL__' => ''.$obj2->email.'', From 5dd016c3bc2a12bdb76c8eaffe45756afb90367e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 8 Feb 2016 17:55:29 +0100 Subject: [PATCH 13/38] Update modOauth.class.php --- htdocs/core/modules/modOauth.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 0ccab13e2b5..dc19839011b 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -139,8 +139,8 @@ class modOauth extends DolibarrModules $this->remove($options); $sql = array( - "CREATE TABLE IF NOT EXISTS llx_oauth_state (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), state varchar(128), fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", - "CREATE TABLE IF NOT EXISTS llx_oauth_token (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), token text, fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."oauth_state (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), state varchar(128), fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."oauth_token (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), token text, fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", ); return $this->_init($sql,$options); From 73041b0be50eb148dad1fff2dc15dbe300c0ee61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2016 14:05:05 +0100 Subject: [PATCH 14/38] Update google_oauthcallback.php --- htdocs/core/modules/oauth/google_oauthcallback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 43232ed92f2..623c131086b 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -45,7 +45,7 @@ $backtourl = GETPOST('backtourl', 'alpha'); $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/google_oauthcallback.php'); /** From 51da5ea1f0676ca747f5899efbee305e424906d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2016 14:07:54 +0100 Subject: [PATCH 15/38] Update printgcp.modules.php --- htdocs/core/modules/printing/printgcp.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7c6e965f778..29e6f0d6941 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -75,7 +75,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - $urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php' + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' ); $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); $serviceFactory = new \OAuth\ServiceFactory(); @@ -113,7 +113,7 @@ class printing_printgcp extends PrintingDriver if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); - $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); + $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); if ($token_ok) { $refreshtoken = $token->getRefreshToken(); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); @@ -122,10 +122,10 @@ class printing_printgcp extends PrintingDriver } /* if ($storage->hasAccessToken('Google')) { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); - $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); } else { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); }*/ } else { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); @@ -200,7 +200,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); @@ -387,7 +387,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); From ffccd43aab0a425e6d9574a07ea66e26c88d40f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2016 14:08:50 +0100 Subject: [PATCH 16/38] Update oauth.php --- htdocs/admin/oauth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 2adf79a6174..c65c78d34ef 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -43,7 +43,7 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); -// Supported OAUTH (a provider is supported when a file xxx_oauth2callback.php is available into htdocs/core/modules/oauth) +// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) $supportedoauth2array=array('OAUTH_GOOGLE_NAME'=>'google'); // API access parameters OAUTH @@ -368,4 +368,4 @@ print ''; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From c28f977e02af60db6ef16be4d86bdef39d6f7444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2016 14:12:34 +0100 Subject: [PATCH 17/38] Update printgcp.modules.php --- htdocs/core/modules/printing/printgcp.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 29e6f0d6941..5177e108f40 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -113,7 +113,7 @@ class printing_printgcp extends PrintingDriver if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); - $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); + $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); if ($token_ok) { $refreshtoken = $token->getRefreshToken(); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); @@ -338,7 +338,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getoauthcallback.php?service=google' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php?service=google' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); From 7ef0415aca64a95e401918724d70bb1246c6322b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Feb 2016 15:57:24 +0100 Subject: [PATCH 18/38] Small per enhancement --- htdocs/core/lib/functions.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 41a9d7c78b7..db227ae4cf6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1892,11 +1892,12 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo { global $conf; - if (empty($stringencoding)) $stringencoding='UTF-8'; - if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; + + if (empty($stringencoding)) $stringencoding='UTF-8'; // reduce for small screen - if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); + if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); + // We go always here if ($trunc == 'right') { From 05d7b14786a4c5d47768df2b8e3185d0b377be11 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 9 Feb 2016 19:11:19 +0100 Subject: [PATCH 19/38] Accoutancy --- htdocs/accountancy/bookkeeping/balance.php | 498 +++++++++++++++++++++ 1 file changed, 498 insertions(+) create mode 100644 htdocs/accountancy/bookkeeping/balance.php diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php new file mode 100644 index 00000000000..5e36e5f2a77 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -0,0 +1,498 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2015 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/accountancy/bookkeeping/balance.php + * \ingroup Accounting Expert + * \brief Balance of book keeping + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + +// Langs +$langs->load("accountancy"); + +$page = GETPOST("page"); +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); +$action = GETPOST('action', 'alpha'); +$search_mvt_num = GETPOST('search_mvt_num', 'int'); +$search_doc_type = GETPOST("search_doc_type"); +$search_doc_ref = GETPOST("search_doc_ref"); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); +$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); + +if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt")) { + $action = 'delbookkeepingyear'; +} +if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { + $action = 'export_csv'; +} + +$search_accountancy_code = GETPOST("search_accountancy_code"); + +$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); +if ($search_accountancy_code_start == - 1) { + $search_accountancy_code_start = ''; +} +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} + +$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code"); + +$search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha'); +if ($search_accountancy_aux_code_start == - 1) { + $search_accountancy_aux_code_start = ''; +} +$search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha'); +if ($search_accountancy_aux_code_end == - 1) { + $search_accountancy_aux_code_end = ''; +} +$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); +$search_direction = GETPOST('search_direction', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); + +$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; + +$offset = $limit * $page; + +$object = new BookKeeping($db); + +$formventilation = new FormVentilation($db); +$formother = new FormOther($db); +$form = new Form($db); + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_mvt_num = ''; + $search_doc_type = ''; + $search_doc_ref = ''; + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_accountancy_aux_code = ''; + $search_accountancy_aux_code_start = ''; + $search_accountancy_aux_code_end = ''; + $search_mvt_label = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; +} + +if (empty($search_date_start)) { + $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); + $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); +} +if ($sortorder == "") + $sortorder = "ASC"; +if ($sortfield == "") + $sortfield = "t.rowid"; + +$options = ''; +$filter = array (); +if (! empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); +} +if (! empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); +} +if (! empty($search_doc_type)) { + $filter['t.doc_type'] = $search_doc_type; + $options .= '&search_doc_type=' . $search_doc_type; +} +if (! empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); +} +if (! empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $options .= '&search_doc_ref=' . $search_doc_ref; +} +if (! empty($search_accountancy_code)) { + $filter['t.numero_compte'] = $search_accountancy_code; + $options .= '&search_accountancy_code=' . $search_accountancy_code; +} +if (! empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; +} +if (! empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $options .= '&search_accountancy_code_end=' . $search_accountancy_code_end; +} +if (! empty($search_accountancy_aux_code)) { + $filter['t.code_tiers'] = $search_accountancy_aux_code; + $options .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; +} +if (! empty($search_accountancy_aux_code_start)) { + $filter['t.code_tiers>='] = $search_accountancy_aux_code_start; + $options .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; +} +if (! empty($search_accountancy_aux_code_end)) { + $filter['t.code_tiers<='] = $search_accountancy_aux_code_end; + $options .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; +} +if (! empty($search_mvt_label)) { + $filter['t.label_compte'] = $search_mvt_label; + $options .= '&search_mvt_label=' . $search_mvt_label; +} +if (! empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $options .= '&search_direction=' . $search_direction; +} +if (! empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $options .= '&search_ledger_code=' . $search_ledger_code; +} +if (! empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $options .= '&search_mvt_num=' . $search_mvt_num; +} + +/* + * Action + */ +if ($action == 'delbookkeeping') { + + $import_key = GETPOST('importkey', 'alpha'); + + if (! empty($import_key)) { + $result = $object->deleteByImportkey($import_key); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + Header("Location: list.php"); + exit(); + } +} elseif ($action == 'delbookkeepingyearconfirm') { + + $delyear = GETPOST('delyear', 'int'); + + if (! empty($delyear)) { + $result = $object->deleteByYear($delyear); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + Header("Location: list.php"); + exit(); + } +} elseif ($action == 'delmouvconfirm') { + + $mvt_num = GETPOST('mvt_num', 'int'); + + if (! empty($mvt_num)) { + $result = $object->deleteMvtNum($mvt_num); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + // if (!empty($options)) { + // Header("Location: list.php?".urldecode($options)); + // } else { + Header("Location: list.php"); + // } + exit(); + } +} elseif ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = 'bookkepping'; + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + + $result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + foreach ( $object->lines as $line ) { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; + // Model Cegid Expert Export + $date = dol_print_date($line->doc_date, '%d%m%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accountg($line->numero_compte) . $sep; + print ' ' . $sep; + print $line->sens . $sep; + print price($line->montant) . $sep; + print dol_trunc($line->label_compte, 32) . $sep; + print $line->doc_ref . $sep; + + /*print $line->piece_num . $sep; + print length_accounta($line->code_tiers) . $sep; + print . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep;*/ + + print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + + // Std export + $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + print $date . $sep; + print $line->doc_ref . $sep; + print length_accounta($line->numero_compte) . $sep; + print length_accountg($line->code_tiers) . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + + /*print $line->piece_num . $sep; + print $line->label_compte . $sep; + print price($line->montant) . $sep; + print $line->sens . $sep;*/ + print $line->code_journal . $sep; + print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { + + // Coala export + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accounta($line->numero_compte) . $sep; + print $line->piece_num . $sep; + print $line->doc_ref . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + print 'E' . $sep; + print length_accountg($line->code_tiers) . $sep; + print "\n"; + } + } +} + +else { + + $title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); + + llxHeader('', $title_page); + + /* + * List + */ + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + if ($action == 'delmouv') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); + print $formconfirm; + } + if ($action == 'delbookkeepingyear') { + + $form_question = array (); + $delyear = GETPOST('delyear'); + + if (empty($delyear)) { + $delyear = dol_print_date(dol_now(), '%Y'); + } + $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + + $form_question['delyear'] = array ( + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); + print $formconfirm; + } + + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); + + /*print '
'; + print ''; + print ''; + + print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); + + print '
'; + + print '
';*/ + + print '
'; + print '
' . "\n"; + //print '
'; + //print '' . $langs->trans("NewAccountingMvt") . ''; + // print '' . $langs->trans("Export") . ''; + print '
'; + + print '
'; + + print '
'; + print $langs->trans('DateStart') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print $langs->trans('DateEnd') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + print '
'; + /* + print '
'; + print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '
'; + print '
'; + print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); + print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); + print '
';*/ + + print ''; + print ''; + //print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); + // print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); + //print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; + + print ''; + /*print ''; + print '';*/ + //print ''; + print ''; + // print ''; + /*print '';*/ + // print ''; + + /*print '';*/ + print ''; + print ''; + print ''; + // print ''; + // print ''; + //print ''; + print ''; + + print ''; + + $var = True; + + $total_debit = 0; + $total_credit = 0; + + foreach ( $object->lines as $line ) { + $var = ! $var; + + $total_debit += $line->debit; + $total_credit += $line->credit; + + print ""; + + //print ''; + //print ''; + //print ''; + print ''; + //print ''; + //print ''; + print ''; + print ''; + print ''; + // print ''; + // print ''; + //print ''; + print ''; + print "\n"; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "
'; + print $langs->trans('From') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print '
'; + print $langs->trans('To') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + // print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); + print '
'; + // print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; + print $langs->trans('From'); + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + // print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; + print '
'; + print $langs->trans('To'); + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '
'; + // print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print $langs->trans('From'); + print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); + // print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; + print '
'; + print $langs->trans('To'); + print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); + print '
'; + print ''; + print '     '; + print ''; + print ' '; + print ''; + print '
' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit-$line->debit) . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . ''; + //print '' . img_edit() . ''; + //print '' . img_delete() . ''; + print '
'; + print price($total_debit); + print ''; + print price($total_credit); + print ''.price($total_credit-$total_debit).'
"; + print '
'; + + llxFooter(); +} + +$db->close(); \ No newline at end of file From 44e39519b038448bc9498daf9e9636525da17994 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 9 Feb 2016 19:20:03 +0100 Subject: [PATCH 20/38] add accountancy balance --- htdocs/accountancy/bookkeeping/balance.php | 245 +----------------- .../accountancy/class/bookkeeping.class.php | 82 +++++- htdocs/core/menus/standard/eldy.lib.php | 3 +- 3 files changed, 97 insertions(+), 233 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 5e36e5f2a77..16027a42af4 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -38,21 +38,8 @@ $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); $action = GETPOST('action', 'alpha'); -$search_mvt_num = GETPOST('search_mvt_num', 'int'); -$search_doc_type = GETPOST("search_doc_type"); -$search_doc_ref = GETPOST("search_doc_ref"); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); -$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); - -if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt")) { - $action = 'delbookkeepingyear'; -} -if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { - $action = 'export_csv'; -} - -$search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { @@ -63,19 +50,9 @@ if ($search_accountancy_code_end == - 1) { $search_accountancy_code_end = ''; } -$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code"); - -$search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha'); -if ($search_accountancy_aux_code_start == - 1) { - $search_accountancy_aux_code_start = ''; +if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { + $action = 'export_csv'; } -$search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha'); -if ($search_accountancy_aux_code_end == - 1) { - $search_accountancy_aux_code_end = ''; -} -$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); -$search_direction = GETPOST('search_direction', 'alpha'); -$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -89,19 +66,8 @@ $form = new Form($db); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_mvt_num = ''; - $search_doc_type = ''; - $search_doc_ref = ''; - $search_doc_date = ''; - $search_accountancy_code = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; - $search_accountancy_aux_code = ''; - $search_accountancy_aux_code_start = ''; - $search_accountancy_aux_code_end = ''; - $search_mvt_label = ''; - $search_direction = ''; - $search_ledger_code = ''; $search_date_start = ''; $search_date_end = ''; } @@ -125,22 +91,6 @@ if (! empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); } -if (! empty($search_doc_type)) { - $filter['t.doc_type'] = $search_doc_type; - $options .= '&search_doc_type=' . $search_doc_type; -} -if (! empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); -} -if (! empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $options .= '&search_doc_ref=' . $search_doc_ref; -} -if (! empty($search_accountancy_code)) { - $filter['t.numero_compte'] = $search_accountancy_code; - $options .= '&search_accountancy_code=' . $search_accountancy_code; -} if (! empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; @@ -149,85 +99,17 @@ if (! empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; $options .= '&search_accountancy_code_end=' . $search_accountancy_code_end; } -if (! empty($search_accountancy_aux_code)) { - $filter['t.code_tiers'] = $search_accountancy_aux_code; - $options .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; -} -if (! empty($search_accountancy_aux_code_start)) { - $filter['t.code_tiers>='] = $search_accountancy_aux_code_start; - $options .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; -} -if (! empty($search_accountancy_aux_code_end)) { - $filter['t.code_tiers<='] = $search_accountancy_aux_code_end; - $options .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; -} -if (! empty($search_mvt_label)) { - $filter['t.label_compte'] = $search_mvt_label; - $options .= '&search_mvt_label=' . $search_mvt_label; -} -if (! empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $options .= '&search_direction=' . $search_direction; -} -if (! empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - $options .= '&search_ledger_code=' . $search_ledger_code; -} -if (! empty($search_mvt_num)) { - $filter['t.piece_num'] = $search_mvt_num; - $options .= '&search_mvt_num=' . $search_mvt_num; -} /* * Action */ -if ($action == 'delbookkeeping') { - - $import_key = GETPOST('importkey', 'alpha'); - - if (! empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - Header("Location: list.php"); - exit(); - } -} elseif ($action == 'delbookkeepingyearconfirm') { - - $delyear = GETPOST('delyear', 'int'); - - if (! empty($delyear)) { - $result = $object->deleteByYear($delyear); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - Header("Location: list.php"); - exit(); - } -} elseif ($action == 'delmouvconfirm') { - - $mvt_num = GETPOST('mvt_num', 'int'); - - if (! empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - // if (!empty($options)) { - // Header("Location: list.php?".urldecode($options)); - // } else { - Header("Location: list.php"); - // } - exit(); - } -} elseif ($action == 'export_csv') { +if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - $result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -312,131 +194,43 @@ else { setEventMessages($object->error, $object->errors, 'errors'); } - if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); - print $formconfirm; - } - if ($action == 'delbookkeepingyear') { - - $form_question = array (); - $delyear = GETPOST('delyear'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - - $form_question['delyear'] = array ( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); - print $formconfirm; - } - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - /*print '
'; - print ''; - print ''; - - print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); - - print '
'; - - print '
';*/ - print '
'; print '
' . "\n"; - //print '
'; - //print '' . $langs->trans("NewAccountingMvt") . ''; - // print '' . $langs->trans("Export") . ''; print '
'; print '
'; - print '
'; - print $langs->trans('DateStart') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print $langs->trans('DateEnd') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - print '
'; - /* - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - print '
';*/ + print '
'; + print $langs->trans('DateStart') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print $langs->trans('DateEnd') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + print '
'; print ''; print ''; - //print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - // print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); - // print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); - //print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; print ''; - /*print ''; - print '';*/ - //print ''; print ''; - // print ''; - /*print '';*/ - // print ''; - /*print '';*/ print ''; print ''; print ''; - // print ''; - // print ''; - //print ''; + print '"; - //print ''; - //print ''; - //print ''; print ''; - //print ''; - //print ''; print ''; print ''; - print ''; - // print ''; - // print ''; - //print ''; + print ''; print ''; print "\n"; } @@ -485,7 +269,7 @@ else { print ''; - print ''; + print ''; print ''; print ''; @@ -494,5 +278,4 @@ else { llxFooter(); } - $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index dbca9aeddd9..0015dfbf9e9 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015-*2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -642,6 +642,86 @@ class BookKeeping extends CommonObject } } + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= " t.numero_compte,"; + $sql .= " SUM(t.debit) as debit,"; + $sql .= " SUM(t.credit) as credit"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + + // Manage filter + $sqlwhere = array (); + if (count($filter) > 0) { + foreach ( $filter as $key => $value ) { + if ($key == 't.doc_date') { + $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { + $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $key . '=' . $value; + } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + } else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + + $sql .= ' GROUP BY t.numero_compte'; + + if (! empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (! empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + } + $this->lines = array (); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ( $obj = $this->db->fetch_object($resql) ) { + $line = new BookKeepingLine(); + + $line->numero_compte = $obj->numero_compte; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $this->lines[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + /** * Update object into database * diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0497b50308f..23f37e1b676 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -971,7 +971,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); - + if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); + // Reports $langs->load("compta"); From ef7e245432d431712015a3c60c24df387e3265f6 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 9 Feb 2016 19:23:17 +0100 Subject: [PATCH 21/38] g --- 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 23f37e1b676..4e6a219c055 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -969,9 +969,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // General Ledger $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); + if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); - if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); // Reports $langs->load("compta"); From 39feb457791b61e7123b5f0aaf51c57b33024a1c Mon Sep 17 00:00:00 2001 From: philippe grand Date: Wed, 10 Feb 2016 12:15:22 +0100 Subject: [PATCH 22/38] default sort should be from A to Z --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index dc7266603ca..e4260388ac7 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -57,7 +57,7 @@ if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder=($filter=='outofdate'?"ASC":"DESC"); } +if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers From 1d5bd7208ed1c302a7ef74e5321c776fd6685d20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Feb 2016 00:24:32 +0100 Subject: [PATCH 23/38] Packager can publish release candidates on foundation server --- build/makepack-dolibarr.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 1d6542eafc9..c8b3c7664e2 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -1150,14 +1150,16 @@ if ($nboftargetok) { if ($target eq 'SF') { $destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD; - print "Publish file ".$file." to $NEWPUBLISH/".$filestoscan{$file}."\n"; + print "Publish file ".$file." to $NEWPUBLISH/".$filestoscan{$file}."/".$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; } else { + $dirnameonly=$file; + $dirnameonly =~ s/.*\/([^\/]+)\/[^\/]+$/$1/; $filenameonly=$file; - $filenameonly =~ s/.*\/([^\/]+\/[^\/]+)$/$1/; # removes path - $destFolder="$NEWPUBLISH/$filenameonly"; - print "Publish file ".$file." to $NEWPUBLISH/".$filenameonly."\n"; + $filenameonly =~ s/.*\/[^\/]+\/([^\/])+$/$1/; + $destFolder="$NEWPUBLISH/$dirnameonly"; + print "Publish file ".$file." to $NEWPUBLISH/".$dirnameonly."\n"; } # mkdir From 518080468e90617a9cb7e130f620c119a01cb0a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Feb 2016 10:39:01 +0100 Subject: [PATCH 24/38] Fix button create template must be visible only if amount is != 0 --- htdocs/compta/facture.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index eb3f969890b..090a82cbaa2 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3313,7 +3313,9 @@ else if ($id > 0 || ! empty($ref)) print ' '; print $prevsits[0]->situation_counter; - for ($i = 1; $i < count($prevsits); $i++) { + $cprevsits = count($prevsits); + + for ($i = 1; $i < $cprevsits; $i++) { print ' + '; print $prevsits[$i]->situation_counter; } @@ -3334,7 +3336,7 @@ else if ($id > 0 || ! empty($ref)) print ''; // Previous situation(s) deduction(s) - for ($i = 0; $i < count($prevsits); $i++) { + for ($i = 0; $i < $cprevsits; $i++) { print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 418e164bc94..6c2b1f6a027 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1,15 +1,16 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2011 Remy Younes - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2015 Alexandre Spangaro - * Copyright (C) 2015 Ferran Marcet +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011 Remy Younes + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2011-2015 Alexandre Spangaro + * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2016 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 @@ -1146,7 +1147,7 @@ if ($id) { $showfield=1; $align="left"; - $valuetoshow=$obj->$fieldlist[$field]; + $valuetoshow=$obj->{$fieldlist[$field]}; if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; @@ -1183,77 +1184,77 @@ if ($id) else if ($fieldlist[$field]=='libelle_facture') { $langs->load("bills"); $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=nl2br($valuetoshow); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { $langs->load("propal"); $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { $langs->load('agenda'); $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { $langs->load("bills"); $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { $langs->load("orders"); $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { $langs->load("sendings"); $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; @@ -1263,16 +1264,16 @@ if ($id) } else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow=$langs->trans($obj->$fieldlist[$field]); + $valuetoshow=$langs->trans($obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->$fieldlist[$field]); + $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='localtax1_type') { @@ -1484,7 +1485,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { if (! in_array('country',$fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { - $country_id = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); + $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); print ''; @@ -1498,7 +1499,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif ($fieldlist[$field] == 'region_id') { - $region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); + $region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0); print ''; @@ -1513,21 +1514,21 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') elseif ($fieldlist[$field] == 'type_template') { print ''; } // Le type de l'element (pour les type de contact) elseif ($fieldlist[$field] == 'element') { print ''; } // La source de l'element (pour les type de contact) elseif ($fieldlist[$field] == 'source') { print ''; } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") @@ -1538,18 +1539,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { print ''; } elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { $align="left"; if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right print ''; } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { - print ''; + print ''; } elseif (in_array($fieldlist[$field], array('content'))) { @@ -1560,18 +1561,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') else print ''; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { - print ''; + print ''; } - elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { - print ''; + elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + print ''; } elseif ($fieldlist[$field]=='unit') { print ''; } // Le type de taxe locale elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') { print ''; } else @@ -1603,7 +1604,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field]=='accountancy_code_sell') $size='size="10" '; if ($fieldlist[$field]=='accountancy_code_buy') $size='size="10" '; if ($fieldlist[$field]=='sortorder') $size='size="2" '; - print ''; + print ''; print ''; } } diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 2adf79a6174..3bcbe990f87 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -1,5 +1,6 @@ + * Copyright (C) 2016 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 @@ -346,14 +347,14 @@ foreach ($list as $key) $var = !$var; print ''; print ''; - print ''; // Api Secret $var = !$var; print ''; print ''; - print ''; } @@ -368,4 +369,4 @@ print ''; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ee5f1465e3f..d63c2536476 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,12 +1,13 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2009-2012 Laurent Destailleur - * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Charles-Fr BENKE +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Charles-Fr BENKE + * Copyright (C) 2016 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 @@ -867,7 +868,7 @@ class ExtraFields } else { - $labeltoshow=$obj->$InfoFieldList[1]; + $labeltoshow=$obj->{$InfoFieldList[1]}; } $labeltoshow=dol_trunc($labeltoshow,45); @@ -888,12 +889,12 @@ class ExtraFields { if(!$notrans) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); - if ($translabel!=$obj->$InfoFieldList[1]) { + $translabel=$langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel!=$obj->{$InfoFieldList[1]}) { $labeltoshow=dol_trunc($translabel,18); } else { - $labeltoshow=dol_trunc($obj->$InfoFieldList[1],18); + $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18); } } if (empty($labeltoshow)) $labeltoshow='(not defined)'; @@ -1044,7 +1045,7 @@ class ExtraFields $labeltoshow .= $obj->$field_toshow . ' '; } } else { - $labeltoshow = $obj->$InfoFieldList[1]; + $labeltoshow = $obj->{$InfoFieldList[1]}; } $labeltoshow = dol_trunc($labeltoshow, 45); @@ -1065,11 +1066,11 @@ class ExtraFields $out .= '/>' . $labeltoshow . '
'; } else { if (! $notrans) { - $translabel = $langs->trans($obj->$InfoFieldList[1]); - if ($translabel != $obj->$InfoFieldList[1]) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel != $obj->{$InfoFieldList[1]}) { $labeltoshow = dol_trunc($translabel, 18); } else { - $labeltoshow = dol_trunc($obj->$InfoFieldList[1], 18); + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); } } if (empty($labeltoshow)) @@ -1263,13 +1264,13 @@ class ExtraFields else { $translabel=''; - if (!empty($obj->$InfoFieldList[1])) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); + if (!empty($obj->{$InfoFieldList[1]})) { + $translabel=$langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel!=$obj->$InfoFieldList[1]) { + if ($translabel!=$obj->{$InfoFieldList[1]}) { $value=dol_trunc($translabel,18); }else { - $value=$obj->$InfoFieldList[1]; + $value=$obj->{$InfoFieldList[1]}; } } } @@ -1343,13 +1344,13 @@ class ExtraFields } } else { $translabel = ''; - if (! empty($obj->$InfoFieldList[1])) { - $translabel = $langs->trans($obj->$InfoFieldList[1]); + if (! empty($obj->{$InfoFieldList[1]})) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel != $obj->$InfoFieldList[1]) { + if ($translabel != $obj->{$InfoFieldList[1]}) { $value .= dol_trunc($translabel, 18) . '
'; } else { - $value .= $obj->$InfoFieldList[1] . '
'; + $value .= $obj->{$InfoFieldList[1]} . '
'; } } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3728644a401..25b5712d3f4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1,8 +1,9 @@ - * Copyright (C) 2012-2015 Regis Houssin - * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2015 Marcos García +/* Copyright (C) 2008-2012 Laurent Destailleur + * Copyright (C) 2012-2015 Regis Houssin + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 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 @@ -2256,18 +2257,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu // Define $accessallowed if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg)) { - if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; - $original_file=$conf->$reg[1]->dir_temp.'/'.$fuser->id.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1; + $original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file; } else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) { - if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; - $original_file=$conf->$reg[1]->dir_temp.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1; + $original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file; } else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) { - if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; - $original_file=$conf->$reg[1]->dir_output.'/'.$fuser->id.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1; + $original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file; } else { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index f2b13d79d0f..deab2457c8b 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -4,7 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Ferran Marcet - * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2015-2016 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 @@ -1910,7 +1910,7 @@ function fetchObjectByElement($element_id, $element_type) global $db,$conf; $element_prop = getElementProperties($element_type); - if (is_array($element_prop) && $conf->$element_prop['module']->enabled) + if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) { dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 3a3436c71a9..7912b4f189f 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -1,7 +1,8 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Charles-Fr BENKE +/* Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Charles-Fr BENKE + * Copyright (C) 2016 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 @@ -131,11 +132,11 @@ class Export //print_r("$perm[0]-$perm[1]-$perm[2]
"); if (! empty($perm[2])) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; if (! $bool) break; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 2c17dd44f02..9a4d58aa65f 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2016 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 @@ -106,11 +107,11 @@ class Import //print_r("$perm[0]-$perm[1]-$perm[2]
"); if ($perm[2]) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; //print $bool." $perm[0]"."
"; From ad534c90e63cb1fce495c8b576710e68836840f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 12 Feb 2016 10:34:21 +0100 Subject: [PATCH 27/38] Update 3.8.0-3.9.0.sql --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 7c372a5c394..41166b0de06 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -34,9 +34,6 @@ ALTER TABLE llx_actioncomm ADD COLUMN email_tocc varchar(256) after email_to; ALTER TABLE llx_actioncomm ADD COLUMN email_tobcc varchar(256) after email_tocc; -UPDATE llx_commande_fourn set billed=1 where statut = 8; -UPDATE llx_commande_fourn set statut=5 where statut = 8 and billed=1; - ALTER TABLE llx_user MODIFY COLUMN pass varchar(128); ALTER TABLE llx_user MODIFY COLUMN pass_temp varchar(128); @@ -111,6 +108,9 @@ ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_s ALTER TABLE llx_commande_fournisseur ADD COLUMN billed smallint DEFAULT 0 AFTER fk_statut; ALTER TABLE llx_commande_fournisseur ADD INDEX billed (billed); +UPDATE llx_commande_fournisseur set billed=1 where statut = 8; +UPDATE llx_commande_fournisseur set statut=5 where statut = 8 and billed=1; + ALTER TABLE llx_product ADD COLUMN cost_price double(24,8) DEFAULT NULL; ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); From 756b50b9d320ebbc0d5cc3103051aa20313d452a Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 12 Feb 2016 12:06:23 +0100 Subject: [PATCH 28/38] FIX : search product in customer product prices doesn't work --- htdocs/product/class/productcustomerprice.class.php | 2 ++ htdocs/societe/price.php | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 86228db70c5..f2adc298a76 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -346,6 +346,8 @@ class Productcustomerprice extends CommonObject $sql .= ' AND ' . $key . ' = \'' . $value . '\''; } elseif ($key == 'soc.nom') { $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + } elseif ($key == 'prod.ref') { + $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; } else { $sql .= ' AND ' . $key . ' = ' . $value; } diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 82adbd96607..0259150ccc4 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -241,9 +241,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { 't.fk_soc' => $object->id ); - $search_soc = GETPOST('search_soc'); - if (! empty($search_soc)) { - $filter ['soc.nom'] = $search_soc; + $search_prod = GETPOST('search_prod'); + if (! empty($search_prod)) { + $filter ['prod.ref'] = $search_prod; } if ($action == 'add_customer_price') { @@ -487,7 +487,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { setEventMessage($prodcustprice->error, 'errors'); } - $option = '&search_soc=' . $search_soc . '&id=' . $object->id; + $option = '&search_prod=' . $search_prod . '&id=' . $object->id; print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); @@ -512,7 +512,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print '
'; - print ''; + print ''; print ''; // Print the search button print ''; print ''; print '"; print ''; From 969314e73153ea534b5434300c4c91cd99632bef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Feb 2016 12:19:32 +0100 Subject: [PATCH 30/38] Fix: disabling option lead in not working dolibarr --- htdocs/core/modules/modExpedition.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 314536c28b5..6d29a426afd 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -83,7 +83,7 @@ class modExpedition extends DolibarrModules // Constants $this->const = array(); $r=0; - + $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "rouget"; @@ -124,7 +124,15 @@ class modExpedition extends DolibarrModules $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; - + $r++; + + $this->const[$r][0] = "MAIN_SUBMODULE_EXPEDITION"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "1"; + $this->const[$r][3] = "Enable shipments"; + $this->const[$r][4] = 0; + $r++; + // Boxes $this->boxes = array(); From e9ffbd140626e0a228edaa28ffcadef759067a01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Feb 2016 14:27:59 +0100 Subject: [PATCH 31/38] FIX When an email was partially sent from GUI, it was not possible to finish from CLI. --- scripts/emailings/mailing-send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index cfe26e3d2a4..f1ebe332372 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -68,7 +68,7 @@ if (! empty($login)) $user->fetch('',$login); $sql = "SELECT m.rowid, m.titre, m.sujet, m.body,"; $sql.= " m.email_from, m.email_replyto, m.email_errorsto"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; -$sql.= " WHERE m.statut = 1"; +$sql.= " WHERE m.statut IN (1,2)"; if ($id != 'all') { $sql.= " AND m.rowid= ".$id; From cc174daa13a859075a90e34371e5584e2242c049 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Feb 2016 20:12:47 +0100 Subject: [PATCH 32/38] Prepare 3.8.4 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 77ba2788d99..7bf8271606d 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -30,7 +30,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.8.3'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.8.4'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From b7ae5bac6f15570afba5d00e229feae69a7af24a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Feb 2016 20:48:25 +0100 Subject: [PATCH 33/38] Fix: The text "All" is not appropriate. --- htdocs/core/class/html.form.class.php | 17 ++++++++++------- htdocs/product/price.php | 27 ++++++++++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c694933f85c..5078b5932c9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -894,7 +894,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') - * @param int $showempty Add an empty field + * @param string $showempty Add an empty field (Can be '1' or text to use on empty line) * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -903,7 +903,7 @@ class Form * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @return string HTML string with select box for thirdparty. */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='') + function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='') { $out=''; @@ -949,7 +949,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client in (1,3)') - * @param int $showempty Add an empty field + * @param string $showempty Add an empty field (Can be '1' or text to use on empty line) * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -960,7 +960,7 @@ class Form * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @return string HTML string with */ - function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='') + function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='') { global $conf,$user,$langs; @@ -1017,10 +1017,13 @@ class Form $out.= '
'; - print $langs->trans('From') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print '
'; - print $langs->trans('To') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - // print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); - print '
'; - // print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; print $langs->trans('From'); print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - // print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; print '
'; print $langs->trans('To'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '
'; - // print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $langs->trans('From'); - print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - // print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print '
'; - print $langs->trans('To'); - print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - print '
'; - print ''; - print '     '; print ''; print ' '; @@ -458,21 +252,11 @@ else { print "
' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit-$line->debit) . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . '' . price($line->credit - $line->debit) . ''; - //print '' . img_edit() . ''; - //print '' . img_delete() . ''; print '
'; print price($total_credit); print ''.price($total_credit-$total_debit).'' . price($total_credit - $total_debit) . '
' . $langs->trans('Currency' . $conf->currency) . '
'; print ''; print $langs->trans('SituationDeduction'); @@ -3629,6 +3631,7 @@ else if ($id > 0 || ! empty($ref)) } } + // deprecated. Useless because now we can use templates if (! empty($conf->global->FACTURE_SHOW_SEND_REMINDER)) // For backward compatibility { if (($object->statut == 1 || $object->statut == 2) && $resteapayer > 0) { @@ -3684,7 +3687,7 @@ else if ($id > 0 || ! empty($ref)) // Classify paid if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) + || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) ) { print ''; @@ -3714,10 +3717,10 @@ else if ($id > 0 || ! empty($ref)) print ''; } - // Clone as predefined + // Clone as predefined / Create template if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $user->rights->facture->creer) { - if (! $objectidnext) + if (! $objectidnext && count($object->lines) > 0) { print ''; } @@ -3732,7 +3735,7 @@ else if ($id > 0 || ! empty($ref)) } } - //Create next situation invoice + // Create next situation invoice if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { print ''; From 51cc252d4a8a4229a429e288c55c85ac1aaf9d1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Feb 2016 15:47:47 +0100 Subject: [PATCH 25/38] Fix: submit was no more possible from keyboard --- htdocs/core/class/html.form.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1c9dd350859..c694933f85c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -503,7 +503,8 @@ class Form $ret.=''; } $ret.=''; - $ret.=''; + // Warning: if you set submit button to disabled, post using Enter will no more work + $ret.=''; $ret.=''; $ret.=' @@ -516,7 +517,6 @@ class Form /* console.log( index + ": " + $( this ).text() ); */ if ($(this).is(\':checked\')) atleastoneselected++; }); - console.log(atleastoneselected); if (atleastoneselected) { jQuery(".massaction").show(); @@ -530,6 +530,7 @@ class Form jQuery(".checkforselect").click(function() { initCheckForSelect(); }); + /* Warning: if you set submit button to disabled, post using Enter will no more work jQuery(".massactionselect").change(function() { console.log( $( this ).val() ); if ($(this).val() != \'0\') @@ -541,6 +542,7 @@ class Form jQuery(".massactionconfirmed").prop(\'disabled\', true); } }); + */ }); '; From d038ca1875b0ea30ff70db52e48fa6516a572d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 11 Feb 2016 20:01:51 +0100 Subject: [PATCH 26/38] FIX #4597 PHP 7 Uniform Variable Syntax PHP7 compatibility with the new Uniform Variable Syntax. This change is compatible with both PHP 5 and PHP 7. See: https://wiki.php.net/rfc/uniform_variable_syntax#backward_incompatible_changes --- htdocs/admin/delais.php | 13 ++-- htdocs/admin/dict.php | 95 +++++++++++++------------ htdocs/admin/oauth.php | 7 +- htdocs/core/class/extrafields.class.php | 49 ++++++------- htdocs/core/lib/files.lib.php | 21 +++--- htdocs/core/lib/functions2.lib.php | 4 +- htdocs/exports/class/export.class.php | 11 +-- htdocs/imports/class/import.class.php | 7 +- 8 files changed, 107 insertions(+), 100 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index b43235ca1ec..2b52372046b 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2005 Simon Tosser - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2001-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005 Simon Tosser + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2016 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 @@ -158,7 +159,7 @@ if ($action == 'edit') foreach($delays as $delay) { $var=!$var; - $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print '
'.img_object('',$delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; @@ -205,7 +206,7 @@ else foreach($delays as $delay) { $var=!$var; - $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print '
'.img_object('',$delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; print ''; print ''; print ''; print ''; - print $form->selectarray('type_template', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('type_template', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('element', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('source', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); + print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1); print ''; - print ''; + print ''; print ''; if ($context != 'hide') { - //print ''; - $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); + //print ''; + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); print $doleditor->Create(1); } else print ' '; print ''; @@ -1581,14 +1582,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') 'point' => $langs->trans('SizeUnitpoint'), 'inch' => $langs->trans('SizeUnitinch') ); - print $form->selectarray('unit', $units, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); + print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0); print ''; - print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print '
'; + print ''; print '
'; + print ''; print '
 '; From 1c6d154a775a11bf048082ea245cf703fb54f829 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Feb 2016 12:19:11 +0100 Subject: [PATCH 29/38] Fix: disabling option lead in not working dolibarr --- htdocs/admin/confexped.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index ea05c683ef7..85682960df9 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -2,8 +2,8 @@ /* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2011-2015 Juanjo Menent ù - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2011-2016 Juanjo Menent ù + * Copyright (C) 2015 Claudio Aschieri * * 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 @@ -38,21 +38,34 @@ if (!$user->admin) $action=GETPOST('action','alpha'); + +/* + * Actions + */ + // Shipment note +if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) +{ + // This option should always be set to on when module is on. + dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); +} +/* if ($action == 'activate_sending') { dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); header("Location: confexped.php"); exit; } -else if ($action == 'disable_sending') +if ($action == 'disable_sending') { dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); header("Location: confexped.php"); exit; } +*/ + // Delivery note -else if ($action == 'activate_delivery') +if ($action == 'activate_delivery') { dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); // We must also enable this dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1",'chaine',0,'',$conf->entity); @@ -68,8 +81,9 @@ else if ($action == 'disable_delivery') /* - * Affiche page + * View */ + $dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/"; $form=new Form($db); @@ -102,16 +116,15 @@ print ''.$langs->trans("SendingsAbility").''; print ''; - -if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) +print $langs->trans("Required"); +/*if (empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } else { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; -} - +}*/ print "
' . $langs->trans("PriceByQuantity") . ' ' . $i; print ''; - if ($object->prices_by_qty [$i] == 1) { + if ($object->prices_by_qty[$i] == 1) { print ''; print ''; @@ -558,7 +567,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; print ''; - foreach ($object->prices_by_qty_list [$i] as $ii => $prices) { + foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print ''; print ''; @@ -574,7 +583,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; } else { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1177,7 +1186,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if ($action == 'add_customer_price') { - // Create mode + // Form to add a new customer price $maxpricesupplier = $object->min_recommended_price(); print load_fiche_titre($langs->trans('PriceByCustomer')); @@ -1188,19 +1197,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print '
' . $langs->trans("Discount") . ' 
' . $prices ['quantity'] . '' . $prices['quantity'] . '' . price($prices['price']) . '' . price($prices['unitprice']) . '' . price($prices['remise_percent']) . ' %
'; print ''; - print ''; + print ''; print ''; print ''; // VAT - print ''; // Price base - print ''; print ''; // Price - print '
' . $langs->trans('ThirdParty') . '' . $langs->trans('ThirdParty') . ''; - print $form->select_company('', 'socid', 's.client in (1,2,3) AND s.rowid NOT IN (SELECT fk_soc FROM ' . MAIN_DB_PREFIX . 'product_customer_price WHERE fk_product='.$object->id.')', 1, 0, 0, array(), 0, 'minwidth300'); + print $form->select_company('', 'socid', 's.client in (1,2,3) AND s.rowid NOT IN (SELECT fk_soc FROM ' . MAIN_DB_PREFIX . 'product_customer_price WHERE fk_product='.$object->id.')', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); print '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr); print '
'; + print '
'; print $langs->trans('PriceBase'); print ''; @@ -1209,7 +1218,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
'; + print '
'; $text = $langs->trans('SellingPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; From 2f99273734482ed88d3e537eea0c9dbce35b1cb2 Mon Sep 17 00:00:00 2001 From: abb Date: Fri, 12 Feb 2016 23:49:24 +0100 Subject: [PATCH 34/38] fix:no transaction in this place --- htdocs/core/class/commonobjectline.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 5bcbab5934a..94c7b7bf860 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -66,8 +66,6 @@ abstract class CommonObjectLine extends CommonObject $langs->load('products'); - $this->db->begin(); - $label_type = 'label'; if ($type == 'short') From 834f0b20ae4cd9dff9b9ccad1064d82ae5ac67fb Mon Sep 17 00:00:00 2001 From: abb Date: Fri, 12 Feb 2016 23:49:24 +0100 Subject: [PATCH 35/38] fix:no transaction in this place --- htdocs/core/class/commonobjectline.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index ef854a2452e..f9f2e3c889f 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -69,8 +69,6 @@ abstract class CommonObjectLine extends CommonObject $langs->load('products'); - $this->db->begin(); - $label_type = 'label'; if ($type == 'short') From 13c85516eee4ec976194248df856aae98742e474 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Feb 2016 21:58:54 +0100 Subject: [PATCH 36/38] Doc comment --- htdocs/comm/propal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 08106bc2151..c7d9d385385 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -268,7 +268,7 @@ if (empty($reshook)) { $db->begin(); - // Si on a selectionne une propal a copier, on realise la copie + // If we select proposal to clone during creation (when option PROPAL_CLONE_ON_CREATE_PAGE is on) if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { if ($object->fetch(GETPOST('copie_propal')) > 0) { From 2fd01d71cfd8ec3e46b8b1bb860a90aad8664e65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Feb 2016 22:20:42 +0100 Subject: [PATCH 37/38] Fix #4548 Check on stock enough must be done according to warehouse --- htdocs/expedition/class/expedition.class.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 9ad2108519a..c885a03145d 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -856,13 +856,23 @@ class Expedition extends CommonObject return -1; } - if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) // FIXME Check is done for stock of product, it must be done for stock of product into warehouse if $entrepot_id defined + if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { + // Check must be done for stock of product into warehouse if $entrepot_id defined $product=new Product($this->db); $result=$product->fetch($fk_product); - $product_type=$product->type; - if ($product_type == 0 && $product->stock_reel < $qty) + $product_type=$product->type; + if ($entrepot_id > 0) { + $product->load_stock(); + $product_stock = $product->stock_warehouse[$entrepot_id]->real; + } + else + { + $product_stock = $product->stock_reel; + } + + if ($product_type == 0 && $product_stock < $qty) { $this->error=$langs->trans('ErrorStockIsNotEnough'); $this->db->rollback(); From 3925ae0742f2d5b0b22f513986e280026e76a925 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Feb 2016 23:53:42 +0100 Subject: [PATCH 38/38] Fix: we loose ability to refresh contact list when changing a company on contact tab --- htdocs/core/class/html.formcompany.class.php | 16 +++++++--- htdocs/core/lib/ajax.lib.php | 32 ++++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index e91184ede12..40276b6205d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -564,16 +564,21 @@ class FormCompany } } - // Refresh contacts list on thirdparty list change - $htmloption=''; $events=array(); + // Add an entry 'method' to say 'yes, we must execute url with param action = method'; + // Add an entry 'url' to say which url to execute + // Add an entry htmlname to say which element we must change once url is called + // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines + // To refresh contacts list on thirdparty list change $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events { print '