From dcde7773a3e788772dd4eab1208fd45c1db77fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 2 Mar 2016 11:04:52 +0100 Subject: [PATCH 1/9] Started using Account TYPE and STATUS constants --- htdocs/compta/bank/card.php | 6 +++--- htdocs/compta/bank/class/account.class.php | 17 ++++++++++++++--- .../societe/class/companybankaccount.class.php | 4 +--- htdocs/user/class/userbankaccount.class.php | 4 +--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index cccf16f0467..12dfe51ab59 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -302,7 +302,7 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").''; print ''; - print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print $form->selectarray("clos", $account->status,(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print ''; // Country @@ -643,7 +643,7 @@ else print '
'; - if ($account->type == 0 || $account->type == 1) + if ($account->type == Account::TYPE_SAVINGS || $account->type == Account::TYPE_CURRENT) { print ''; @@ -861,7 +861,7 @@ else // Status print ''; print ''; // Country diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a5e108a2c96..ca6ad0c37ce 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -139,7 +139,19 @@ class Account extends CommonObject public $state_code; public $state; - public $type_lib=array(); + /** + * Variable containing all account types with their respective translated label. + * Defined in __construct + * @var array + */ + public $type_lib = array(); + + /** + * Variable containing all account statuses with their respective translated label. + * Defined in __construct + * @var array + */ + public $status = array(); /** * Accountancy code @@ -205,7 +217,6 @@ class Account extends CommonObject $this->db = $db; - $this->clos = 0; $this->solde = 0; $this->type_lib = array( @@ -1230,7 +1241,7 @@ class Account extends CommonObject $this->label = 'My Bank account'; $this->bank = 'MyBank'; $this->courant = 1; - $this->clos = 0; + $this->clos = Account::STATUS_OPEN; $this->code_banque = '123'; $this->code_guichet = '456'; $this->number = 'ABC12345'; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 3924e8a9174..f71b04b7730 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -46,16 +46,14 @@ class CompanyBankAccount extends Account * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->socid = 0; - $this->clos = 0; $this->solde = 0; $this->error_number = 0; $this->default_rib = 0; - return 1; } diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 30c795bbd72..a91d064c7f8 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -44,15 +44,13 @@ class UserBankAccount extends Account * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->socid = 0; - $this->clos = 0; $this->solde = 0; $this->error_number = 0; - return 1; } From ff83dd9afeffda4c41328b27ade5ec20a0222bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 2 Mar 2016 11:08:57 +0100 Subject: [PATCH 2/9] Replaced account type comparisons with TYPE constants --- htdocs/compta/bank/account.php | 2 +- htdocs/compta/bank/class/account.class.php | 6 +++--- htdocs/compta/bank/ligne.php | 2 +- htdocs/compta/bank/virement.php | 2 +- htdocs/core/lib/bank.lib.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 0973ece78d3..880ff92d3d5 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -489,7 +489,7 @@ if ($id > 0 || ! empty($ref)) $form->select_date($dateop,'op',0,0,0,'transaction'); print ''; print ''; print '
'.$langs->trans("Status").''; - print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print $form->selectarray("clos", $account->status,(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print '
'; - $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == 2 ? 'LIQ' : '')),'operation','1,2',2,1); + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); print ''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index ca6ad0c37ce..a3f8ea61274 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -242,7 +242,7 @@ class Account extends CommonObject global $conf; if (empty($this->rappro)) return -1; - if ($this->courant == 2 && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2; + if ($this->courant == Account::TYPE_CASH && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2; if ($this->clos) return -3; return 1; } @@ -399,7 +399,7 @@ class Account extends CommonObject $this->error="this->rowid not defined"; return -2; } - if ($this->courant == 2 && $oper != 'LIQ') + if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { $this->error="ErrorCashAccountAcceptsOnlyCashMoney"; return -3; @@ -1240,7 +1240,7 @@ class Account extends CommonObject $this->ref = 'MBA'; $this->label = 'My Bank account'; $this->bank = 'MyBank'; - $this->courant = 1; + $this->courant = Account::TYPE_CURRENT; $this->clos = Account::STATUS_OPEN; $this->code_banque = '123'; $this->code_guichet = '456'; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 13b65f0baf1..a01d7d0684b 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -102,7 +102,7 @@ if ($user->rights->banque->modifier && $action == "update") $ac = new Account($db); $ac->fetch($id); - if ($ac->courant == 2 && $_POST['value'] != 'LIQ') + if ($ac->courant == Account::TYPE_CASH && $_POST['value'] != 'LIQ') { setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors'); $error++; diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 1a3294a2f15..146ed4759c4 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -93,7 +93,7 @@ if ($action == 'add') // By default, electronic transfert from bank to bank $typefrom='PRE'; $typeto='VIR'; - if ($accountto->courant == 2 || $accountfrom->courant == 2) + if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { // This is transfert of change $typefrom='LIQ'; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 3c5d57fdaf6..ceb8a87bb30 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -64,7 +64,7 @@ function bank_prepare_head(Account $object) $head[$h][2] = 'graph'; $h++; - if ($object->courant != 2) + if ($object->courant != Account::TYPE_CASH) { $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; $head[$h][1] = $langs->trans("AccountStatements"); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index a24a2d32baa..cbd4b035c4e 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -281,7 +281,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM { $objp = $db->fetch_object($resql); $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); - if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) // If not cash account and not closed and can be reconciliate + if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a849d9ac40a..d3666031839 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1342,7 +1342,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $objp = $db->fetch_object($resql); $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); - if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) // If not cash account and not closed and can be reconciliate + if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } From b41016da7044637571957b2f1abfc57db301bd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 2 Mar 2016 11:12:19 +0100 Subject: [PATCH 3/9] Little refactor of FormBank::select_type_comptes_financiers --- htdocs/core/class/html.formbank.class.php | 27 +++-------------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index ad74b465f27..48ec0764c09 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -49,32 +49,11 @@ class FormBank * @param string $htmlname Nom champ formulaire * @return void */ - function select_type_comptes_financiers($selected=1,$htmlname='type') + public function select_type_comptes_financiers($selected = Account::TYPE_CURRENT, $htmlname = 'type') { - global $langs; - $langs->load("banks"); + $account = new Account($this->db); - $type_available=array(0,1,2); - - print ''; + print Form::selectarray($htmlname, $account->type_lib, $selected); } } From ba2c0db1591eb5b4f939fa69861b0a5c9f1bdbdd Mon Sep 17 00:00:00 2001 From: philippe grand Date: Thu, 3 Mar 2016 12:00:08 +0100 Subject: [PATCH 4/9] fix : missing translation --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 814279635e8..456c8f83c96 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -789,6 +789,7 @@ Permission2403=Delete actions (events or tasks) linked to his account Permission2411=Read actions (events or tasks) of others Permission2412=Create/modify actions (events or tasks) of others Permission2413=Delete actions (events or tasks) of others +Permission2414=Export actions/tasks of others Permission2501=Read/Download documents Permission2502=Download documents Permission2503=Submit or delete documents From 902eba67d22ffa01f6710094f88222c01a3d0bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 3 Mar 2016 17:12:16 +0100 Subject: [PATCH 5/9] Update html.formfile.class.php --- htdocs/core/class/html.formfile.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1226d3b35ba..96b4ae2805e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -109,7 +109,10 @@ class FormFile $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb $maxphp=@ini_get('upload_max_filesize'); // En inconnu + if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1; if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024; + if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024; + if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024; // Now $max and $maxphp are in Kb if ($maxphp > 0) $max=min($max,$maxphp); From 8536841ada5f4f56fabf418e6725449acee148e6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 4 Mar 2016 10:27:34 +0100 Subject: [PATCH 6/9] Fix: 3.9rc2 Show accountancy account ventilated instead of the orwid of the account. --- htdocs/accountancy/customer/list.php | 76 ++++++++++++++-------------- htdocs/accountancy/supplier/list.php | 73 +++++++++++++------------- 2 files changed, 75 insertions(+), 74 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index a2a1619cb63..34eb66b75d1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,9 +1,9 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2014-2015 Ari Elbaz (elarifr) - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) + * Copyright (C) 2013-2014 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 @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/customer/list.php - * \ingroup Accountancy - * \brief Ventilation page from customers invoices + * \file htdocs/accountancy/customer/list.php + * \ingroup Advanced accountancy + * \brief Ventilation page from customers invoices */ require '../../main.inc.php'; @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("compta"); @@ -123,36 +124,38 @@ print ''; + '; /* * Action */ - if ($action == 'ventil' && ! empty($btn_ventil)) { print '
' . $langs->trans("Processing") . '...
'; if (! empty($codeventil) && ! empty($mesCasesCochees)) { print '
' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '
'; $mesCodesVentilChoisis = $codeventil; $cpt = 0; - + foreach ( $mesCasesCochees as $maLigneCochee ) { $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql .= " SET fk_code_ventilation = " . $monCompte; $sql .= " WHERE rowid = " . $monId; - + + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); + dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); if ($db->query($sql)) { - print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; } else { - print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '
' . $sql . '
'; + print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; } - + $cpt ++; } } else { @@ -164,7 +167,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) { /* * Customer Invoice lines */ - if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { @@ -224,16 +226,13 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); print '
' . $langs->trans("DescVentilTodoCustomer") . '
'; - print_liste_field_titre($langs->trans("Date"), $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder); - print '  '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); - + print '
' . "\n"; print ''; - + print ''; print ''; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); @@ -247,40 +246,39 @@ if ($result) { print_liste_field_titre(''); print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print ''; - + // We add search filter - print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - + $facture_static = new Facture($db); $product_static = new Product($db); $form = new Form($db); - + $var = true; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; - + $objp->code_sell_l = ''; $objp->code_sell_p = ''; $objp->aarowid_suggest = ''; $code_sell_p_l_differ = ''; - + $code_sell_p_notset = ''; $objp->aarowid_suggest = $objp->aarowid; - + if (! empty($objp->code_sell)) { $objp->code_sell_p = $objp->code_sell; } else { @@ -304,9 +302,9 @@ if ($result) { } if ($objp->code_sell_l != $objp->code_sell_p) $code_sell_p_l_differ = 'color:red'; - + print ""; - + // Ref Invoice $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; @@ -316,14 +314,14 @@ if ($result) { $product_static->id = $objp->product_id; $product_static->type = $objp->type; print ''; - + print ''; $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print ''; @@ -339,10 +337,10 @@ if ($result) { if ($objp->code_sell_l == $objp->code_sell_p) { print $objp->code_sell_l; } else { - print $langs->trans("Purchase") . ' = ' . $objp->code_sell_l . '
' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p; + print $langs->trans("Buy") . ' = ' . $objp->code_sell_l . '
' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p; } print ''; - + print ''; @@ -353,7 +351,7 @@ if ($result) { print ''; $i ++; } - + print '
%%'; print ''; print ' '; print ''; print '
'; - + if ($product_static->id) print $product_static->getNomUrl(1); else print ' '; - + print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, $trunclength)) . ''; print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); print '
'; print '
'; print '
'; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 212ff316c34..14cf87ffdde 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/supplier/list.php - * \ingroup Accountancy - * \brief Ventilation page from suppliers invoices + * \file htdocs/accountancy/supplier/list.php + * \ingroup Advanced accountancy + * \brief Ventilation page from suppliers invoices */ require '../../main.inc.php'; @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("compta"); @@ -128,36 +129,39 @@ print ''; + '; + /* * Action */ - if ($action == 'ventil' && ! empty($btn_ventil)) { print '
' . $langs->trans("Processing") . '...
'; if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) { print '
' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '
'; $mesCodesVentilChoisis = $codeventil; $cpt = 0; - + foreach ( $mesCasesCochees as $maLigneCochee ) { // print '
id selectionnee : '.$monChoix."
"; $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " SET fk_code_ventilation = " . $monCompte; $sql .= " WHERE rowid = " . $monId; - + + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); + dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); if ($db->query($sql)) { - print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; } else { - print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '
' . $sql . '
'; + print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; } - + $cpt ++; } } else { @@ -169,7 +173,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) { /* * Supplier Invoice Lines */ - if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { @@ -226,15 +229,15 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - + print '
' . $langs->trans("DescVentilTodoCustomer") . '
'; - + print '
' . "\n"; print ''; - + print ''; print ''; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); @@ -248,14 +251,14 @@ if ($result) { print_liste_field_titre(''); print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print "\n"; - + print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; - + $facturefourn_static = new FactureFournisseur($db); $productfourn_static = new ProductFournisseur($db); $form = new Form($db); - + $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; - + // product_type: 0 = service ? 1 = product // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! @@ -281,9 +284,9 @@ if ($result) { $objp->code_buy_p = ''; $objp->aarowid_suggest = ''; $code_buy_p_l_differ = ''; - + $code_buy_p_notset = ''; - + $objp->aarowid_suggest = $objp->aarowid; if (! empty($objp->code_buy)) { $objp->code_buy_p = $objp->code_buy; @@ -297,7 +300,7 @@ if ($result) { $objp->code_buy_p = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); } } - + if ($objp->type_l == 1) { $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); if ($objp->aarowid == '') @@ -307,17 +310,17 @@ if ($result) { if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p; } - + if ($objp->code_buy_l != $objp->code_buy_p) $code_buy_p_l_differ = 'color:red'; print ""; - + // Ref Invoice $facturefourn_static->ref = $objp->ref; $facturefourn_static->id = $objp->facid; print ''; - + // Ref Supplier Invoice $productfourn_static->ref = $objp->product_ref; $productfourn_static->id = $objp->product_id; @@ -328,23 +331,23 @@ if ($result) { else print ' '; print ''; - + print ''; - + // TODO: we should set a user defined value to adjust user square / wide screen size $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print ''; - + print ''; - + if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; print ''; - + print ''; - + // Colonne choix du compte print ''; - + print ""; $i ++; } - + print '
%%  '; @@ -264,16 +267,16 @@ if ($result) { print ''; print '
' . $facturefourn_static->getNomUrl(1) . '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, $trunclength)) . ''; print price($objp->price); print ''; print price($objp->tva_tx_line); print ''; // if not same kind of product_type stored in product & facturedt we display both account and let user choose if ($objp->code_buy_l == $objp->code_buy_p) { @@ -353,7 +356,7 @@ if ($result) { print 'lines=' . $objp->code_buy_l . '
product=' . $objp->code_buy_p; } print '
'; print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); @@ -363,11 +366,11 @@ if ($result) { print ''; print 'aarowid ? "checked" : "") . '/>'; print '
'; print '
'; print '
'; From db656ea4cab97cd0eb39b2cc5e5b6cab753d98eb Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 4 Mar 2016 10:38:33 +0100 Subject: [PATCH 7/9] New : add button to create event on supplier order or invoice with MAIN_ADD_EVENT_ON_ELEMENT_CARD --- htdocs/fourn/commande/card.php | 5 +++++ htdocs/fourn/facture/card.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 922e0d61d38..6a5698497c3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2755,6 +2755,11 @@ elseif (! empty($object->id)) print ''; } } + // Create event + if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + { + print ''; + } // Modify if ($object->statut == 1) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e23f8cf8dbc..837525d3262 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2321,6 +2321,12 @@ else } } } + + // Create event + if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + { + print ''; + } // Clone if ($action != 'edit' && $user->rights->fournisseur->facture->creer) From 2bca2b278a278210e1da68aeb741e3836390bd33 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 4 Mar 2016 13:03:07 +0100 Subject: [PATCH 8/9] Fix parser and button not using selected expression --- htdocs/product/fournisseurs.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 96020e81ada..f5fc8c8655c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -229,6 +229,7 @@ if (empty($reshook)) { //Check the expression validity by parsing it $priceparser = new PriceParser($db); + $object->fk_supplier_price_expression = $price_expression; $price_result = $priceparser->parseProductSupplier($object); if ($price_result < 0) { //Expression is not valid $error++; @@ -470,7 +471,7 @@ if ($id > 0 || $ref) on_change(); } function on_click() { - window.location = "'.DOL_URL_ROOT.'/product/dynamic_price/editor.php?id='.$id.'&tab=fournisseurs&eid=" + $("#eid").attr("value"); + window.location = "'.DOL_URL_ROOT.'/product/dynamic_price/editor.php?id='.$id.'&tab=fournisseurs&eid=" + $("#eid").val(); } function on_change() { if ($("#eid").val() == 0) { From a1159b6f29168beff9eae0491d43620525df8cfb Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 4 Mar 2016 14:11:06 +0100 Subject: [PATCH 9/9] Fix: unset date start/end at success --- htdocs/comm/propal.php | 13 +++++++++++++ htdocs/commande/card.php | 13 +++++++++++++ htdocs/fourn/commande/card.php | 13 +++++++++++++ htdocs/fourn/facture/card.php | 13 +++++++++++++ htdocs/supplier_proposal/card.php | 25 +++++++++++++++++++++++++ 5 files changed, 77 insertions(+) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 7d85567f480..6821f6cd376 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1044,6 +1044,19 @@ if (empty($reshook)) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e63e3b9a5dc..308da237023 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -969,6 +969,19 @@ if (empty($reshook)) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 922e0d61d38..ac2013c2a67 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -563,6 +563,19 @@ if (empty($reshook)) unset($localtax1_tx); unset($localtax2_tx); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + if ($result >= 0) { // Define output language diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e23f8cf8dbc..8674b6e2e9a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -620,6 +620,19 @@ if (empty($reshook)) if ($result >= 0) { unset($_POST['label']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + $db->commit(); } else diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a66c849bf3a..e455ee56c6e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -729,6 +729,18 @@ if (empty($reshook)) unset($_POST['dp_desc']); unset($_POST['idprod']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); @@ -836,6 +848,19 @@ if (empty($reshook)) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback();