diff --git a/ChangeLog b/ChangeLog index 6ac794b974e..15c1dc404f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,26 @@ Following changes may create regression for some external modules, but were nece * Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still exists, but if an external module need action on it, it must provides itself its trigger file. +***** ChangeLog for 5.0.3 compared to 5.0.2 ***** +FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty +FIX: #6813 +FIX: 6863 +FIX: #6877 +FIX: #6881 +FIX: Better sanitizing of search all parameter. +FIX: Correction with author and validator user on orders +FIX: dialog window with md theme must not be hidden by left menu part. +FIX: doactions hook missing in invoice model page +FIX: Fullname when member is a moral entity with no name. +FIX: Link to files on bank account tab broken with multicompany FIX: Link to preview on thirdparty broken with multicompany +FIX: New vat code not correctly implemented if "1 price per customer". +FIX: Pagination of invoices +FIX: pagination on resources +FIX: REST API not possible to add agendaevents +FIX: situation invoice broken due to the all percent application form inside addline form +FIX: SQL injection on user/index.php parameter search_statut. +FIX: XSS + ***** ChangeLog for 5.0.2 compared to 5.0.1 ***** FIX: #6468 + Fix missing translation FIX: #6517 #6525 Autocompletion of thirdparty after n chars not implemented diff --git a/build/debian/README.howto b/build/debian/README.howto index c94309ec2ef..1632e954237 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -444,3 +444,4 @@ Note that package 3.5.7 contains not only fixed for bugs reported to debian. It so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935. After discussion with ..., it appears that security holes are enough to request this unblock request." +Note: If there is a response to ask more information, don't forget to remove the tag during answer. diff --git a/build/debian/source/lintian-overrides b/build/debian/source/lintian-overrides index b4c0956e90f..c878035b482 100644 --- a/build/debian/source/lintian-overrides +++ b/build/debian/source/lintian-overrides @@ -4,7 +4,12 @@ dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/* dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/* # Those are false positives, the files are their own sources since # they are not minified -source-is-missing htdocs/includes/jsgantt/jsgantt.js * -source-is-missing htdocs/includes/jquery/plugins/colorpicker/jquery.colorpicker.js * -source-is-missing htdocs/includes/jquery/plugins/select2/select2.js * -source-is-missing htdocs/includes/jquery/plugins/select2/select2_locale_ar.js * +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/a11yhelp/dialogs/lang/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/specialchar/dialogs/lang/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/lang/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/dialogs/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/filter/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/templates/templates/default.js +source-is-missing htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json +source-is-missing htdocs/includes/restler/framework/Luracast/Restler/explorer/lib/*.js + diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 16e11225d49..47759792d71 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -32,7 +32,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 1bb1bf178b3..d1083c50d10 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -43,7 +43,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTIN $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index fcb44c6f858..4552a478d6a 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -74,7 +74,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTIN $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 306fa4d2cab..244331b76dc 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -65,10 +65,8 @@ $langs->load("accountancy"); $langs->load("trips"); $langs->load("salaries"); -// Old system menu -$id_bank_account = GETPOST('id_account', 'int'); // Multi journal -$code_journal = GETPOST('code_journal', 'alpha'); +$id_journal = GETPOST('id_journal', 'int'); $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); @@ -81,7 +79,7 @@ $action = GETPOST('action','aZ09'); $now = dol_now(); // Security check -if ($user->societe_id > 0 && empty($id_bank_account)) +if ($user->societe_id > 0 && empty($id_journal)) accessforbidden(); @@ -112,7 +110,7 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $p[0]; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; -$sql .= " ba.courant, ba.ref as baref, ba.account_number,"; +$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,"; $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; @@ -121,7 +119,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.row $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; -$sql .= " WHERE ba.rowid=" . $id_bank_account; +$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) . "'"; @@ -139,20 +137,8 @@ $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); // Get code of finance journal -$journal = ''; -$bankstatic = new Account($db); -$bankstatic->fetch($id_bank_account); -$bankstatic->rowid; -$bankstatic->number; -$bankstatic->label; -$bankstatic->fk_accountancy_journal; - $accountingjournalstatic = new AccountingJournal($db); -if(! empty($id_bank_account)) { - $accountingjournalstatic->fetch($bankstatic->fk_accountancy_journal); -} else { - $accountingjournalstatic->fetch('',$code_journal); -} +$accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); @@ -194,7 +180,7 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_compta' => $compta_soc, + 'code_compta' => $compta_soc, ); $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); @@ -202,6 +188,8 @@ if ($result) { $tabuser[$obj->rowid] = array ( 'id' => $obj->userid, 'name' => $obj->firstname.' '.$obj->lastname, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, 'accountancy_code' => $compta_user, ); @@ -219,7 +207,7 @@ if ($result) { // get_url may return -1 which is not traversable if (is_array($links)) { - // Now loop on each link of record in bank. + // 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_salary'))) // So we excluded 'company' here @@ -754,13 +742,13 @@ if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("FinanceJournal")); - $nom = $langs->trans("FinanceJournal") . ' - ' . $bankstatic->getNomUrl(1); + $nom = $langs->trans("FinanceJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); $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); - $varlink = 'id_account=' . $id_bank_account; + $varlink = 'id_journal=' . $id_journal; journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f67224e3996..9bd9f8b7f42 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * @@ -32,10 +32,11 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -45,6 +46,9 @@ $langs->load("main"); $langs->load("accountancy"); $langs->load("trips"); +// Multi journal +$id_journal = GETPOST('id_journal', 'int'); + $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); $date_startyear = GETPOST('date_startyear'); @@ -64,6 +68,10 @@ $action = GETPOST('action','aZ09'); /* * Actions */ +// Get code of finance journal +$accountingjournalstatic = new AccountingJournal($db); +$accountingjournalstatic->fetch($id_journal); +$journal = $accountingjournalstatic->code; $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; @@ -157,161 +165,159 @@ if ($action == 'writebookkeeping') { { $errorforline = 0; - $db->begin(); - - if (! $errorforline) - { - foreach ( $tabttc[$key] as $k => $mt ) { - if ($mt) { - // get compte id and label - - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'expense_report'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; - $bookkeeping->label_compte = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt <= 0) ? $mt : 0; - $bookkeeping->credit = ($mt > 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - - if (! $errorforline) - { - // Fees - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); - if ($mt) { - // get compte id and label - $accountingaccount = new AccountingAccount($db); - if ($accountingaccount->fetch(null, $k, true)) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'expense_report'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->numero_compte = $k; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - } - - if (! $errorforline) - { - // VAT - // var_dump($tabtva); - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - // get compte id and label - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'expense_report'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; - $bookkeeping->numero_compte = $k; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - + $db->begin(); + if (! $errorforline) { - $db->commit(); + foreach ( $tabttc[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt > 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + + if (! $errorforline) + { + // Fees + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k, true); + if ($mt) { + // get compte id and label + $accountingaccount = new AccountingAccount($db); + if ($accountingaccount->fetch(null, $k, true)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + } + + if (! $errorforline) + { + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + + if (! $errorforline) + { + $db->commit(); } else { - $db->rollback(); + $db->rollback(); } - } if (empty($error) && count($tabpay)) { - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } elseif (count($tabpay) == $error) { - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); } else { - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } $action=''; @@ -328,7 +334,6 @@ $userstatic = new User($db); // Export /*if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -448,7 +453,9 @@ if (empty($action) || $action == 'view') { $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); - journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); + $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 ''; @@ -456,10 +463,10 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; - print '
'; - + print '
'; + print ' '; + + // Loan card - + $linkback = '' . $langs->trans("BackToList") . ''; - + $morehtmlref='
'; // Ref loan $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); @@ -458,7 +470,7 @@ if ($id > 0) } } $morehtmlref.='
'; - + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -652,7 +664,7 @@ if ($id > 0) while ($i < $num) { $objp = $db->fetch_object($resql); - + print ''; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; @@ -713,31 +725,33 @@ if ($id > 0) if (empty($reshook)) { print '
'; - + // Edit if ($user->rights->loan->write) { + print ''.$langs->trans('CreateCalcSchedule').''; + print ''.$langs->trans("Modify").''; } - + // Emit payment if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { print ''.$langs->trans("DoPayment").''; } - + // Classify 'paid' if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) { print ''.$langs->trans("ClassifyPaid").''; } - + // Delete if ($user->rights->loan->delete) { print ''.$langs->trans("Delete").''; } - + print "
"; } } diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php new file mode 100644 index 00000000000..fb6df8fcb6c --- /dev/null +++ b/htdocs/loan/class/loanschedule.class.php @@ -0,0 +1,542 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/loan/class/loanschedule.class.php + * \ingroup facture + * \brief File of class to manage schedule of loans + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** + * Class to manage Schedule of loans + */ +class LoanSchedule extends CommonObject +{ + public $element='loan_schedule'; //!< Id that identify managed objects + public $table_element='loan_schedule'; //!< Name of table without prefix where object is stored + + var $fk_loan; + var $datec=''; + var $tms=''; + var $datep=''; + var $amounts=array(); // Array of amounts + var $amount_capital; // Total amount of payment + var $amount_insurance; + var $amount_interest; + var $fk_typepayment; + var $num_payment; + var $fk_bank; + var $fk_user_creat; + var $fk_user_modif; + var $lines=array(); + + /** + * @deprecated + * @see amount, amounts + */ + var $total; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + /** + * Create payment of loan into database. + * Use this->amounts to have list of lines for the payment + * + * @param User $user User making payment + * @return int <0 if KO, id of payment if OK + */ + function create($user) + { + global $conf, $langs; + + $error=0; + + $now=dol_now(); + + // Validate parameters + if (! $this->datepaid) + { + $this->error='ErrorBadValueForParameter'; + return -1; + } + + // Clean parameters + if (isset($this->fk_loan)) $this->fk_loan = trim($this->fk_loan); + if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital?$this->amount_capital:0); + if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance?$this->amount_insurance:0); + if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest?$this->amount_interest:0); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif); + + $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; + $totalamount = price2num($totalamount); + + // Check parameters + if ($totalamount == 0) { + $this->errors[]='step1'; + return -1; // Negative amounts are accepted for reject prelevement but not null + } + + + $this->db->begin(); + + if ($totalamount != 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; + $sql.= " fk_typepayment, fk_user_creat, fk_bank)"; + $sql.= " VALUES (".$this->fk_loan.", '".$this->db->idate($now)."',"; + $sql.= " '".$this->db->idate($this->datepaid)."',"; + $sql.= " ".$this->amount_capital.","; + $sql.= " ".$this->amount_insurance.","; + $sql.= " ".$this->amount_interest.","; + $sql.= " ".$this->fk_typepayment.", "; + $sql.= " ".$user->id.","; + $sql.= " ".$this->fk_bank . ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); + } + else + { + $this->error=$this->db->lasterror(); + $error++; + } + + } + + if ($totalamount != 0 && ! $error) + { + $this->amount_capital=$totalamount; + $this->total=$totalamount; // deprecated + $this->db->commit(); + return $this->id; + } + else + { + $this->errors[]=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.fk_loan,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.datep,"; + $sql.= " t.amount_capital,"; + $sql.= " t.amount_insurance,"; + $sql.= " t.amount_interest,"; + $sql.= " t.fk_typepayment,"; + $sql.= " t.num_payment,"; + $sql.= " t.note_private,"; + $sql.= " t.note_public,"; + $sql.= " t.fk_bank,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.fk_user_modif,"; + $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= ' b.fk_account'; + $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX.$this->table_element." as t)"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + + $this->fk_loan = $obj->fk_loan; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $this->db->jdate($obj->tms); + $this->datep = $this->db->jdate($obj->datep); + $this->amount_capital = $obj->amount_capital; + $this->amount_insurance = $obj->amount_insurance; + $this->amount_interest = $obj->amount_interest; + $this->fk_typepayment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_creat = $obj->fk_user_creat; + $this->fk_user_modif = $obj->fk_user_modif; + + $this->type_code = $obj->type_code; + $this->type_libelle = $obj->type_libelle; + + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user=0, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan); + if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital); + if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance); + if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest); + if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); + if (isset($this->note_private)) $this->note_private=trim($this->note_private); + if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + + $sql.= " fk_loan=".(isset($this->fk_loan)?$this->fk_loan:"null").","; + $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql.= " amount_capital=".(isset($this->amount_capital)?$this->amount_capital:"null").","; + $sql.= " amount_insurance=".(isset($this->amount_insurance)?$this->amount_insurance:"null").","; + $sql.= " amount_interest=".(isset($this->amount_interest)?$this->amount_interest:"null").","; + $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; + $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; + $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; + $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; + $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; + $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; + $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + function calc_mens($capital,$rate,$nbterm) + { + $result=''; + + if (!empty($capital)&&!empty($rate)&&!empty($nbterm)) + { + $result=($capital*($rate/12))/(1-pow((1+($rate/12)),($nbterm*-1))); + } + + return $result; + } + + + /** + * Load all object in memory from database + * + * @param int $loanid Id object + * @return int <0 if KO, >0 if OK + */ + function fetchall($loanid) + { + global $langs; + + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.fk_loan,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.datep,"; + $sql.= " t.amount_capital,"; + $sql.= " t.amount_insurance,"; + $sql.= " t.amount_interest,"; + $sql.= " t.fk_typepayment,"; + $sql.= " t.num_payment,"; + $sql.= " t.note_private,"; + $sql.= " t.note_public,"; + $sql.= " t.fk_bank,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.fk_user_modif"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql.= " WHERE t.fk_loan = ".$loanid; + + dol_syslog(get_class($this)."::fetchall", LOG_DEBUG); + $resql=$this->db->query($sql); + + if ($resql) + { + while($obj = $this->db->fetch_object($resql)) + { + $line = New LoanSchedule($this->db); + $line->id = $obj->rowid; + $line->ref = $obj->rowid; + + $line->fk_loan = $obj->fk_loan; + $line->datec = $this->db->jdate($obj->datec); + $line->tms = $this->db->jdate($obj->tms); + $line->datep = $this->db->jdate($obj->datep); + $line->amount_capital = $obj->amount_capital; + $line->amount_insurance = $obj->amount_insurance; + $line->amount_interest = $obj->amount_interest; + $line->fk_typepayment = $obj->fk_typepayment; + $line->num_payment = $obj->num_payment; + $line->note_private = $obj->note_private; + $line->note_public = $obj->note_public; + $line->fk_bank = $obj->fk_bank; + $line->fk_user_creat = $obj->fk_user_creat; + $line->fk_user_modif = $obj->fk_user_modif; + + $this->lines[] = $line; + } + $this->db->free($resql); + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + /** + * trans_paiment + * + * @return void + */ + function trans_paiment() + { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $toinsert = array(); + + $sql = "SELECT l.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."loan as l "; + $sql.= " WHERE l.paid = 0"; + $resql=$this->db->query($sql); + + if($resql){ + while($obj = $this->db->fetch_object($resql)){ + $lastrecorded = $this->lastpaiment($obj->rowid); + $toinsert = $this->paimenttorecord($obj->rowid, $lastrecorded); + if(count($toinsert)>0){ + foreach ($toinsert as $echid){ + $this->db->begin(); + $sql = "INSERT INTO " .MAIN_DB_PREFIX . "payment_loan "; + $sql.= "(fk_loan,datec,tms,datep,amount_capital,amount_insurance,amount_interest,fk_typepayment,num_payment,note_private,note_public,fk_bank,fk_user_creat,fk_user_modif) "; + $sql.= "SELECT fk_loan,datec,tms,datep,amount_capital,amount_insurance,amount_interest,fk_typepayment,num_payment,note_private,note_public,fk_bank,fk_user_creat,fk_user_modif FROM " . MAIN_DB_PREFIX . "loan_schedule WHERE rowid =" .$echid; + $res=$this->db->query($sql); + if($res){ + $this->db->commit(); + }else { + $this->db->rollback(); + } + } + } + } + } + } + + + /** + * trans_paiment + * + * @param int $loanid Loan id + * @return int < 0 if KO, Date > 0 if OK + */ + function lastpaiment($loanid) + { + $sql = "SELECT p.datep"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p "; + $sql.= " WHERE p.fk_loan = " . $loanid; + $sql.= " ORDER BY p.datep DESC "; + $sql.= " LIMIT 1 "; + + $resql=$this->db->query($sql); + + if($resql){ + $obj = $this->db->fetch_object($resql); + return $this->db->jdate($obj->datep); + }else{ + return -1; + } + } + + /** + * paimenttorecord + * + * @param int $loanid Loan id + * @param int $datemax Date max + * @return array Array of id + */ + function paimenttorecord($loanid, $datemax) + { + $sql = "SELECT p.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; + $sql.= " WHERE p.fk_loan = " . $loanid; + if (!empty($datemax)) { $sql.= " AND p.datep > '" . $this->db->idate($datemax) ."'";} + $sql.= " AND p.datep <= '" . $this->db->idate(dol_now()). "'"; + + $resql=$this->db->query($sql); + + if($resql){ + while($obj = $this->db->fetch_object($resql)) + { + $result[] = $obj->rowid; + } + + } + + return $result; + } +} + diff --git a/htdocs/loan/createschedule.php b/htdocs/loan/createschedule.php new file mode 100644 index 00000000000..596cc9fd536 --- /dev/null +++ b/htdocs/loan/createschedule.php @@ -0,0 +1,208 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/loan/createecheancier.php + * \ingroup loan + * \brief Schedule card + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; + +global $user; + +$loanid = GETPOST('loanid', 'int'); +$action = GETPOST('action'); + +$object = new Loan($db); +$object->fetch($loanid); + +$langs->load('loan'); + +if ($action == 'createecheancier') { + + $i=1; + while($i <$object->nbterm+1){ + + $date = GETPOST('hi_date'.$i,'int'); + $mens = GETPOST('mens'.$i); + $int = GETPOST('hi_interets'.$i); + + $echeance = new LoanSchedule($db); + + $echeance->fk_loan = $object->id; + $echeance->datec = dol_now(); + $echeance->tms = dol_now(); + $echeance->datepaid = $date; + $echeance->amount_capital = $mens-$int; + $echeance->amount_insurance = 0; + $echeance->amount_interest = $int; + $echeance->fk_typepayment = 3; + $echeance->fk_bank = 1; + $echeance->fk_user_creat = $user->id; + $echeance->fk_user_modif = $user->id; + $result=$echeance->create($user); + if ($result<0) { + setEventMessages(null, $echeance->errors,'errors'); + } + $i++; + } +} + +if ($action == 'updateecheancier') { + + $i=1; + while($i <$object->nbterm+1){ + + $mens = GETPOST('mens'.$i); + $int = GETPOST('hi_interets'.$i); + $id = GETPOST('hi_rowid'.$i); + $echeance = new LoanSchedule($db); + $echeance->fetch($id); + $echeance->tms = dol_now(); + $echeance->amount_capital = $mens-$int; + $echeance->amount_insurance = 0; + $echeance->amount_interest = $int; + $echeance->fk_user_modif = $user->id; + $result= $echeance->update($user,0); + if ($result<0) { + setEventMessages(null, $echeance->errors,'errors'); + } + $i++; + } +} + +$echeance = new LoanSchedule($db); +$echeance->fetchall($object->id); + +top_htmlhead('', ''); +$var = ! $var; + + +?> + +'; +print ''; +print ''; +if(count($echeance->lines)>0){ + print ''; +}else{ + print ''; +} +print ''; +print ''; +print '"; +print ''; + +print ''; +Print ''; +Print ''; +Print ''; +Print ''; +Print ''; +print ''; + +if ($object->nbterm > 0 && count($echeance->lines)==0) +{ + $i=1; + $capital = $object->capital; + while($i <$object->nbterm+1){ + $mens = round($echeance->calc_mens($capital, $object->rate/100, $object->nbterm-$i+1),2,PHP_ROUND_HALF_UP); + $int = ($capital*($object->rate/12))/100; + $int = round($int,2,PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + $capital = $cap_rest; + } +}elseif(count($echeance->lines)>0){ + $i=1; + $capital = $object->capital; + foreach ($echeance->lines as $line){ + $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; + $int = $line->amount_interest; + $cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP); + print ''; + print ''; + print ''; + if($line->datep > dol_now()){ + print ''; + }else{ + print ''; + } + print ''; + print ''; + print ''; + $i++; + $capital = $cap_rest; + } +} + +print '
' . "Création d'échéancier
Echéance Date Montant Intérêts Capital restant du
' . $i .'' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . ' €'.price($int,0,'',1).' €'.price($cap_rest).' €
' . $i .'' . dol_print_date($line->datep,'day') . ' €' . price($mens) . ' €'.price($int,0,'',1).' €'.price($cap_rest).' €
'; +print '
'; +print '
'; +print '
'; +print ''; + +llxFooter(); +$db->close(); + + + diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index b04d3bd90b3..3ce2c048057 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -41,7 +41,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 846daad7806..1c99d6e7082 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -55,7 +55,7 @@ if (! $sortfield) $sortfield="u.lastname"; } $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index bcb3cc65699..5e3e8d9342e 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -42,7 +42,7 @@ $result = restrictedArea($user, 'societe','',''); $mesg = ''; $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f5e84dd5c04..2862d3ff862 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -64,7 +64,7 @@ if (! $sortfield) } $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index b1023839eca..907e927c5fd 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -49,7 +49,7 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 45ce972bbc3..3c9e721b3f6 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -42,7 +42,7 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 63b92bc6468..b3f2cc87d73 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -39,20 +39,23 @@ require_once '../lib/mymodule.lib.php'; $langs->load("mymodule@mymodule"); // Access control -if (! $user->admin) { - accessforbidden(); -} +if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + + /* * View */ + $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index f3ce5963aa6..7f1897c80ae 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -62,24 +62,101 @@ class ActionsMyModule */ public function doActions($parameters, &$object, &$action, $hookmanager) { + global $conf, $user, $langs; + $error = 0; // Error counter - $myvalue = 'test'; // A result value + /* print_r($parameters); - echo "action: " . $action; print_r($object); + echo "action: " . $action; + */ + + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + - if (in_array('somecontext', explode(':', $parameters['context']))) { - // do something only for the context 'somecontext' } if (! $error) { - $this->results = array('myreturn' => $myvalue); + $this->results = array('myreturn' => 999); $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code + return 0; // or return 1 to replace standard code } else { $this->errors[] = 'Error message'; return -1; } } + + + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; + + $error = 0; // Error counter + + /* + print_r($parameters); + print_r($object); + echo "action: " . $action; + */ + + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + + foreach($parameters['toselect'] as $objectid) + { + // Do action on each object id + + } + } + + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } + + + /** + * Overloading the addMoreMassActions function : replacing the parent's function with the one below + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; + + $error = 0; // Error counter + + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext' + { + $this->resprints = ''; + } + + if (! $error) { + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } + + + } diff --git a/htdocs/modulebuilder/template/img/object_mytest.png b/htdocs/modulebuilder/template/img/object_mytest.png new file mode 100644 index 00000000000..5a307bfc62f Binary files /dev/null and b/htdocs/modulebuilder/template/img/object_mytest.png differ diff --git a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang index 53c6205386c..c33f2453fc4 100644 --- a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang +++ b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang @@ -18,12 +18,10 @@ # Generic # -# Module label 'ModuleXXXName' -# (where XXX is value of numeric property 'numero' of module) -Module500000Name = My module -# Module description 'ModuleXXXDesc' -# (where XXX is value of numeric property 'numero' of module) -Module500000Desc = My module description +# Module label 'ModuleMyModuleName' +ModuleMyModuleName = My module +# Module description 'ModuleMyModuleDesc' +ModuleMyModuleDesc = My module description # # Admin page diff --git a/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang b/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang index d15d37f0ebf..06e7ba33885 100644 --- a/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang +++ b/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang @@ -18,12 +18,10 @@ # Générique # -# Module label 'ModuleXXXName' -# (where XXX is value of numeric property 'numero' of module) -Module500000Name = Mon module -# Module description 'ModuleXXXDesc' -# (where XXX is value of numeric property 'numero' of module) -Module500000Desc = Description de mon module +# Module label 'ModuleMyModuleName' +ModuleMyModuleName = Mon module +# Module description 'ModuleMyModuleDesc' +ModuleMyModuleDesc = Description de mon module # # Page d'administration diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index a935b87bd58..b1768785f4c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -73,7 +73,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 510a0545372..0d51664f5db 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -42,7 +42,7 @@ $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 5183eeb3382..172bdd9354c 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -74,6 +74,9 @@ $error = 0; * Actions */ +$nomessageinsetmoduleoptions=1; +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setcodeproduct') { if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) @@ -87,36 +90,6 @@ if ($action == 'setcodeproduct') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - //setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - // message yet present at the bottom if($action) - //setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'),'chaine',0,'',$conf->entity); @@ -278,7 +251,7 @@ if ($action) } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("SetupNotError"), null, 'errors'); } } @@ -543,7 +516,7 @@ foreach ($dirmodels as $reldir) print ''; print "
"; - + /* * Other conf */ @@ -598,7 +571,7 @@ print ''; // multiprix nombre de prix a proposer if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - + print ''; print ''.$langs->trans("MultiPricesNumPrices").''; print ''; @@ -640,7 +613,7 @@ print ''; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { - + print ''; print ''.$langs->trans("NumberOfProductShowInSelect").''; print ''; @@ -681,7 +654,7 @@ print ''; // View product description in thirdparty language if (! empty($conf->global->MAIN_MULTILANGS)) { - + print ''; print ''.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; print ''; @@ -723,7 +696,7 @@ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) if ($conf->$module->enabled) { - + print ""; print $object->description; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index e9ae9073835..d0b58c9909c 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -57,7 +57,7 @@ $hookmanager->initHooks(array('productdocuments')); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 57545b07948..41c03756a44 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -40,7 +40,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 1ebbf256c9c..512ae6d08a1 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -81,7 +81,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 74f9c59cff3..7db6e876cf1 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -81,7 +81,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 5320e637316..79b347019d3 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -42,7 +42,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; $offset = $limit * $page ; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 1c72d5f6615..0e6056b91da 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -52,7 +52,7 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index e2f5bccc430..1df5e9fa02f 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -49,7 +49,7 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 506689a6001..06fd9d64916 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -53,7 +53,7 @@ $showmessage=GETPOST('showmessage'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index ac2849fefcf..03979f3e9d3 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -54,7 +54,7 @@ $mesg = ''; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 78d3c470cb1..7ea0800625f 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -65,7 +65,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 1a3d7c9edb2..006f882b820 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -64,7 +64,7 @@ $texte = ''; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index a2b3f1cc667..9cda69560d5 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->load('projects'); +$langs->load('users'); $action=GETPOST('action','aZ09'); $mode=GETPOST("mode"); @@ -62,6 +63,8 @@ $month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("mo $day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d")); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); + +$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); $search_project_ref=GETPOST('search_project_ref', 'alpha'); @@ -75,6 +78,17 @@ $daytoparse = $now; if ($yearofday && $monthofday && $dayofday) $daytoparse=dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) +{ + $usertoprocess=$user; +} +else +{ + $usertoprocess=new User($db); + $usertoprocess->fetch($search_usertoprocessid); +} +$search_usertoprocessid=$usertoprocess->id; + $object=new Task($db); @@ -83,9 +97,10 @@ $object=new Task($db); */ // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $action = ''; + $search_usertoprocessid = ''; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; @@ -125,7 +140,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } if (! $error) { - $idfortaskuser=$user->id; + $idfortaskuser=$usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task @@ -143,7 +158,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $project->fetch($object->fk_project); // Get type $listofprojcontact=$project->liste_type_contact('internal'); - + if (count($listofprojcontact)) { $typeforprojectcontact=reset(array_keys($listofprojcontact)); @@ -151,7 +166,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } } - else + else { dol_print_error($db); } @@ -175,6 +190,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') if (! $error) { setEventMessages("TaskAssignedToEnterTime", null); + $taskid=0; } $action=''; @@ -247,12 +263,12 @@ if ($action == 'addtime' && $user->rights->projet->lire) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); exit; } } - else - { + else + { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } } @@ -286,8 +302,6 @@ $next_day = $next['mday']; $title=$langs->trans("TimeSpent"); if ($mine) $title=$langs->trans("MyTimeSpent"); -$usertoprocess = $user; - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) @@ -314,8 +328,9 @@ llxHeader("",$title,""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); $param=''; -$param.=($mode?'&mode='.$mode:''); -$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($search_userassignedid > 0?'&search_userassignedid='.$search_usertoprocessid:''); // Show navigation bar $nav =''.img_previous($langs->trans("Previous"))."\n"; @@ -337,7 +352,7 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode); +$head=project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperday', '', -1, 'task'); // Show description of content @@ -360,45 +375,17 @@ print ''; dol_fiche_end(); - -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - - -// Add a new project/task -//print '
'; -//print '
'; -//print ''; -//print ''; -//print ''; -//print ''; -//print ''; - -print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. print '
'; -print $langs->trans("AssignTaskToMe").'
'; +$titleassigntask = $langs->trans("AssignTaskToMe"); +if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); +print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); -print ''; -//print ''; +print '
'; +print ' '; +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); +print ''; print '
'; print '
'; @@ -408,6 +395,11 @@ print '
'; print ''."\n"; print ''; +print ''; print ''; print ''; print ''; @@ -427,6 +419,7 @@ print ''; print "\n"; print ''; +print ''; print ''; print ''; print ''; @@ -436,12 +429,15 @@ if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) } print ''; print ''; -print ''; +/*print ''; if ($usertoprocess->id == $user->id) print ''; -else print ''; +else print '';*/ +print ''; +print ''; print ''; -print ''; +print ''; print ''; +print ''; print "\n"; @@ -455,7 +451,7 @@ if (count($tasksarray) > 0) } else { - print ''; + print ''; } print "
'; +$usersettoshow='hierarchyme'; +if ($user->rights->projet->all->lire) $usersettoshow=''; +print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150'); +print '
'.$langs->trans("User").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')
'.$langs->trans("TimeSpent").''.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Duration").''.$langs->trans("Note").'
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print '
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index da5303511ad..4a2156430af 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -58,11 +58,14 @@ $nowtmp=dol_getdate($now); $nowday=$nowtmp['mday']; $nowmonth=$nowtmp['mon']; $nowyear=$nowtmp['year']; + $year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); $month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m")); $day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d")); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); + +$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); $search_project_ref=GETPOST('search_project_ref', 'alpha'); @@ -88,7 +91,16 @@ $next_day = $next['day']; $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); -$usertoprocess=$user; +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) +{ + $usertoprocess=$user; +} +else +{ + $usertoprocess=new User($db); + $usertoprocess->fetch($search_usertoprocessid); +} +$search_usertoprocessid=$usertoprocess->id; $object=new Task($db); @@ -98,9 +110,10 @@ $object=new Task($db); */ // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $action = ''; + $search_usertoprocessid = ''; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; @@ -137,13 +150,13 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - + if (! $error) { - $idfortaskuser=$user->id; + $idfortaskuser=$usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); - if (! $result || $result == -2) // Contact add ok or already contact of task + if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; @@ -158,7 +171,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $project->fetch($object->fk_project); // Get type $listofprojcontact=$project->liste_type_contact('internal'); - + if (count($listofprojcontact)) { $typeforprojectcontact=reset(array_keys($listofprojcontact)); @@ -166,7 +179,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } } - else + else { dol_print_error($db); } @@ -190,6 +203,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') if (! $error) { setEventMessages("TaskAssignedToEnterTime", null); + $taskid=0; } $action=''; @@ -233,16 +247,16 @@ if ($action == 'addtime' && $user->rights->projet->lire) $error++; break; } - + $updateoftaskdone++; } } } - + if (! $updateoftaskdone) // Check to update progress if no update were done on task. { $object->fetch($taskid); - //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; + //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; if ($object->progress != GETPOST($taskid . 'progress', 'int')) { $object->progress = GETPOST($taskid . 'progress', 'int'); @@ -262,7 +276,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:'')); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:'')); exit; } } @@ -312,14 +326,15 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); $param=''; -$param.=($mode?'&mode='.$mode:''); -$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; +$nav =''.img_previous($langs->trans("Previous"))."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; +$nav.=''.img_next($langs->trans("Next"))."\n"; +$nav.="   (".$langs->trans("Today").")"; $nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; $nav.=' '; @@ -333,7 +348,7 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode); +$head=project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperweek', '', -1, 'task'); // Show description of content @@ -356,44 +371,17 @@ print ''; dol_fiche_end(); -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - - -// Add a new project/task -//print '
'; -//print '
'; -//print ''; -//print ''; -//print ''; -//print ''; -//print ''; - -print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. print '
'; -print $langs->trans("AssignTaskToMe").'
'; +$titleassigntask = $langs->trans("AssignTaskToMe"); +if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); +print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); -print ''; -//print ''; +print '
'; +print ' '; +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); +print ''; print '
'; print '
'; @@ -403,6 +391,11 @@ print '
'; print ''."\n"; print ''; +print ''; print ''; print ''; print ''; @@ -423,6 +416,7 @@ print ''; print "\n"; print ''; +print ''; print ''; print ''; print ''; @@ -432,9 +426,11 @@ if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) } print ''; print ''; +/*print ''; + if ($usertoprocess->id == $user->id) print ''; + else print '';*/ +print ''; print ''; -if ($usertoprocess->id == $user->id) print ''; -else print ''; $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); @@ -452,16 +448,16 @@ if (count($tasksarray) > 0) { //var_dump($tasksarray); //var_dump($tasksrole); - + $j=0; $level=0; projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask); - $colspan=7; + $colspan=8; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; - + print ' - + @@ -474,7 +470,7 @@ if (count($tasksarray) > 0) } else { - print ''; + print ''; } print "
'; +$usersettoshow='hierarchyme'; +if ($user->rights->projet->all->lire) $usersettoshow=''; +print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150'); +print '
'.$langs->trans("User").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')
'.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").'
'.$langs->trans("Total").''.$langs->trans("Total").'
 
 
 
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print '
'; diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index fbcecf032cf..9e35ea77e0b 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -51,6 +51,8 @@ $type='project'; * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setmainoptions') { if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity); @@ -104,7 +106,7 @@ else if ($action == 'specimen') $project = new Project($db); $project->initAsSpecimen(); - + // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); @@ -188,35 +190,6 @@ else if ($action == 'specimentask') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -414,7 +387,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''.$module->name."\n"; print $module->info(); print ''; @@ -518,7 +491,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) if ($module->isEnabled()) { - + print ''.$module->name."\n"; print $module->info(); print ''; @@ -660,7 +633,7 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - + print ''; print (empty($module->name)?$name:$module->name); print "\n"; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f6355ec5566..0b45a0d0696 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -134,7 +134,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - + if (! $error) { $error=0; @@ -308,8 +308,8 @@ if (empty($reshook)) setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors'); } } - - + + if ($error) { $db->rollback(); @@ -322,7 +322,7 @@ if (empty($reshook)) if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int')); else unset($object->thirdparty); } - + } // Build doc @@ -623,7 +623,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print '     '; print ''; - } + } print ''; print ''; @@ -645,12 +645,12 @@ if ($action == 'create' && $user->rights->projet->creer) }); '; } -elseif ($object->id > 0) +elseif ($object->id > 0) { /* * Show or edit */ - + $res=$object->fetch_optionals($object->id,$extralabels); // To verify role of users @@ -711,10 +711,11 @@ elseif ($object->id > 0) print ''; $head=project_prepare_head($object); - dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); if ($action == 'edit' && $userWrite > 0) { + dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); + print ''; // Ref @@ -835,27 +836,30 @@ elseif ($object->id > 0) } else { + dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + // Project card - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; // Title $morehtmlref.=$object->title; // Thirdparty - if ($object->thirdparty->id > 0) + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : '; + if ($object->thirdparty->id > 0) { - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -889,7 +893,7 @@ elseif ($object->id > 0) if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency); print ''; } - + // Date start - end print ''; - + // Budget print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start,'dayhour'); @@ -899,7 +903,7 @@ elseif ($object->id > 0) print ($end?$end:'?'); if ($object->hasDelay()) print img_warning("Late"); print '
'.$langs->trans("Budget").''; if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency); @@ -908,16 +912,16 @@ elseif ($object->id > 0) // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'; - + print ''; print '
'; print '
'; print '
'; - + print ''; - + // Description print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($object->description); @@ -929,13 +933,13 @@ elseif ($object->id > 0) print $form->showCategories($object->id,'project',1); print "
'; - + print '
'; print '
'; print ''; - + print '
'; } @@ -954,9 +958,10 @@ elseif ($object->id > 0) // Change probability from status if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + // Default value to close or not when we set opp to 'WON'. $defaultcheckedwhenoppclose=1; if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; - + print ''; print ''; */ - + // Personalized checkout print ''; - + print ' - +
'; @@ -1106,11 +1116,11 @@ if (preg_match('/^dopayment/',$action)) print ''; print ''."\n"; print ''."\n"; - + print '
- +
@@ -1126,22 +1136,22 @@ if (preg_match('/^dopayment/',$action))
- +
- + - + '; + print ''; } diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index 2d8e260d85a..f3c48f754ec 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -53,7 +53,7 @@ $result = restrictedArea($user, 'resource', $id, 'resource'); $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 63ba12197fd..5c84be25521 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -42,6 +42,9 @@ if (!$user->admin) accessforbidden(); /* * Actions */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setcodeclient') { if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) @@ -101,35 +104,6 @@ if ($action == 'updateoptions') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a document generator module if ($action == 'set') { diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 32d13356654..d0eb936fcbb 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -54,7 +54,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 346f4ea38dc..ba4383e6f8e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2417,7 +2417,7 @@ else if ($user->rights->societe->supprimer) { - print ''; + print ''; } if ($user->rights->societe->supprimer) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 17018091951..056a67e5587 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -43,7 +43,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 3802397509b..78af32c652a 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -53,7 +53,7 @@ $result = restrictedArea($user, 'societe', $id, '&societe'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 7019933fb9c..20323136017 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -356,11 +356,13 @@ class SupplierProposal extends CommonObject * @param array $array_option extrafields array * @param string $ref_fourn Supplier price reference * @param int $fk_unit Id of the unit to use. + * @param string $origin 'order', 'supplier_proposal', ... + * @param int $origin_id Id of origin line * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$array_option=0, $ref_fourn='', $fk_unit='') + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$array_option=0, $ref_fourn='', $fk_unit='', $origin='', $origin_id=0) { global $mysoc; @@ -462,7 +464,8 @@ class SupplierProposal extends CommonObject $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; $this->line->fk_unit=$fk_unit; - + $this->line->origin=$origin; + $this->line->origin_id=$origin_id; $this->line->ref_fourn = $this->db->escape($ref_fourn); // infos marge @@ -880,7 +883,10 @@ class SupplierProposal extends CommonObject $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, - $this->lines[$i]->ref_fourn + $this->lines[$i]->ref_fourn, + $this->lines[$i]->fk_unit, + 'supplier_proposal', + $this->lines[$i]->rowid ); if ($result < 0) diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 62ff5e0c71a..cec276a6064 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -53,7 +53,7 @@ $result = restrictedArea($user, 'supplier_proposal', $id); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 2c10e2451a6..10aa98fee3f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -84,7 +84,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 33bba8f1404..3912a9b80ff 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -39,7 +39,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $colorbackhmenu1='80,90,120'; // topmenu $colorbackvmenu1='255,255,255'; // vmenu $colortopbordertitle1='120,120,120'; // top border of title -$colorbacktitle1='230,230,230'; // title of tables,list +$colorbacktitle1='230,230,233'; // title of tables,list $colorbacktabcard1='255,255,255'; // card $colorbacktabactive='234,234,234'; $colorbacklineimpair1='255,255,255'; // line impair @@ -56,7 +56,7 @@ $fontsize='13'; $fontsizesmaller='12'; if (defined('THEME_ONLY_CONSTANT')) return; - + session_cache_limiter(FALSE); require_once '../../main.inc.php'; @@ -272,8 +272,8 @@ input[type=submit] { margin-left: 5px; } input, input.flat, form.flat select, select, select.flat, .dataTables_length label select { - global->THEME_ELDY_SHOW_BORDER_INPUT)) - print "border: none;" + global->THEME_ELDY_SHOW_BORDER_INPUT)) + print "border: none;" ?> } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { @@ -340,9 +340,9 @@ input.buttongen { vertical-align: middle; } span.timesheetalreadyrecorded input { - /*font-size: smaller;*/ border: none; - /*background: transparent;*/ + border-bottom: solid 1px rgba(0,0,0,0.4); + margin-right: 1px !important; } select.flat, form.flat select { @@ -363,8 +363,10 @@ select.flat, form.flat select { .opacitytransp { opacity: 0; } -select:invalid { color: gray; } - input:disabled { +select:invalid { + color: gray; +} +input:disabled { background:#ddd; } @@ -712,6 +714,7 @@ div.fiche>form>div.div-table-responsive { align-self: flex-start; } + /* ============================================================================== */ /* Styles to hide objects */ /* ============================================================================== */ @@ -901,7 +904,7 @@ td.showDragHandle { #id-right, #id-left { padding-top: 16px; padding-bottom: 16px; - + display: table-cell; /* DOL_XXX Empeche fonctionnement correct du scroll horizontal sur tableau, avec datatable ou CSS */ float: none; vertical-align: top; @@ -987,7 +990,7 @@ div.fiche { div.fiche { margin-: px; - margin-: dol_optimize_smallscreen)?'16':'6')); ?>px; + margin-: dol_optimize_smallscreen)?'16':'12')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'."\n"; ?> dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> } @@ -1529,7 +1532,7 @@ foreach($mainmenuusedarray as $val) display: table; position: absolute; height: 100%; - width: 100%; + width: 100%; } .login_center { display: table-cell; @@ -1754,12 +1757,12 @@ div.vmenu, td.vmenu { } -/* Force vmenusearchselectcombo with type=text differently than without because beautify with select2 affect vmenusearchselectcombo differently */ +/* Force vmenusearchselectcombo with type=text differently than without because beautify with select2 affect vmenusearchselectcombo differently */ input.vmenusearchselectcombo[type=text] { width: 180px !important; } .vmenusearchselectcombo { - width: 188px; + width: 188px; } .menu_contenu { @@ -1926,7 +1929,7 @@ td.ecmroot { background-image: -webkit-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important; background-image: -ms-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important; background-image: linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important; - + background: #FFF; background-repeat: repeat-x !important; */ @@ -1939,7 +1942,7 @@ td.ecmroot { -webkit-box-shadow: 2px 2px 4px #DDD; box-shadow: 2px 2px 4px #DDD; */ - + padding: 10px 4px 14px 4px !important; min-height: 32px; } @@ -1969,7 +1972,7 @@ div.tabs { padding-right: 6px !important; clear:both; height:100%; - /* background-image: linear-gradient(to top,#f6f6f6 0,#fff 8px); */ + /* background-image: linear-gradient(to top,#f6f6f6 0,#fff 8px); */ } div.tabsElem { margin-top: 1px; @@ -1987,12 +1990,12 @@ div.tabBar { background: rgb(); } div.tabBar div.titre { - padding-top: 10px; + padding-top: 10px; } div.tabBarWithBottom { padding-bottom: 18px; - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } div.tabBar table.tableforservicepart2:last-child { border-bottom: 1px solid #aaa; @@ -2623,7 +2626,7 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se background: rgb(); font-weight: ; border-bottom: 1px solid #ddd; - + color: rgb(); font-family: ; text-align: ; @@ -2682,7 +2685,7 @@ input.liste_titre { } .noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - /* background: #F0F0F0; */ + height: 32px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { color: #552266; @@ -2734,7 +2737,7 @@ div.tabBar .noborder { /* Prepare to remove class pair - impair */ -.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { background: linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); @@ -2761,7 +2764,7 @@ div.tabBar .noborder { /* * Boxes */ - + .ficheaddleft div.boxstats { border: none; } @@ -2775,19 +2778,19 @@ div.tabBar .noborder { text-align: center; border-radius: 2px; } -.boxstats, .boxstats130, .boxstatscontent { +.boxstats, .boxstats130, .boxstatscontent { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .boxstats { padding: 3px; - width: 105px; + width: 105px; } .boxstats130 { - width: 160px; + width: 160px; height: 48px; - padding: 3px + padding: 3px } .boxstatscontent { padding: 3px; @@ -2795,13 +2798,16 @@ div.tabBar .noborder { @media only screen and (max-width: 767px) { + .thumbstat { + flex: 1 1 110px; + } .thumbstat150 { flex: 1 1 110px; } .boxstats, .boxstats130 { - width: 90px; + width: 90px; } - .dashboardlineindicator { + .dashboardlineindicator { float: left; padding-left: 5px; } @@ -2833,7 +2839,7 @@ span.dashboardlineko { color: #FFF; /*color: #8c4446 ! important; padding-left: 1px;*/ - + font-size: 80%; } .dashboardlinelatecoin { @@ -2842,9 +2848,9 @@ span.dashboardlineko { text-align: right; top: -24px; padding: 1px 2px 1px 2px; - border-radius: .25em; + border-radius: .25em; - background-color: #af4705; + background-color: #9f4705; padding: 0px 5px 0px 5px; top: -26px; } @@ -2854,7 +2860,7 @@ span.dashboardlineko { margin-right: 2px; background-color: #8c4446; color: #FFFFFF ! important; - border-radius: .25em; + border-radius: .25em; display: inline-block; vertical-align: middle; } @@ -3955,7 +3961,7 @@ div.dataTables_length select { border-top: 1px solid #ccc; border-bottom: solid 1px rgba(0,0,0,.2); } -.select2-container-active .select2-choice, .select2-container-active .select2-choices +.select2-container-active .select2-choice, .select2-container-active .select2-choices { outline: none; border-top: none; @@ -4039,7 +4045,7 @@ a span.select2-chosen border-right: none; border-top: none; border-left: none; - + } @@ -4593,7 +4599,12 @@ div.tabsElem a.tab { z-index: 201; background: #FFF; } - + + .login_vertical_align { + padding-left: 20px; + padding-right: 20px; + } + /* Reduce login top right info */ .help { @@ -4628,7 +4639,7 @@ div.tabsElem a.tab { vertical-align: middle; background: #FFF; height: 42px; - + z-index: 202; min-width: 190px; max-width: 190px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a1851dc4a76..d3f822bcca2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -317,7 +317,7 @@ textarea { border-left:solid 1px rgba(0,0,0,.1); border-right:solid 1px rgba(0,0,0,.1); border-bottom:solid 1px rgba(0,0,0,.2); - + background-color: #FFF; padding:4px; margin-left:1px; @@ -337,9 +337,9 @@ input.buttongen { vertical-align: middle; } span.timesheetalreadyrecorded input { - /*font-size: smaller;*/ border: none; - /*background: transparent;*/ + border-bottom: solid 1px rgba(0,0,0,0.1); + margin-right: 1px !important; } select.flat, form.flat select { @@ -867,10 +867,10 @@ div.fiche>form>div.div-table-responsive { width: 20px; object-fit: contain; } - + div.statusref { padding-right: 10px; - } + } } .linkobject { cursor: pointer; } @@ -1027,7 +1027,7 @@ div.fiche { div.fiche { margin-: px; - margin-: dol_optimize_smallscreen)?'16':'4')); ?>px; + margin-: dol_optimize_smallscreen)?'16':'12')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; } @@ -1557,12 +1557,12 @@ foreach($mainmenuusedarray as $val) display: table; position: absolute; height: 100%; - width: 100%; + width: 100%; } .login_center { display: table-cell; vertical-align: middle; -} +} .login_vertical_align { padding: 10px; padding-bottom: 80px; @@ -1992,14 +1992,14 @@ div.tabBar { border-top: 1px solid #CCC; width: auto; background: rgb(); - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } div.tabBar div.titre { - padding-top: 10px; + padding-top: 10px; } div.tabBarWithBottom { padding-bottom: 18px; - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } div.tabBar table.tableforservicepart2:last-child { border-bottom: 1px solid #aaa; @@ -2720,7 +2720,7 @@ tr.liste_titre th, tr.liste_titre td, th.liste_titre, form.liste_titre div, div. { border-bottom: 1px solid #; } -/* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ +/* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ tr:first-child th.liste_titre { border-bottom: 1px solid #FFF ! important; } @@ -2769,7 +2769,7 @@ input.liste_titre { } .noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - /* background: #F0F0F0; */ + height: 32px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { /* border-top: 1px solid #f4f4f4; */ @@ -2777,7 +2777,6 @@ input.liste_titre { font-weight: normal; white-space: nowrap; padding: 4px; - height: 20px; } tr.liste_sub_total, tr.liste_sub_total td { border-bottom: 2px solid #aaa; @@ -2826,7 +2825,7 @@ div .tdtop { /* Prepare to remove class pair - impair */ -.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { background: linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); @@ -2852,7 +2851,7 @@ div .tdtop { /* * Boxes */ - + .ficheaddleft div.boxstats { border: none; } @@ -2866,29 +2865,32 @@ div .tdtop { text-align: center; border-radius: 2px; } -.boxstats, .boxstats130, .boxstatscontent { +.boxstats, .boxstats130, .boxstatscontent { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .boxstats { padding: 3px; - width: 105px; + width: 105px; } .boxstats130 { - width: 135px; + width: 135px; height: 48px; - padding: 3px + padding: 3px } @media only screen and (max-width: 767px) { + .thumbstat { + flex: 1 1 110px; + } .thumbstat150 { flex: 1 1 110px; } .boxstats, .boxstats130 { - width: 90px; + width: 90px; } - .dashboardlineindicator { + .dashboardlineindicator { float: left; padding-left: 5px; } @@ -2927,7 +2929,7 @@ span.dashboardlineko { padding: 1px 6px 1px 6px; background-color: #8c4446; color: #FFFFFF ! important; - border-radius: .25em; + border-radius: .25em; } .boxtable { margin-bottom: 8px !important; @@ -4047,7 +4049,7 @@ div.dataTables_length select { border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } -.select2-container-active .select2-choice, .select2-container-active .select2-choices +.select2-container-active .select2-choice, .select2-container-active .select2-choices { outline: none; border-top: none; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index c6123df3e77..c56f76af246 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -143,16 +143,16 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); - foreach ($listofsqldir as $dir) + foreach ($listofsqldir as $dir) { print 'Process dir '.$dir."\n"; $filesarray = scandir($dir); - - foreach($filesarray as $key => $file) + + foreach($filesarray as $key => $file) { if (! preg_match('/\.sql$/',$file)) continue; - + print 'Check sql file '.$file."\n"; $filecontent=file_get_contents($dir.'/'.$file); @@ -167,7 +167,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $result=strpos($filecontent,'ON DELETE CASCADE'); print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); - + if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') { // Test for migration files only @@ -176,16 +176,20 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase else { if (preg_match('/\.key\.sql$/',$file)) - { - // Test for files key files only - + { + // Test for key files only + } else { - // Test for files non key files only + // Test for non key files only $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY ') == 0); print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); + + $result=stripos($filecontent,'ENGINE=innodb'); + print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n"; + $this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.'); } } } diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 02d85164d79..645993d8659 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -179,32 +179,32 @@ class DateLibTest extends PHPUnit_Framework_TestCase $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + // With same hours - Tuesday/Wednesday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 1, 2013); $date2=dol_mktime(0, 0, 0, 1, 2, 2013); - + $result=num_public_holiday($date1,$date2,'FR',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for FR'); // 1 closed days - + $result=num_public_holiday($date1,$date2,'XX',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(0,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for XX'); // no closed days (country unknown) - + // With same hours - Friday/Sunday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 4, 2013); $date2=dol_mktime(0, 0, 0, 1, 6, 2013); - + $result=num_public_holiday($date1,$date2,'FR',1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days - + $this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days + $result=num_public_holiday($date1,$date2,'XX',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(2,$result,'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) } - + /** * testNumOpenDay * @@ -217,32 +217,32 @@ class DateLibTest extends PHPUnit_Framework_TestCase $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + // With same hours - Tuesday/Wednesday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 1, 2013); $date2=dol_mktime(0, 0, 0, 1, 2, 2013); - + $result=num_open_day($date1,$date2,0,1,0,'FR'); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for FR'); // 1 opened days - + $result=num_open_day($date1,$date2,0,1,0,'XX'); print __METHOD__." result=".$result."\n"; $this->assertEquals(2,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for XX'); // 2 opened days (country unknown) - + // With same hours - Friday/Sunday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 4, 2013); $date2=dol_mktime(0, 0, 0, 1, 6, 2013); - + $result=num_open_day($date1,$date2,0,1,0,'FR'); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay for FR'); // 1 opened day, 2 closed - + $result=num_open_day($date1,$date2,'XX',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown) } - + /** * testConvertTime2Seconds * @@ -335,6 +335,11 @@ class DateLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals('02/01/1970 00:00',$result); + // Check %a and %b format for fr_FR + $result=dol_print_date(0,'%a %b %B',true,$outputlangs); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('Jeu Jan. Janvier',$result); + // Check day format for en_US $outputlangs=new Translate('',$conf); $outputlangs->setDefaultLang('en_US'); @@ -345,9 +350,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase $this->assertEquals('01/02/1970',$result); // Check %a and %b format for en_US - $result=dol_print_date(0,'%a %b',true,$outputlangs); + $result=dol_print_date(0,'%a %b %B',true,$outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('Thu Jan',$result); + $this->assertEquals('Thu Jan January',$result); return $result; }