From 0ce514079b4b7288689c47df758922cc33c110af Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sat, 5 Jan 2019 12:51:08 +0100 Subject: [PATCH 1/7] FIX Button journalize grey when mandatroy setup not done --- htdocs/accountancy/journal/bankjournal.php | 74 +++++++++++++++------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index e610d9c0bba..6f114b91a11 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2018 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2017-2018 Frédéric France @@ -56,9 +56,10 @@ require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php'; +require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","other","compta","banks","bills","donations","loan","accountancy","trips","salaries","hrm")); +$langs->loadLangs(array("companies","other","compta","banks","bills","donations","loan","accountancy","trips","salaries","hrm","members")); // Multi journal $id_journal = GETPOST('id_journal', 'int'); @@ -149,6 +150,7 @@ $paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentvariousstatic = new PaymentVarious($db); $paymentloanstatic = new PaymentLoan($db); $accountLinestatic=new AccountLine($db); +$paymentsubscriptionstatic = new Subscription($db); $accountingaccount = new AccountingAccount($db); @@ -167,12 +169,13 @@ if ($result) { //print $sql; // Variables - $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word - $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word - $account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word - $account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word - $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word - $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word + $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word + $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word + $account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_subscription = (! empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word $tabcompany = array(); $tabuser = array(); @@ -263,7 +266,7 @@ if ($result) { // Now loop on each link of record in bank. foreach ($links as $key => $val) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_loan', 'payment_salary', 'payment_various'))) + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines @@ -341,6 +344,14 @@ if ($result) { $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; + } else if ($links[$key]['type'] == 'member') { + $paymentsubscriptionstatic->id = $links[$key]['url_id']; + $paymentsubscriptionstatic->ref = $links[$key]['url_id']; + $paymentsubscriptionstatic->label = $links[$key]['label']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsubscriptionstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; + $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); + $tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount; } else if ($links[$key]['type'] == 'payment_vat') { // Payment VAT $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; @@ -580,6 +591,13 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; + $accountingaccount->fetch(null, $k, true); + $bookkeeping->label_compte = $accountingaccount->label; + } else if ($tabtype[$key] == 'member') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else if ($tabtype[$key] == 'payment_loan') { @@ -915,9 +933,18 @@ if (empty($action) || $action == 'view') { print '
'; + if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; - if ($in_bookkeeping == 'notyet') print ''; - else print '' . $langs->trans("WriteBookKeeping") . ''; + + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' + || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' + || empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { + print ''; + } + else { + if ($in_bookkeeping == 'notyet') print ''; + else print '' . $langs->trans("WriteBookKeeping") . ''; + } print '
'; // TODO Avoid using js. We can use a direct link with $param @@ -1027,11 +1054,13 @@ if (empty($action) || $action == 'view') { print ""; $account_ledger = $k; // Try to force general ledger account depending on type - if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; - if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; + if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; + if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; + $accounttoshow = length_accounta($account_ledger); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { @@ -1051,11 +1080,12 @@ if (empty($action) || $action == 'view') { { // We will refuse writing $errorstring='UnknownAccountForThirdpartyBlocking'; - if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined'; - if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined'; - if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined'; - if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined'; - if ($tabtype[$key] == 'payment_vat') $errorstring='MainAccountForVatPaymentNotDefined'; + if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined'; + if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined'; + if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined'; + if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined'; + if ($tabtype[$key] == 'payment_vat') $errorstring='MainAccountForVatPaymentNotDefined'; + if ($tabtype[$key] == 'member') $errorstring='MainAccountForSubscriptionPaymentNotDefined'; print ''.$langs->trans($errorstring).''; } } @@ -1179,7 +1209,7 @@ function getSourceDocRef($val, $typerecord) $sqlmid = ''; if ($typerecord == 'payment') { - $sqlmid = 'SELECT payfac.fk_facture as id, f.facnumber as ref'; + $sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; $ref = $langs->transnoentitiesnoconv("Invoice"); From 59d6000e89ff5d93269c7ae6eb856d9c705d5bbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Jan 2019 15:13:35 +0100 Subject: [PATCH 2/7] Code comment --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 27e3b84b1de..ec4f894e4e1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -913,7 +913,7 @@ if ((! empty($conf->browser->layout) && $conf->browser->layout == 'phone') // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; // Replace themes bugged with jmobile with eldy -if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo','amarok'))) +if (! empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea','cameleo','amarok'))) { $conf->theme='eldy'; $conf->css = "/theme/".$conf->theme."/style.css.php"; From c9e607455160699e54728119277d3e37a7a3e0a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Jan 2019 15:14:06 +0100 Subject: [PATCH 3/7] Code clean --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3c0278511d9..e174b847dac 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1141,8 +1141,8 @@ class Form $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { - $sql .= " ,s.address, s.zip, s.town"; - $sql .= " , dictp.code as country_code"; + $sql .= ", s.address, s.zip, s.town"; + $sql .= ", dictp.code as country_code"; } $sql.= " FROM (".MAIN_DB_PREFIX ."societe as s"; From b5ad35f886cc69b2b2a6ae49ebf5735a92523058 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Jan 2019 15:18:37 +0100 Subject: [PATCH 4/7] Fix better test tool --- dev/tools/fixdosfiles.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tools/fixdosfiles.sh b/dev/tools/fixdosfiles.sh index 5fcacd8e2fd..a5221d0d201 100755 --- a/dev/tools/fixdosfiles.sh +++ b/dev/tools/fixdosfiles.sh @@ -17,8 +17,8 @@ fi # To detec if [ "x$1" = "xlist" ] then - find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep CRLF -# find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v 'htdocs\/includes' | grep CRLF + find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'documents\/website' | grep CRLF +# find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v 'documents\/website' | grep -v 'htdocs\/includes' | grep CRLF fi # To convert From cbf1c30647af1a08b894eade7bfb8c14a42a6463 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Jan 2019 15:19:07 +0100 Subject: [PATCH 5/7] Fix better test tool --- dev/tools/fixdosfiles.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/fixdosfiles.sh b/dev/tools/fixdosfiles.sh index a5221d0d201..e4ccb1485e1 100755 --- a/dev/tools/fixdosfiles.sh +++ b/dev/tools/fixdosfiles.sh @@ -24,7 +24,7 @@ fi # To convert if [ "x$1" = "xfix" ] then - for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep CRLF | awk -F':' '{ print $1 }' ` + for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'documents\/website' | grep CRLF | awk -F':' '{ print $1 }' ` do echo "Fix file $fic" dos2unix "$fic" From b1559dbc394d08b0f7968e4891a6163737401b82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Jan 2019 15:22:24 +0100 Subject: [PATCH 6/7] Fix perms --- .../swiftmailer/lib/swiftmailer_generate_mimes_config.php | 0 htdocs/modulebuilder/template/scripts/myobject.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php mode change 100755 => 100644 htdocs/modulebuilder/template/scripts/myobject.php diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php old mode 100755 new mode 100644 diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php old mode 100755 new mode 100644 From 38ec05f2f1c5c1b7e6dd535f1ffe75bceacb4a43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Jan 2019 01:17:11 +0100 Subject: [PATCH 7/7] Fix search filter lost --- htdocs/admin/mails_templates.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 40daa521989..2ff20e9acc7 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -606,10 +606,16 @@ if ($resql) $i = 0; $param = '&id='.$id; + if ($search_label) $param.= '&search_label='.urlencode($search_label); + if ($search_lang > 0) $param.= '&search_lang='.urlencode($search_lang); + if ($search_type_template > 0) $param.= '&search_type_template='.urlencode($search_type_template); + if ($search_fk_user > 0) $param.= '&search_fk_user='.urlencode($search_fk_user); + if ($search_topic) $param.= '&search_topic='.urlencode($search_topic); + $paramwithsearch = $param; - if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; - if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; - if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); + if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder); + if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); + if (GETPOST('from','alpha')) $paramwithsearch.= '&from='.urlencode(GETPOST('from','alpha')); // There is several pages if ($num > $listlimit)