diff --git a/ChangeLog b/ChangeLog
index ace6c60c0c0..9cd6f11d1b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,10 +31,17 @@ Following changes may create regression for some external modules, but were nece
content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow
hook specifications so you must return output into "resprint".
+
***** ChangeLog for 5.0.4 compared to 5.0.3 *****
-FIX: #6880
-FIX: #6925
+FIX: #5640 Prices of a predefined product/service were incorrect under certain circumstances
+FIX: #6541 since 4.0.4 to 5.0.0 autofill zip/town not working
+FIX: #6880 #6925
+FIX: #6885
FIX: #6926
+FIX: #7003
+FIX: #7012
+FIX: #7040
+FIX: #7048 #6075
FIX: Can set supplier invoice to billed.
FIX: Can't create invoice if PO disapproved
FIX: contratligne update
@@ -46,6 +53,7 @@ FIX: Redirect to payment page from member subscription page failed if a unique s
FIX: REST api to get project when user has permission to read all.
FIX: situation_progress param default value must be 100 and not 0
FIX: SQL injection on user/index.php parameter search_statut.
+FIX: vat code not saved during product creation.
FIX: Warnings
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
diff --git a/build/exe/doliwamp/install.forced.php.install b/build/exe/doliwamp/install.forced.php.install
index fd98dbf3984..5b186c17268 100644
--- a/build/exe/doliwamp/install.forced.php.install
+++ b/build/exe/doliwamp/install.forced.php.install
@@ -5,7 +5,7 @@
// during install process to be used.
//
//
-$force_install_noedit=2;
+$force_install_noedit=2; // 1=To block vars specific to distrib, 2 to block all technical parameters
$force_install_message='KeepDefaultValuesWamp';
$force_install_main_data_root='WAMPROOT/dolibarr_documents';
$force_install_type='mysqli';
diff --git a/build/rpm/install.forced.php.fedora b/build/rpm/install.forced.php.fedora
index 108455a9403..a8db3e25c9e 100644
--- a/build/rpm/install.forced.php.fedora
+++ b/build/rpm/install.forced.php.fedora
@@ -1,7 +1,7 @@
';
print '
';
diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php
index e71482b0efa..cb852d82e0c 100644
--- a/htdocs/accountancy/admin/categories_list.php
+++ b/htdocs/accountancy/admin/categories_list.php
@@ -74,7 +74,7 @@ $active = 1;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if ($page == -1) { $page = 0 ; }
+if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $listlimit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php
index 227949a3c1c..9cf4d2977fd 100644
--- a/htdocs/accountancy/admin/defaultaccounts.php
+++ b/htdocs/accountancy/admin/defaultaccounts.php
@@ -1,11 +1,11 @@
- * Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2013-2016 Alexandre Spangaro
- * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
+/* Copyright (C) 2013-2014 Olivier Geffroy
+ * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2013-2017 Alexandre Spangaro
+ * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
* Copyright (C) 2014 Marcos García
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2015 Jean-François Ferry
*
* 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
@@ -23,7 +23,7 @@
*/
/**
- * \file htdocs/accountancy/admin/index.php
+ * \file htdocs/accountancy/admin/defaultaccounts.php
* \ingroup Advanced accountancy
* \brief Setup page to configure accounting expert module
*/
@@ -53,10 +53,10 @@ $action = GETPOST('action', 'alpha');
$list_account_main = array (
'ACCOUNTING_ACCOUNT_CUSTOMER',
'ACCOUNTING_ACCOUNT_SUPPLIER',
+ 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
$list_account = array (
- 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index 2d6ee046bbc..ead997a5d8c 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -51,8 +51,8 @@ $action = GETPOST('action', 'alpha');
$list = array (
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT' ,
- 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
- 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
+// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
+// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
);
@@ -65,28 +65,28 @@ $accounting_mode = defined('ACCOUNTING_MODE') ? ACCOUNTING_MODE : 'RECETTES-DEPE
if ($action == 'update') {
$error = 0;
-
+
$accounting_modes = array (
'RECETTES-DEPENSES',
- 'CREANCES-DETTES'
+ 'CREANCES-DETTES'
);
-
+
$accounting_mode = GETPOST('accounting_mode', 'alpha');
-
+
if (in_array($accounting_mode, $accounting_modes)) {
-
+
if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
-
+
if ($error) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
- foreach ($list as $constname)
+ foreach ($list as $constname)
{
$constvalue = GETPOST($constname, 'alpha');
@@ -267,10 +267,10 @@ if (! empty($user->admin))
// Param a user $user->rights->accountancy->chartofaccount can access
-foreach ($list as $key)
+foreach ($list as $key)
{
print '';
-
+
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
// Param
@@ -280,7 +280,7 @@ foreach ($list as $key)
print '';
print ' ';
print ' ';
-
+
print ' ';
}
diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php
index 3dc932dbab5..dca29fd28b8 100644
--- a/htdocs/accountancy/admin/journals_list.php
+++ b/htdocs/accountancy/admin/journals_list.php
@@ -58,7 +58,7 @@ $active = 1;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if ($page == -1) { $page = 0 ; }
+if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $listlimit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index 5b614061dbc..311aab692ff 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -111,16 +111,16 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
if ($action == 'update') {
if (! empty($btn_changetype)) {
$error = 0;
-
+
$accounting_product_modes = array (
'ACCOUNTANCY_SELL',
- 'ACCOUNTANCY_BUY'
+ 'ACCOUNTANCY_BUY'
);
-
+
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
-
+
if (in_array($accounting_product_mode, $accounting_product_modes)) {
-
+
if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
@@ -128,26 +128,26 @@ if ($action == 'update') {
$error ++;
}
}
-
+
if (! empty($btn_changeaccount)) {
//$msg = '' . $langs->trans("Processing") . '...
';
if (! empty($chk_prod)) {
-
+
$accounting = new AccountingAccount($db);
-
+
//$msg .= '' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
';
-
+
$cpt = 0; $ok = 0; $ko = 0;
foreach ( $chk_prod as $productid ) {
-
+
$accounting_account_id = GETPOST('codeventil_' . $productid);
-
+
$result = $accounting->fetch($accounting_account_id, null, 1);
if ($result < 0) {
// setEventMessages(null, $accounting->errors, 'errors');
$msg .= '' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . ' ' . $sql . ' ';
} else {
-
+
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " SET accountancy_code_buy = " . $accounting->account_number;
@@ -156,7 +156,7 @@ if ($action == 'update') {
$sql .= " SET accountancy_code_sell = " . $accounting->account_number;
}
$sql .= " WHERE rowid = " . $productid;
-
+
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$ok++;
@@ -166,7 +166,7 @@ if ($action == 'update') {
//$msg .= '' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . ' ' . $sql . ' ';
}
}
-
+
$cpt ++;
}
} else {
@@ -258,11 +258,11 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
-if ($result)
+if ($result)
{
$num = $db->num_rows($result);
$i = 0;
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -271,7 +271,7 @@ if ($result)
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
-
+
print '';
-
+
$db->free($result);
} else {
dol_print_error($db);
diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 3c6d2faec94..9be65e7261a 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -37,7 +37,7 @@ $id = GETPOST('id', 'int');
if ($user->societe_id > 0) {
accessforbidden();
}
-$action = GETPOST('action');
+$action = GETPOST('action','aZ09');
$mode = GETPOST('mode');
$piece_num = GETPOST("piece_num");
@@ -500,8 +500,7 @@ if ($action == 'create') {
print " \n";
foreach ( $book->linesmvt as $line ) {
- $var = ! $var;
- print '';
+ print ' ';
$total_debit += $line->debit;
$total_credit += $line->credit;
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 1062fd50d87..16d27df15fd 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -438,7 +438,6 @@ $total_debit = 0;
$total_credit = 0;
foreach ($object->lines as $line ) {
- $var = ! $var;
$total_debit += $line->debit;
$total_credit += $line->credit;
diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index db75947771e..7668756a046 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -429,4 +429,158 @@ class AccountancyCategory
return - 1;
}
}
+
+ public function getCats() {
+ global $db, $langs, $user, $mysoc;
+
+ if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
+ dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
+ exit();
+ }
+
+ if (! empty($mysoc->country_id)) {
+ $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
+ $sql .= " WHERE c.active = 1 ";
+ $sql .= " AND c.fk_country = " . $mysoc->country_id;
+ $sql .= " ORDER BY c.position ASC";
+ } else {
+ $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co";
+ $sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid";
+ $sql .= " AND co.code = '" . $mysoc->country_code . "'";
+ $sql .= " ORDER BY c.position ASC";
+ }
+
+ dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $i = 0;
+ $obj = '';
+ $num = $this->db->num_rows($resql);
+ $data = array ();
+ if ($num) {
+ while ( $i < $num ) {
+ $obj = $this->db->fetch_object($resql);
+
+ $data[] = array (
+ 'rowid' => $obj->rowid,
+ 'code' => $obj->code,
+ 'position' => $obj->position,
+ 'label' => $obj->label,
+ 'formula' => $obj->formula,
+ 'category_type' => $obj->category_type
+ );
+ $i ++;
+ }
+ }
+ return $data;
+ } else {
+ $this->error = "Error " . $this->db->lasterror();
+ $this->errors[] = $this->error;
+ dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR);
+
+ return - 1;
+ }
+ }
+
+
+ // calcule
+
+ const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/';
+
+ const PARENTHESIS_DEPTH = 10;
+
+ public function calculate($input){
+ if(strpos($input, '+') != null || strpos($input, '-') != null || strpos($input, '/') != null || strpos($input, '*') != null){
+ // Remove white spaces and invalid math chars
+ $input = str_replace(',', '.', $input);
+ $input = preg_replace('[^0-9\.\+\-\*\/\(\)]', '', $input);
+
+ // Calculate each of the parenthesis from the top
+ $i = 0;
+ while(strpos($input, '(') || strpos($input, ')')){
+ $input = preg_replace_callback('/\(([^\(\)]+)\)/', 'self::callback', $input);
+
+ $i++;
+ if($i > self::PARENTHESIS_DEPTH){
+ break;
+ }
+ }
+
+ // Calculate the result
+ if(preg_match(self::PATTERN, $input, $match)){
+ return $this->compute($match[0]);
+ }
+
+ return 0;
+ }
+
+ return $input;
+ }
+
+ private function compute($input){
+ $compute = create_function('', 'return '.$input.';');
+
+ return 0 + $compute();
+ }
+
+ private function callback($input){
+ if(is_numeric($input[1])){
+ return $input[1];
+ }
+ elseif(preg_match(self::PATTERN, $input[1], $match)){
+ return $this->compute($match[0]);
+ }
+
+ return 0;
+ }
+
+ /**
+ * get cpts of category
+ *
+ * @return array Result in table
+ */
+ public function getCptsCat($cat_id) {
+ global $mysoc;
+ $sql = "";
+
+ if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
+ dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
+ exit();
+ }
+
+ $sql = "SELECT t.rowid, t.account_number, t.label as name_cpt";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
+ $sql .= " WHERE t.fk_accounting_category = ".$cat_id;
+ $sql .= " ORDER BY t.account_number ";
+
+ //echo $sql;
+
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $i = 0;
+ $obj = '';
+ $num = $this->db->num_rows($resql);
+ $data = array ();
+ if ($num) {
+ while ( $obj = $this->db->fetch_object($resql) ) {
+ $name_cat = $obj->name_cat;
+ $data[] = array (
+ 'id' => $obj->rowid,
+ 'account_number' => $obj->account_number,
+ 'name_cpt' => $obj->name_cpt,
+ );
+ $i ++;
+ }
+ }
+ return $data;
+ } else {
+ $this->error = "Error " . $this->db->lasterror();
+ dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
+
+ return -1;
+ }
+ }
+
}
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 843e15a5dd7..51ef317e917 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -270,7 +270,7 @@ class BookKeeping extends CommonObject
$sql .= ", montant";
$sql .= ", sens";
$sql .= ", fk_user_author";
- $sql .= ", import_key";
+ $sql .= ", date_creation";
$sql .= ", code_journal";
$sql .= ", journal_label";
$sql .= ", piece_num";
@@ -430,6 +430,11 @@ class BookKeeping extends CommonObject
if (empty($this->debit)) $this->debit = 0;
if (empty($this->credit)) $this->credit = 0;
+ $now = dol_now();
+ if (empty($this->date_create)) {
+ $this->date_create = $now;
+ }
+
// Check parameters
// Put here code to add control on parameters values
@@ -451,7 +456,7 @@ class BookKeeping extends CommonObject
$sql .= 'montant,';
$sql .= 'sens,';
$sql .= 'fk_user_author,';
- $sql .= 'import_key,';
+ $sql .= 'date_creation,';
$sql .= 'code_journal,';
$sql .= 'journal_label,';
$sql .= 'piece_num,';
@@ -473,7 +478,7 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ',';
$sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ',';
$sql .= ' ' . $user->id . ',';
- $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ',';
+ $sql .= ' ' . "'" . $this->db->idate($this->date_create) . "',";
$sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
$sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ',';
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).',';
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 817811cd0fc..9af3d0d19d9 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -1,9 +1,9 @@
+/* Copyright (C) 2013 Olivier Geffroy
* Copyright (C) 2013-2014 Florian Henry
* Copyright (C) 2013-2016 Alexandre Spangaro
* Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2015 Jean-François Ferry
*
* 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
@@ -40,7 +40,7 @@ $langs->load("accountancy");
// Security check
if (empty($conf->accounting->enabled)) {
- accessforbidden();
+ accessforbidden();
}
if ($user->societe_id > 0)
accessforbidden();
@@ -187,7 +187,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
}
-$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
+$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
@@ -203,10 +203,6 @@ $buttonbind = '' . $langs->trans("CleanHistory", $year_current) . ' ';
-
-
-$var = true;
-
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '';
@@ -269,14 +265,14 @@ print '';
print '' . $langs->trans("Account") . ' ';
print '' . $langs->trans("Label") . ' ';
for($i = 1; $i <= 12; $i ++) {
- print '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . ' ';
+ print '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . ' ';
}
print '' . $langs->trans("Total") . ' ';
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
- $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
+ $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
$sql .= " SUM(fd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
@@ -296,22 +292,22 @@ $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
- $num = $db->num_rows($resql);
+ $num = $db->num_rows($resql);
- while ( $row = $db->fetch_row($resql)) {
+ while ( $row = $db->fetch_row($resql)) {
- print '' . length_accountg($row[0]) . ' ';
- print '' . $row[1] . ' ';
- for($i = 2; $i <= 12; $i ++) {
- print '' . price($row[$i]) . ' ';
- }
- print '' . price($row[13]) . ' ';
- print '' . price($row[14]) . ' ';
- print ' ';
- }
- $db->free($resql);
+ print '' . length_accountg($row[0]) . ' ';
+ print '' . $row[1] . ' ';
+ for($i = 2; $i <= 12; $i ++) {
+ print '' . price($row[$i]) . ' ';
+ }
+ print '' . price($row[13]) . ' ';
+ print '' . price($row[14]) . ' ';
+ print ' ';
+ }
+ $db->free($resql);
} else {
- print $db->lasterror(); // Show last sql error
+ print $db->lasterror(); // Show last sql error
}
print "
\n";
@@ -319,101 +315,101 @@ print "
\n";
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
{
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
- print_fiche_titre($langs->trans("OtherInfo"), '', '');
+ print_fiche_titre($langs->trans("OtherInfo"), '', '');
- print " \n";
- print '';
- print '' . $langs->trans("TotalVente") . ' ';
- for($i = 1; $i <= 12; $i ++) {
- print '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . ' ';
- }
- print '' . $langs->trans("Total") . ' ';
+ print " \n";
+ print '';
+ print '' . $langs->trans("TotalVente") . ' ';
+ for($i = 1; $i <= 12; $i ++) {
+ print '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . ' ';
+ }
+ print '' . $langs->trans("Total") . ' ';
- $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
- for($i = 1; $i <= 12; $i ++) {
- $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
- }
- $sql .= " SUM(fd.total_ht) as total";
- $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
- $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
- $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
- $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
- } else {
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
- }
+ $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
+ for($i = 1; $i <= 12; $i ++) {
+ $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
+ }
+ $sql .= " SUM(fd.total_ht) as total";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
+ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
+ $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
+ $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
+ } else {
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+ }
- dol_syslog('htdocs/accountancy/customer/index.php');
- $resql = $db->query($sql);
- if ($resql) {
- $i = 0;
- $num = $db->num_rows($resql);
+ dol_syslog('htdocs/accountancy/customer/index.php');
+ $resql = $db->query($sql);
+ if ($resql) {
+ $i = 0;
+ $num = $db->num_rows($resql);
- while ($row = $db->fetch_row($resql)) {
- print '' . $row[0] . ' ';
- for($i = 1; $i <= 12; $i ++) {
- print '' . price($row[$i]) . ' ';
- }
- print '' . price($row[13]) . ' ';
- print ' ';
- $i ++;
- }
- $db->free($resql);
- } else {
- print $db->lasterror(); // Show last sql error
- }
- print "
\n";
+ while ($row = $db->fetch_row($resql)) {
+ print '' . $row[0] . ' ';
+ for($i = 1; $i <= 12; $i ++) {
+ print '' . price($row[$i]) . ' ';
+ }
+ print '' . price($row[13]) . ' ';
+ print ' ';
+ $i ++;
+ }
+ $db->free($resql);
+ } else {
+ print $db->lasterror(); // Show last sql error
+ }
+ print "
\n";
- if (! empty($conf->margin->enabled)) {
- print " \n";
- print '';
- print '' . $langs->trans("TotalMarge") . ' ';
- for($i = 1; $i <= 12; $i ++) {
- print '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . ' ';
- }
- print '' . $langs->trans("Total") . ' ';
+ if (! empty($conf->margin->enabled)) {
+ print " \n";
+ print '';
+ print '' . $langs->trans("TotalMarge") . ' ';
+ for($i = 1; $i <= 12; $i ++) {
+ print '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . ' ';
+ }
+ print '' . $langs->trans("Total") . ' ';
- $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
- for($i = 1; $i <= 12; $i ++) {
- $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
- }
- $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
- $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
- $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
- $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
- $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
- } else {
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
- }
+ $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
+ for($i = 1; $i <= 12; $i ++) {
+ $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
+ }
+ $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
+ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
+ $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
+ $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
+ } else {
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+ }
- dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
- $resql = $db->query($sql);
- if ($resql) {
- $num = $db->num_rows($resql);
+ dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
+ $resql = $db->query($sql);
+ if ($resql) {
+ $num = $db->num_rows($resql);
- while ($row = $db->fetch_row($resql)) {
+ while ($row = $db->fetch_row($resql)) {
- print '' . $row[0] . ' ';
- for($i = 1; $i <= 12; $i ++) {
- print '' . price(price2num($row[$i])) . ' ';
- }
- print '' . price(price2num($row[13])) . ' ';
- print ' ';
- }
- $db->free($resql);
- } else {
- print $db->lasterror(); // Show last sql error
- }
- print "
\n";
- }
+ print '' . $row[0] . ' ';
+ for($i = 1; $i <= 12; $i ++) {
+ print '' . price(price2num($row[$i])) . ' ';
+ }
+ print '' . price(price2num($row[13])) . ' ';
+ print ' ';
+ }
+ $db->free($resql);
+ } else {
+ print $db->lasterror(); // Show last sql error
+ }
+ print "
\n";
+ }
}
diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index b5778ce86f2..d6d006c6556 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -121,7 +121,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
}
-
+
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
@@ -240,7 +240,7 @@ if ($result) {
if ($search_tvaintra)
$param .= "&search_tvaintra=" . $search_tvaintra;
-
+
print '';
} else {
print $db->lasterror();
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 85a97fb3a1e..75c1a59aa30 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -144,10 +144,10 @@ if ($massaction == 'ventil') {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
-
+
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
-
+
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
';
@@ -157,7 +157,7 @@ if ($massaction == 'ventil') {
$ko++;
}
}
-
+
$cpt++;
}
$msg.='';
@@ -375,10 +375,10 @@ if ($result) {
print '';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
- $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
+ $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
print ' ';
-
+
print '';
print price($objp->total_ht);
print ' ';
@@ -404,7 +404,7 @@ if ($result) {
print '';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' ';
-
+
print '';
print ' aarowid ? "checked" : "") . '/>';
print ' ';
diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php
index e9ce1b2e729..fdbf4d1ce4b 100644
--- a/htdocs/accountancy/expensereport/index.php
+++ b/htdocs/accountancy/expensereport/index.php
@@ -178,9 +178,6 @@ $buttonreset = '
* Copyright (C) 2013-2017 Alexandre Spangaro
- * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
+ * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
* Copyright (C) 2013-2016 Florian Henry
* Copyright (C) 2014 Juanjo Menent
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -94,13 +94,13 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
-
+
$db->begin();
-
+
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')';
-
+
dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
@@ -193,7 +193,7 @@ $result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -210,8 +210,8 @@ if ($result) {
if ($search_country)
$param .= "&search_country=" . $search_country;
if ($search_tvaintra)
- $param .= "&search_tvaintra=" . $search_tvaintra;
-
+ $param .= "&search_tvaintra=" . $search_tvaintra;
+
print '';
} else {
print $db->error();
diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php
index 7fb5f26b28b..8e7b9c60c92 100644
--- a/htdocs/accountancy/expensereport/list.php
+++ b/htdocs/accountancy/expensereport/list.php
@@ -139,10 +139,10 @@ if ($massaction == 'ventil') {
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
-
+
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
-
+
dol_syslog('accountancy/expensereport/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
';
@@ -152,7 +152,7 @@ if ($massaction == 'ventil') {
$ko++;
}
}
-
+
$cpt++;
}
$msg.='';
@@ -224,7 +224,7 @@ if ($result) {
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
-
+
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -237,8 +237,8 @@ if ($result) {
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
-
-
+
+
print ' \n";
-
-
+
+
$expensereport_static = new ExpenseReport($db);
$form = new Form($db);
@@ -323,7 +323,7 @@ if ($result) {
// Fees description -- Can be null
print '';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
- $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
+ $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->comments);
print ' ';
@@ -356,7 +356,7 @@ if ($result) {
print '';
print "";
-
+
print '';
} else {
print $db->error();
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index bc27ebfa24f..ed8d1d7501a 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -72,10 +72,10 @@ $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
-$action = GETPOST('action','aZ09');
+$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now();
-$action = GETPOST('action','aZ09');
+$action = GETPOST('action','alpha');
// Security check
if ($user->societe_id > 0 && empty($id_journal))
@@ -121,6 +121,8 @@ $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal;
$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
if ($date_start && $date_end)
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
+if ($in_bookkeeping == 'yes')
+ $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
$sql .= " ORDER BY b.datev";
$object = new Account($db);
@@ -366,6 +368,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = $val["label"];
+ $bookkeeping->label_compte = $langs->trans("Bank");
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
@@ -473,6 +476,18 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->date_create = $now;
if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
+ $sqlmid = 'SELECT ch.libelle, t.libelle as labelc';
+ $sqlmid .= " FROM " . MAIN_DB_PREFIX . "chargesociales ch ";
+ $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paych ON paych.fk_charge=ch.rowid";
+ $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "c_chargesociales as t ON ch.fk_type=t.id";
+ $sqlmid .= " WHERE paych.fk_bank=" . $key;
+ dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
+ $resultmid = $db->query($sqlmid);
+ if ($resultmid) {
+ $objmid = $db->fetch_object($resultmid);
+ $bookkeeping->label_compte = $objmid->labelc;
+ $bookkeeping->doc_ref = $objmid->libelle ;
+ }
$bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
@@ -597,7 +612,6 @@ if (! $error && $action == 'writebookkeeping') {
}
// Export
-/*
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
@@ -606,165 +620,101 @@ if ($action == 'export_csv') {
$companystatic = new Client($db);
$userstatic = new User($db);
- // Model Cegid Expert Export
- if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
- {
- $sep = ";";
+ // Bank
+ foreach ( $tabpay as $key => $val ) {
+ $date = dol_print_date($db->jdate($val["date"]), 'day');
- foreach ( $tabpay as $key => $val ) {
- $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
-
- $reflabel = $val["ref"];
- if ($reflabel == '(SupplierInvoicePayment)') {
- $reflabel = $langs->trans('Supplier');
- }
- if ($reflabel == '(CustomerInvoicePayment)') {
- $reflabel = $langs->trans('Customer');
- }
- if ($reflabel == '(SocialContributionPayment)') {
- $reflabel = $langs->trans('SocialContribution');
- }
- if ($reflabel == '(DonationPayment)') {
- $reflabel = $langs->trans('Donation');
- }
- if ($reflabel == '(SubscriptionPayment)') {
- $reflabel = $langs->trans('Subscription');
- }
- if ($reflabel == '(ExpenseReportPayment)') {
- $reflabel = $langs->trans('Employee');
- }
-
- $companystatic->id = $tabcompany[$key]['id'];
- $companystatic->name = $tabcompany[$key]['name'];
-
- $userstatic->id = $tabuser[$key]['id'];
- $userstatic->lastname = $tabuser[$key]['lastname'];
- $userstatic->firstname = $tabuser[$key]['firstname'];
-
- // Bank
- foreach ( $tabbq[$key] as $k => $mt ) {
- print $date . $sep;
- print $journal . $sep;
- print length_accountg(html_entity_decode($k)) . $sep;
- print $sep;
- print ($mt < 0 ? 'C' : 'D') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- if ($companystatic->name == '') {
- print $langs->trans('Bank')." - ". utf8_decode($val["ref"]) . $sep;
- } else {
- print $langs->trans("Bank") .' - '.utf8_decode($companystatic->name) . $sep;
- }
- print utf8_decode($reflabel) . $sep;
- print "\n";
- }
-
- // Third party
- if (is_array($tabtp[$key])) {
- foreach ( $tabtp[$key] as $k => $mt ) {
- if ($mt) {
- print $date . $sep;
- print $journal . $sep;
- if ($tabtype[$key] == 'payment') {
- print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
- print length_accounta(html_entity_decode($k)) . $sep;
- } else if ($tabtype[$key] == 'payment_supplier') {
- print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
- print length_accounta(html_entity_decode($k)) . $sep;
- } else {
- print length_accountg(html_entity_decode($k)) . $sep;
- print $sep;
- }
- print ($mt < 0 ? 'D' : 'C') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- if ($companystatic->name == '') {
- print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep;
- } else {
- print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep;
- }
- print utf8_decode($reflabel) . $sep;
- print "\n";
- }
- }
- } else {
- foreach ( $tabbq[$key] as $k => $mt ) {
- print $date . $sep;
- print $journal . $sep;
- print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep;
- print $sep;
- print ($mt < 0 ? 'D' : 'C') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- if ($companystatic->name == '') {
- print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep;
- } else {
- print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep;
- }
- print utf8_decode($reflabel) . $sep;
- print "\n";
- }
- }
+ $reflabel = $val["ref"];
+ if ($reflabel == '(SupplierInvoicePayment)') {
+ $reflabel = $langs->trans('Supplier');
+ }
+ if ($reflabel == '(CustomerInvoicePayment)') {
+ $reflabel = $langs->trans('Customer');
+ }
+ if ($reflabel == '(SocialContributionPayment)') {
+ $reflabel = $langs->trans('SocialContribution');
+ }
+ if ($reflabel == '(DonationPayment)') {
+ $reflabel = $langs->trans('Donation');
+ }
+ if ($reflabel == '(SubscriptionPayment)') {
+ $reflabel = $langs->trans('Subscription');
+ }
+ if ($reflabel == '(ExpenseReportPayment)') {
+ $reflabel = $langs->trans('Employee');
}
- } else {
- // Model Classic Export
- foreach ( $tabpay as $key => $val ) {
- $date = dol_print_date($db->jdate($val["date"]), 'day');
- $companystatic->id = $tabcompany[$key]['id'];
- $companystatic->name = $tabcompany[$key]['name'];
+ $companystatic->id = $tabcompany[$key]['id'];
+ $companystatic->name = $tabcompany[$key]['name'];
- // Bank
- foreach ( $tabbq[$key] as $k => $mt ) {
- print '"' . $journal . '"' . $sep;
- print '"' . $date . '"' . $sep;
- print '"' . $val["type_payment"] . '"' . $sep;
- print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- if ($companystatic->name == '') {
- print '"' . $langs->trans('Bank') . " - " . utf8_decode($val["ref"]) . '"' . $sep;
- } else {
- print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
- }
- print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
- print "\n";
- }
-
- // Third party
- if (is_array($tabtp[$key])) {
- foreach ( $tabtp[$key] as $k => $mt ) {
- if ($mt) {
- print '"' . $journal . '"' . $sep;
- print '"' . $date . '"' . $sep;
- print '"' . $val["type_payment"] . '"' . $sep;
- print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
- if ($companystatic->name == '') {
- print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($val["ref"]) . '"' . $sep;
- } else {
- print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
- }
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
- print '"' . ($mt >= 0 ? price($mt) : '') . '"';
- print "\n";
- }
- }
+ // Bank
+ foreach ( $tabbq[$key] as $k => $mt ) {
+ print '"' . $journal . '"' . $sep;
+ print '"' . $date . '"' . $sep;
+ print '"' . $val["type_payment"] . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print " " . $sep;
+ if ($companystatic->name == '') {
+ print '"' . $langs->trans('Bank') . " - " . utf8_decode($reflabel) . '"' . $sep;
} else {
- foreach ( $tabbq[$key] as $k => $mt ) {
+ print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
+ }
+ print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
+ print "\n";
+ }
+
+ // Third party
+ if (is_array($tabtp[$key])) {
+ foreach ( $tabtp[$key] as $k => $mt ) {
+ if ($mt) {
print '"' . $journal . '"' . $sep;
print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
- print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
- if ($companystatic->name == '') {
- print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($val["ref"]) . '"' . $sep;
+ print '"' . $val["type_payment"] . '"' . $sep;
+ print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+
+ if ($tabtype[$key] == 'payment_supplier') {
+ print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
+ } else if($tabtype[$key] == 'payment') {
+ print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
} else {
- print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
+ print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+ }
+
+
+
+ print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+ if ($companystatic->name == '') {
+ print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep;
+ } else {
+ print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
}
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
}
+ } else {
+ foreach ( $tabbq[$key] as $k => $mt ) {
+ print '"' . $journal . '"' . $sep;
+ print '"' . $date . '"' . $sep;
+ print '"' . $val["ref"] . '"' . $sep;
+ print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
+ print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
+ print " " . $sep;
+ if ($companystatic->name == '') {
+ print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($reflabel) . '"' . $sep;
+ } else {
+ print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
+ }
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
+ print '"' . ($mt >= 0 ? price($mt) : '') . '"';
+ print "\n";
+ }
}
}
}
-*/
/*
@@ -788,7 +738,7 @@ if (empty($action) || $action == 'view') {
$builddate = time();
//$description = $langs->trans("DescFinanceJournal") . ' ';
$description.= $langs->trans("DescJournalOnlyBindedVisible").' ';
- $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
+ $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
$varlink = 'id_journal=' . $id_journal;
@@ -802,6 +752,7 @@ if (empty($action) || $action == 'view') {
print '';
print ' ';
+ print ' ';
print '
';
// TODO Avoid using js. We can use a direct link with $param
@@ -863,6 +814,9 @@ if (empty($action) || $action == 'view') {
if ($reflabel == '(ExpenseReportPayment)') {
$reflabel = $langs->trans('Employee');
}
+ if ($reflabel == '(payment_salary)') {
+ $reflabel = $langs->trans('Employee');
+ }
$ref=$reflabel;
if ($tabtype[$key] == 'payment')
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index cbe793deb63..e023e14a817 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -43,7 +43,7 @@ $langs->load("main");
$langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int');
-$action = GETPOST('action','aZ09');
+$action = GETPOST('action','alpha');
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
@@ -51,6 +51,7 @@ $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
+$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now();
@@ -108,6 +109,8 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
}
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
+if ($in_bookkeeping == 'yes')
+ $sql .= " AND (f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice') )";
$sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/purchasesjournal.php:: $sql=' . $sql);
@@ -385,69 +388,15 @@ if ($action == 'writebookkeeping') {
$form = new Form($db);
$companystatic = new Fournisseur($db);
+$invoicestatic = new FactureFournisseur($db);
// Export
-/*if ($action == 'export_csv') {
+if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
- // Model Cegid Expert Export
- if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
- $sep = ";";
-
- foreach ( $tabfac as $key => $val ) {
- $date = dol_print_date($val["date"], '%d%m%Y');
-
- // Product / Service
- foreach ( $tabht[$key] as $k => $mt ) {
- $companystatic->id = $tabcompany[$key]['id'];
- $companystatic->name = $tabcompany[$key]['name'];
- $companystatic->client = $tabcompany[$key]['code_client'];
-
- if ($mt) {
- print $date . $sep;
- print $purchase_journal . $sep;
- print length_accountg(html_entity_decode($k)) . $sep;
- print $sep;
- print ($mt < 0 ? 'C' : 'D') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print dol_trunc($val["description"], 32) . $sep;
- print $val["ref"];
- print "\n";
- }
- }
-
- // VAT
- foreach ( $tabtva[$key] as $k => $mt ) {
- if ($mt) {
- print $date . $sep;
- print $purchase_journal . $sep;
- print length_accountg(html_entity_decode($k)) . $sep;
- print $sep;
- print ($mt < 0 ? 'C' : 'D') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print $langs->trans("VAT") . $sep;
- print $val["ref"];
- print "\n";
- }
- }
-
- foreach ( $tabttc[$key] as $k => $mt ) {
- print $date . $sep;
- print $purchase_journal . $sep;
- print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
- print length_accounta(html_entity_decode($k)) . $sep;
- print ($mt < 0 ? 'D' : 'C') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print $companystatic->name . $sep;
- print $val["ref"];
- print "\n";
- }
- }
- } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
- // Model Classic Export
foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key;
@@ -468,44 +417,60 @@ $companystatic = new Fournisseur($db);
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
if ($mt) {
+ print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
+ print '"' . $val["refsuppliersologest"] . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
- // print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print " " . $sep;
+ print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
+ print '"' . $journal_label . '"' ;
print "\n";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
+ print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
+ print '"' . $val["refsuppliersologest"] . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- // print '"' . $langs->trans("VAT") . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print " " . $sep;
+ print '"' . $langs->trans("VAT") . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
+ print '"' . $journal_label . '"' ;
print "\n";
}
}
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
+ print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
+ print '"' . $val["refsuppliersologest"] . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("subledger_account") . '"' . $sep;
+ print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
+ print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+ print '"' . $langs->trans("Code_tiers") . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
- print '"' . ($mt >= 0 ? price($mt) : '') . '"';
+ print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
+ print '"' . $journal_label . '"' ;
+ print "\n";
}
- print "\n";
+
}
}
-}
-*/
+
if (empty($action) || $action == 'view') {
@@ -524,7 +489,7 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreIncluded");
}
- $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
+ $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
$varlink = 'id_journal=' . $id_journal;
@@ -548,6 +513,7 @@ if (empty($action) || $action == 'view') {
else {
print ' ';
}
+ print ' ';
print '';
print '
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index cf92905e041..edaf3a87f27 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -46,7 +46,7 @@ $langs->load("main");
$langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int');
-$action = GETPOST('action','aZ09');
+$action = GETPOST('action','alpha');
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
@@ -54,6 +54,7 @@ $date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
+$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now();
@@ -113,6 +114,8 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
+if ($in_bookkeeping == 'yes')
+ $sql .= " AND (f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice') )";
$sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
@@ -401,76 +404,18 @@ if ($action == 'writebookkeeping') {
$form = new Form($db);
// Export
-/*if ($action == 'export_csv') {
+if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
+
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db);
+ $invoicestatic = new Facture($db);
- // Model Cegid Expert Export
- if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
- $sep = ";";
-
- foreach ( $tabfac as $key => $val ) {
- $companystatic->id = $tabcompany[$key]['id'];
- $companystatic->name = $tabcompany[$key]['name'];
- $companystatic->client = $tabcompany[$key]['code_client'];
-
- $invoicestatic->id = $key;
- $invoicestatic->ref = $val["ref"];
-
- $date = dol_print_date($val["date"], '%d%m%Y');
-
- foreach ( $tabttc[$key] as $k => $mt ) {
- print $date . $sep;
- print $sell_journal . $sep;
- print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
- print length_accounta(html_entity_decode($k)) . $sep;
- print ($mt < 0 ? 'C' : 'D') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . $sep;
- print $val["ref"];
- print "\n";
- }
-
- // Product / Service
- foreach ( $tabht[$key] as $k => $mt ) {
- $accountingaccount_static = new AccountingAccount($db);
- if ($accountingaccount_static->fetch(null, $k, true)) {
- print $date . $sep;
- print $sell_journal . $sep;
- print length_accountg(html_entity_decode($k)) . $sep;
- print $sep;
- print ($mt < 0 ? 'D' : 'C') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep;
- print $val["ref"];
- print "\n";
- }
- }
-
- // TVA
- foreach ( $tabtva[$key] as $k => $mt ) {
- if ($mt) {
- print $date . $sep;
- print $sell_journal . $sep;
- print length_accountg(html_entity_decode($k)) . $sep;
- print $sep;
- print ($mt < 0 ? 'D' : 'C') . $sep;
- print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
- // print $langs->trans("VAT") . $sep;
- print $val["ref"];
- print "\n";
- }
- }
- }
- } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
- // Model Classic Export
- foreach ( $tabfac as $key => $val ) {
+ foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
@@ -481,13 +426,19 @@ $form = new Form($db);
$date = dol_print_date($val["date"], 'day');
foreach ( $tabttc[$key] as $k => $mt ) {
- print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
- print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . '"' . $sep;
- print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
- print "\n";
+ print '"' . $key . '"' . $sep;
+ print '"' . $date . '"' . $sep;
+ print '"' . $val["ref"] . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
+ print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+ print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
+ print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
+ print '"' . $langs->trans("Code_tiers") . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
+ print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
+ print '"' . $sell_journal . '"' ;
+ print "\n";
}
// Product / Service
@@ -495,33 +446,48 @@ $form = new Form($db);
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
+
if ($mt) {
- print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
- print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
- print '"' . ($mt >= 0 ? price($mt) : '') . '"';
- print "\n";
+ print '"' . $key . '"' . $sep;
+ print '"' . $date . '"' . $sep;
+ print '"' . $val["ref"] . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print " " . $sep;
+ print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
+ print '"' . utf8_decode (dol_trunc($companystatic->name, 16) ) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
+ print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
+ print '"' . $sell_journal . '"' ;
+ print "\n";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
+
+
+
if ($mt) {
- print '"' . $date . '"' . $sep;
- print '"' . $val["ref"] . '"' . $sep;
- print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
- print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
- print '"' . ($mt >= 0 ? price($mt) : '') . '"';
- print "\n";
+ print '"' . $key . '"' . $sep;
+ print '"' . $date . '"' . $sep;
+ print '"' . $val["ref"] . '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
+ print " " . $sep;
+ print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key]. '"' . $sep;
+ print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ). ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
+ print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
+ print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
+ print '"' . $sell_journal . '"' ;
+ print "\n";
}
}
- }
}
-}
-*/
+ }
+
if (empty($action) || $action == 'view') {
@@ -539,18 +505,12 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreNotIncluded");
else
$description .= $langs->trans("DepositsAreIncluded");
- $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
+ $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
$varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
- /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
- print ' ';
- } else {
- print ' ';
- }*/
-
// Button to write into Ledger
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
@@ -563,6 +523,7 @@ if (empty($action) || $action == 'view') {
else {
print ' ';
}
+ print ' ';
print '';
print '
diff --git a/htdocs/accountancy/report/result.php b/htdocs/accountancy/report/result.php
index 801ba0a2007..b8335e2d8f7 100644
--- a/htdocs/accountancy/report/result.php
+++ b/htdocs/accountancy/report/result.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2016 Alexandre Spangaro
+/* Copyright (C) 2016/17 Jamal Elbaz
+ * Copyright (C) 2016 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
@@ -25,6 +25,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
@@ -41,6 +42,8 @@ $selectcpt = GETPOST('cpt_bk');
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel');
+$simple_report = GETPOST('simple_report');
+
// Filter
$year = GETPOST('year','int');
@@ -77,7 +80,16 @@ $form = new Form($db);
$textprevyear = '' . img_previous() . ' ';
$textnextyear = ' ' . img_next() . ' ';
-print load_fiche_titre($langs->trans('ReportInOut'), $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, 'title_accountancy');
+ $nom = $langs->trans("ReportInOut");
+ $nomlink = '';
+ $periodlink = '';
+ $exportlink = '';
+ $builddate = time();
+ $description = '';
+ $period = $langs->trans("Detail").' '. $form->selectyesno('simple_report',$simple_report,0) . " " .$textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear ;
+report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
+ 'action' => ''
+ ));
$moreforfilter='';
@@ -108,37 +120,97 @@ foreach($months as $k => $v){
}
print '';
-$cats = $AccCat->getCatsCpts();
-if ($cats < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
-$catsCalcule = $AccCat->getCatsCal();
+
+//All categories
+$cats = $AccCat->getCats();
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
$j=1;
$sommes = array();
-if (!empty($cats))
-{
- foreach ($cats as $name_cat => $cpts)
- {
+foreach($cats as $cat ){
+ if(!empty($cat['category_type'])){ // category calculed
+
+ $formula = $cat['formula'];
+
print "";
- print '' . $name_cat . ' ';
+ print '' . $cat['label'] . ' ';
+
+ $vars = array();
+
+ // Previous Fiscal year (N-1)
+ foreach($sommes as $code => $det){
+ $vars[$code] = $det['NP'];
+ }
+
+
+ $result = strtr($formula, $vars);
+
+
+ $r = $AccCat->calculate($result);
+
+ print '' . price($r) . ' ';
+ $code = $cat['code']; // code categorie de calcule
+ $sommes[$code]['NP'] += $r;
+
+ // Current fiscal year (N)
+ if (is_array($sommes) && ! empty($sommes)){
+ foreach($sommes as $code => $det){
+ $vars[$code] = $det['N'];
+ }
+ }
+
+ $result = strtr($formula, $vars);
+
+ $r = $AccCat->calculate($result);
+
+ print '' . price($r) . ' ';
+ $sommes[$code]['N'] += $r;
+
+ // Detail by month
+ foreach($months as $k => $v){
+ foreach($sommes as $code => $det){
+ $vars[$code] = $det['M'][$k];
+ }
+ $result = strtr($formula, $vars);
+ $r = $AccCat->calculate($result);
+ print '' . price($r) . ' ';
+ $sommes[$code]['M'][$k] += $r;
+ }
+
+
print " \n";
- $position = -1;
- $code = -1;
+
+
+ }else{ // normal category
+
+ $totCat = array();
+ $totCat['M'] = array();
+
+ // get cpts of category
+ $cpts = $AccCat->getCptsCat($cat['rowid']);
+
+
+ print "";
+ print '' . $cat['label'] . ' ';
+
foreach($cpts as $i => $cpt){
+ $var = ! $var;
- $position = $cpt['position'];
- $code = $cpt['code'];
-
+ $code = $cat['code'];
+
+ // N-1
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
+
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultNP=0;
} else {
$resultNP=$AccCat->sdc;
}
-
+
+ //N
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
@@ -146,13 +218,64 @@ if (!empty($cats))
} else {
$resultN=$AccCat->sdc;
}
+
+ $totCat['NP'] += $resultNP;
+ $totCat['N'] += $resultN;
+
+ foreach($months as $k => $v){
+ $return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
+ if ($return < 0) {
+ setEventMessages(null, $AccCat->errors, 'errors');
+ $resultM=0;
+ } else {
+ $resultM=$AccCat->sdc;
+ }
+ $totCat['M'][$k] += $resultM;
+
+ }
+ }
+
+ print '' . price($totCat['NP']) . ' ';
+ print '' . price($totCat['N']) . ' ';
+
+ foreach($totCat['M'] as $k => $v){
+ print '' . price($v) . ' ';
+ }
+ print " \n";
+
+ foreach($cpts as $i => $cpt){
+ $var = ! $var;
+
+ $code = $cat['code'];
+
+ // N-1
+ $return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
+
+ if ($return < 0) {
+ setEventMessages(null, $AccCat->errors, 'errors');
+ $resultNP=0;
+ } else {
+ $resultNP=$AccCat->sdc;
+ }
+
+ //N
+ $return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
+ if ($return < 0) {
+ setEventMessages(null, $AccCat->errors, 'errors');
+ $resultN=0;
+ } else {
+ $resultN=$AccCat->sdc;
+ }
+
$sommes[$code]['NP'] += $resultNP;
$sommes[$code]['N'] += $resultN;
- print '';
- print '' . $cpt['account_number'] . ' ';
+ print ' ';
+ if ($simple_report == 'yes') {
+ print '' . length_accountg($cpt['account_number']) . ' ';
print '' . $cpt['name_cpt'] . ' ';
- print '' . price($resultNP) . ' ';
- print '' . price($resultN) . ' ';
+ print '' . price($resultNP) . ' ';
+ print '' . price($resultN) . ' ';
+ }
foreach($months as $k => $v){
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
@@ -163,102 +286,15 @@ if (!empty($cats))
$resultM=$AccCat->sdc;
}
$sommes[$code]['M'][$k] += $resultM;
+ if ($simple_report == 'yes') {
print '' . price($resultM) . ' ';
- }
-
- print " \n";
- }
-
- // If it's a calculated catgory
- $p = $position + 1;
- if(array_key_exists($p, $catsCalcule)){
- $formula = $catsCalcule[$p]['formula'];
-
- print "";
- print '' . $catsCalcule[$p]['label'] . ' ';
-
- $vars = array();
-
- // Previous Fiscal year (N-1)
- foreach($sommes as $code => $det){
- $vars[$code] = $det['NP'];
- }
- $result = strtr($formula, $vars);
- eval( '$result = (' . $result . ');' );
- print '' . price($result) . ' ';
- $code = $catsCalcule[$p]['code']; // code categorie de calcule
- $sommes[$code]['NP'] += $result;
-
- // Current fiscal year (N)
- foreach($sommes as $code => $det){
- $vars[$code] = $det['N'];
- }
- $result = strtr($formula, $vars);
- eval( '$result = (' . $result . ');' );
- print '' . price($result) . ' ';
- $sommes[$code]['N'] += $result;
-
- // Detail by month
- foreach($months as $k => $v){
- foreach($sommes as $code => $det){
- $vars[$code] = $det['M'][$k];
}
- $result = strtr($formula, $vars);
- eval( '$result = (' . $result . ');' );
- print '' . price($result) . ' ';
- $sommes[$code]['M'][$k] += $result;
}
- //print '' . $catsCalcule[$p]['formula'] . ' ';
print " \n";
- unset($catsCalcule[$p]); // j'élimine la catégorie calculée après affichage
}
- $j++;
- }
-
- // Others calculed category
- foreach($catsCalcule as $p => $catc)
- {
- $formula = $catsCalcule[$p]['formula'];
-
- print "";
- print '' . $catsCalcule[$p]['label'] . ' ';
-
- $vars = array();
-
- // Previous Fiscal year (N-1)
- foreach($sommes as $code => $det){
- $vars[$code] = $det['NP'];
- }
- $result = strtr($formula, $vars);
- eval( '$result = (' . $result . ');' );
- print '' . price($result) . ' ';
- $code = $catsCalcule[$p]['code']; // code categorie de calcule
- $sommes[$code]['NP'] += $result;
-
- // Current fiscal year (N)
- foreach($sommes as $code => $det){
- $vars[$code] = $det['N'];
- }
- $result = strtr($formula, $vars);
- eval( '$result = (' . $result . ');' );
- print '' . price($result) . ' ';
- $sommes[$code]['N'] += $result;
-
- // Detail by month
- foreach($months as $k => $v){
- foreach($sommes as $code => $det){
- $vars[$code] = $det['M'][$k];
- }
- $result = strtr($formula, $vars);
- eval( '$result = (' . $result . ');' );
- print '' . price($result) . ' ';
- $sommes[$code]['M'][$k] += $result;
- }
-
- //print '' . $catsCalcule[$p]['formula'] . ' ';
- print " \n";
}
+
}
print "";
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index dc6b5e7ec20..398d12503ab 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -1,10 +1,10 @@
* Copyright (C) 2013-2017 Alexandre Spangaro
- * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
+ * Copyright (C) 2014-2015 Ari Elbaz (elarifr)
* Copyright (C) 2013-2016 Florian Henry
* Copyright (C) 2014 Juanjo Menent
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -52,6 +52,8 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
+$search_country = GETPOST('search_country', 'alpha');
+$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
@@ -94,17 +96,19 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_amount = '';
$search_account = '';
$search_vat = '';
+ $search_country = '';
+ $search_tvaintra = '';
}
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
-
+
$db->begin();
-
+
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
-
+
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
@@ -149,13 +153,15 @@ print ''."\n";
+ print ''."\n";
}
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index b68d7706e43..72f27a16602 100755
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -2121,8 +2121,8 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88))
* Applies the Cartesian product algorithm to an array
* Source: http://stackoverflow.com/a/15973172
*
- * @param array $input Array of products
- * @return array Array of combinations
+ * @param array $input Array of products
+ * @return array Array of combinations
*/
function cartesianArray(array $input) {
// filter out empty values
@@ -2145,3 +2145,70 @@ function cartesianArray(array $input) {
return $result;
}
+
+
+/**
+ * Get name of directory where the api_...class.php file is stored
+ *
+ * @param string $module Module name
+ * @return string Directory name
+ */
+function getModuleDirForApiClass($module)
+{
+ $moduledirforclass=$module;
+
+ if (in_array($module, array('login', 'access', 'status', 'documents'))) {
+ $moduledirforclass = 'api';
+ }
+ if (preg_match('/^dictionary/', $module)) {
+ $moduledirforclass = 'api';
+ }
+
+ if ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {
+ $moduledirforclass = 'societe';
+ }
+ if ($module == 'propale' || $module == 'proposals') {
+ $moduledirforclass = 'comm/propal';
+ }
+ elseif ($module == 'agenda' || $module == 'agendaevents') {
+ $moduledirforclass = 'comm/action';
+ }
+ elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') {
+ $moduledirforclass = 'adherents';
+ }
+ elseif ($module == 'banque' || $module == 'bankaccounts') {
+ $moduledirforclass = 'compta/bank';
+ }
+ elseif ($module == 'category' || $module == 'categorie') {
+ $moduledirforclass = 'categories';
+ }
+ elseif ($module == 'order' || $module == 'orders') {
+ $moduledirforclass = 'commande';
+ }
+ elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') {
+ $moduledirforclass = 'compta/facture';
+ }
+ elseif ($module == 'products') {
+ $moduledirforclass = 'product';
+ }
+ elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') {
+ $moduledirforclass = 'projet';
+ }
+ elseif ($module == 'task') {
+ $moduledirforclass = 'projet';
+ }
+ elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
+ $moduledirforclass = 'product/stock';
+ }
+ elseif ($module == 'fournisseur' || $module == 'supplierinvoices') {
+ $moduledirforclass = 'fourn';
+ }
+ elseif ($module == 'expensereports') {
+ $moduledirforclass = 'expensereport';
+ }
+ elseif ($module == 'users') {
+ $moduledirforclass = 'user';
+ }
+
+ return $moduledirforclass;
+}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 3c771220c70..dedb169dc38 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1068,10 +1068,10 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// Show page nb only on iso languages (so default Helvetica font)
if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica')
{
- $pdf->SetXY(-20,-$posy);
+ $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy);
//print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
- if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
- else $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
+ if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
+ else $pdf->MultiCell(15, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
}
return $marginwithfooter;
diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql
index c1de978d2df..76d58132caf 100644
--- a/htdocs/core/menus/init_menu_auguria.sql
+++ b/htdocs/core/menus/init_menu_auguria.sql
@@ -212,6 +212,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
-- Setup
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
+
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
@@ -221,6 +222,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 80, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 90, __ENTITY__);
+ -- Accounting period
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__);
-- Binding
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
@@ -246,8 +249,6 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2445__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 22, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2446__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 23, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2447__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 24, __ENTITY__);
- -- Accounting period
- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2400__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=setup', 'FiscalPeriod', 1, 'admin', '', '', 2, 4, __ENTITY__);
-- Rapports compta simple
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__);
diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php
index b51d303765b..6b42e7ad500 100644
--- a/htdocs/core/menus/standard/auguria.lib.php
+++ b/htdocs/core/menus/standard/auguria.lib.php
@@ -62,10 +62,7 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m
$classname = 'class="tmenu menuhider"';
$idsel='menu';
- if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry_auguria('', 1, '#', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry_auguria($showmode);
- $menu->add('#', '', 0, $showmode, $atarget, "xxx", '');
+ $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
}
$num = count($newTabMenu);
@@ -84,10 +81,10 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m
$url = $shorturl = $tmp[0];
$param = (isset($tmp[1])?$tmp[1]:'');
- // Complete param to force leftmenu to '' to closed opend menu when we click on a link with no leftmenu defined.
+ // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($newTabMenu[$i]['url']))
{
- $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['url'].'&leftmenu=';
+ $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
}
if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($newTabMenu[$i]['url']))
{
@@ -95,7 +92,10 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m
}
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
$url = dol_buildpath($url,1).($param?'?'.$param:'');
- $shorturl = $shorturl.($param?'?'.$param:'');
+ //$shorturl = $shorturl.($param?'?'.$param:'');
+ $shorturl = $url;
+
+ if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl);
}
$url=preg_replace('/__LOGIN__/',$user->login,$url);
@@ -118,10 +118,18 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m
}
else if ($showmode == 2) $classname='class="tmenu"';
- if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget));
- if (empty($noout)) print_end_menu_entry_auguria($showmode);
- $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), '');
+ $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu']?$newTabMenu[$i]['leftmenu']:''), $newTabMenu[$i]['position'], $id, $idsel, $classname);
+ }
+
+ // Sort on position
+ $menu->liste = dol_sort_array($menu->liste, 'position');
+
+ // Output menu entries
+ foreach($menu->liste as $menkey => $menuval)
+ {
+ if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']);
+ if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget));
+ if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']);
}
$showmode=1;
@@ -293,6 +301,16 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
print "\n";
}
+ if (is_array($moredata) && ! empty($moredata['bookmarks']))
+ {
+ print "\n";
+ print "\n";
+ print ''."\n";
+ print "\n";
+ }
+
// We update newmenu with entries found into database
$menuArbo = new Menubase($db,'auguria');
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu);
@@ -556,16 +574,6 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
if ($altok) print ''; // End menu block
}
- if (is_array($moredata) && ! empty($moredata['bookmarks']))
- {
- print "\n";
- print "\n";
- print ''."\n";
- print "\n";
- }
-
return count($menu_array);
}
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index d1da533b021..b479f02619c 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -60,10 +60,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
$classname = 'class="tmenu menuhider"';
$idsel='menu';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('#', '', 0, $showmode, $atarget, "xxx", '');
+ $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
}
// Home
@@ -73,10 +70,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='home';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("Home"), 1, DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", '');
+ $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
// Third parties
$tmpentry=array('enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur');
@@ -91,10 +85,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='companies';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("ThirdParties"), $showmode, DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '');
+ $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname);
}
// Products-Services
@@ -120,10 +111,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
$chaine.=$langs->trans("TMenuServices");
}
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($chaine, $showmode, DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '');
+ $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname);
}
// Commercial
@@ -147,10 +135,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='commercial';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("Commercial"), $showmode, DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "");
+ $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname);
}
// Financial
@@ -177,10 +162,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='accountancy';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("MenuFinancial"), $showmode, DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", '');
+ $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", '', 50, $id, $idsel, $classname);
}
// Bank
@@ -198,10 +180,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='bank';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("MenuBankCash"), $showmode, DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '');
+ $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 60, $id, $idsel, $classname);
}
// Projects
@@ -218,10 +197,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='project';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("Projects"), $showmode, DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", '');
+ $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", '', 70, $id, $idsel, $classname);
}
// HRM
@@ -238,10 +214,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='hrm';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/hrm/index.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '');
+ $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname);
}
@@ -260,10 +233,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='tools';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("TMenuTools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '');
+ $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname);
}
// Members
@@ -278,10 +248,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
else $classname = 'class="tmenu"';
$idsel='members';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("MenuMembers"), $showmode, DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu=', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '');
+ $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 100, $id, $idsel, $classname);
}
@@ -297,6 +264,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
$showmode=dol_eldy_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal);
if ($showmode == 1)
{
+ // url = url from host, shorturl = relative path into dolibarr sources
$url = $shorturl = $newTabMenu[$i]['url'];
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
{
@@ -307,7 +275,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
$url = dol_buildpath($url,1).($param?'?'.$param:'');
- $shorturl = $shorturl.($param?'?'.$param:'');
+ //$shorturl = $shorturl.($param?'?'.$param:'');
+ $shorturl = $url;
+ if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl);
}
$url=preg_replace('/__LOGIN__/',$user->login,$url);
$shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl);
@@ -321,10 +291,18 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
}
else if ($showmode == 2) $classname='class="tmenu"';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget));
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), '');
+ $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu']?$newTabMenu[$i]['leftmenu']:''), $newTabMenu[$i]['position'], $id, $idsel, $classname);
+ }
+
+ // Sort on position
+ $menu->liste = dol_sort_array($menu->liste, 'position');
+
+ // Output menu entries
+ foreach($menu->liste as $menkey => $menuval)
+ {
+ if (empty($noout)) print_start_menu_entry($menuval['idsel'],$menuval['classname'],$menuval['enabled']);
+ if (empty($noout)) print_text_menu_entry($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget));
+ if (empty($noout)) print_end_menu_entry($menuval['enabled']);
}
$showmode=1;
@@ -978,7 +956,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
{
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47);
}*/
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60);
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60);
+
+ // Fiscal year
+ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods.
+ {
+ if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
+ }
// Binding
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
@@ -1102,12 +1086,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire);
-
- // Fiscal year
- if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods.
- {
- if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_periods", $langs->trans("FiscalPeriod"),1,$user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
- }
}
// Accountancy (simple)
@@ -1605,7 +1583,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$url = $shorturl = $tmp[0];
$param = (isset($tmp[1])?$tmp[1]:''); // params in url of the menu link
- // Complete param to force leftmenu to '' to closed opend menu when we click on a link with no leftmenu defined.
+ // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined.
if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($menu_array[$i]['mainmenu']))
{
$param.=($param?'&':'').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu=';
diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php
index e4424712625..dafc0486145 100644
--- a/htdocs/core/menus/standard/empty.php
+++ b/htdocs/core/menus/standard/empty.php
@@ -76,39 +76,47 @@ class MenuManager
$res='ErrorBadParameterForMode';
$noout=0;
- if ($mode == 'jmobile') $noout=1;
+ //if ($mode == 'jmobile') $noout=1;
if ($mode == 'topnb')
{
return 1;
}
- if ($mode == 'top' || $mode == 'jmobile')
+ if ($mode == 'top')
{
if (empty($noout)) print_start_menu_array_empty();
- // Home
- $showmode=1;
- $idsel='home';
- $classname='class="tmenusel"';
+ $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER));
// Show/Hide vertical menu
- if ($mode != 'jmobile' && $mode != 'topnb' && (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$showmode=1;
$classname = 'class="tmenu menuhider"';
$idsel='menu';
- if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget);
- if (empty($noout)) print_end_menu_entry($showmode);
- $menu->add('#', '', 0, $showmode, $atarget, "xxx", '');
+ $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
}
- if (empty($noout)) print_start_menu_entry_empty($idsel, $classname, $showmode);
- if (empty($noout)) print_text_menu_entry_empty($langs->trans("Home"), 1, dol_buildpath('/index.php',1).'?mainmenu=home&leftmenu=', $id, $idsel, $classname, $this->atarget);
- if (empty($noout)) print_end_menu_entry_empty($showmode);
- $this->menu->add(dol_buildpath('/index.php',1), $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '');
+ // Home
+ $showmode=1;
+ $classname='class="tmenusel"';
+ $idsel='home';
+
+ $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname);
+
+
+ // Sort on position
+ $this->menu->liste = dol_sort_array($this->menu->liste, 'position');
+
+ // Output menu entries
+ foreach($this->menu->liste as $menkey => $menuval)
+ {
+ if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']);
+ if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget));
+ if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']);
+ }
$showmode=1;
if (empty($noout)) print_start_menu_entry_empty('','class="tmenuend"',$showmode);
@@ -123,7 +131,195 @@ class MenuManager
}
}
- if ($mode == 'left' || $mode == 'jmobile')
+ if ($mode == 'jmobile') // Used to get menu in xml ul/li
+ {
+ // Home
+ $showmode=1;
+ $classname='class="tmenusel"';
+ $idsel='home';
+
+ $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname);
+
+
+ // $this->menu->liste is top menu
+ //var_dump($this->menu->liste);exit;
+ $lastlevel = array();
+ print ''."\n";
+ foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
+ {
+ print ''."\n";
+ }
+ }
+
+ if ($mode == 'left')
{
// Put here left menu entries
// ***** START *****
@@ -134,8 +330,10 @@ class MenuManager
$this->menu->add("/admin/modules.php", $langs->trans("Modules"),1);
$this->menu->add("/admin/menus.php", $langs->trans("Menus"),1);
$this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"),1);
- $this->menu->add("/admin/fiscalyear.php", $langs->trans("Fiscalyear"),1);
- $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1);
+ $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1);
+ $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1);
+
+ $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1);
$this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1);
$this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1);
$this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1);
@@ -143,7 +341,6 @@ class MenuManager
$this->menu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1);
$this->menu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1);
$this->menu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1);
- if (! empty($conf->accounting->enabled)) $this->menu->add("/accountancy/admin/account.php", $langs->trans("Chartofaccounts"),1);
$this->menu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1);
// ***** END *****
@@ -170,15 +367,15 @@ class MenuManager
$lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined
if (($alt%2==0))
{
- print '