diff --git a/.travis.yml b/.travis.yml index db0f3196cf8..27a7c64bf46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ php: - '5.3' - '5.4' - '5.5' -- '5.6.29' +- '5.6' - '7.0' - '7.1' - nightly @@ -305,6 +305,9 @@ script: php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade500600-2.log php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log cd - set +e echo diff --git a/COPYRIGHT b/COPYRIGHT index 04f0358a655..427784a1552 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -53,6 +53,7 @@ jQuery Tiptip 1.3 GPL and MIT License Yes jsGanttImproved 1.7.5.2 BSD License Yes JS library (to build Gantt reports) JsTimezoneDetect 1.0.6 MIT License Yes JS library to detect user timezone SwaggerUI 2.0.24 GPL-2+ Yes JS library to offer the REST API explorer +Ace 1.2.8 BSD Yes JS library to get code syntaxique coloration in a textarea. For licenses compatibility informations: http://www.gnu.org/licenses/licenses.en.html diff --git a/ChangeLog b/ChangeLog index 9cd6f11d1b8..d5bdaa43239 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 7.0.0 compared to 6.0.* ***** + + + ***** ChangeLog for 6.0.0 compared to 5.0.* ***** For developers: diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 9b82bd05b2a..3b9ef4cc447 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -5,7 +5,7 @@ in Dolibarr root. ALL: ---- -Check "DOL_CHANGE" +Check "@CHANGE" CKEDITOR (4.6.2): diff --git a/dev/resources/iso-normes/sample_FEC_file.txt b/dev/resources/iso-normes/sample_FEC_file.txt index 5ca795af5c2..8ca50c92617 100644 --- a/dev/resources/iso-normes/sample_FEC_file.txt +++ b/dev/resources/iso-normes/sample_FEC_file.txt @@ -1,4 +1,4 @@ -JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE +JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE Banque Banque 17293 20170109 401PPRO PUBLI-PROV L08 20170109 PPRO domiciliation 1TR 187,20 0,00 20170109 Banque Banque 17293 20170109 5121CRA CR AGRICOLE L08 20170109 PPRO domiciliation 1TR 0,00 187,20 20170109 Banque Banque 17295 20170109 401ORPA ORANGE PARIS Report 20170109 ORPA adsl par 12 96,00 0,00 20170109 diff --git a/dev/resources/iso-normes/world_tax_rates.txt b/dev/resources/iso-normes/world_tax_rates.txt index e5bb64a86f2..740062288dc 100644 --- a/dev/resources/iso-normes/world_tax_rates.txt +++ b/dev/resources/iso-normes/world_tax_rates.txt @@ -1 +1,4 @@ -http://www.taxrates.cc/index.html \ No newline at end of file +http://www.taxrates.cc/index.html + +For India: VAT=IGST/CGST=Localtax1/SGST=Localtax2: https://cleartax.in/s/what-is-sgst-cgst-igst + diff --git a/dev/tools/rmphpclosingtag.sh b/dev/tools/rmphpclosingtag.sh deleted file mode 100755 index ec755bc399b..00000000000 --- a/dev/tools/rmphpclosingtag.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# vim:ft=sh:ts=3:sts=3:sw=3:et: - -### -# Strips the closing php tag `?>` and any following blank lines from the -# end of any PHP file in the current working directory and sub-directories. Files -# with non-whitespace characters following the closing tag will not be affected. -# -# Author: Bryan C. Geraghty -# Date: 2009-10-28 -# Source: http://bryan.ravensight.org/2010/07/remove-php-closing-tag/ -## - -FILES=$(pcregrep -rnM --include='^.*\.php$' '^\?\>(?=([\s\n]+)?$(?!\n))' .); - -for MATCH in $FILES; -do - FILE=`echo $MATCH | awk -F ':' '{print $1}'`; - TARGET=`echo $MATCH | awk -F ':' '{print $2}'`; - LINE_COUNT=`wc -l $FILE | awk -F " " '{print $1}'`; - echo "Removing lines ${TARGET} through ${LINE_COUNT} from file $FILE..."; - sed -i "${TARGET},${LINE_COUNT}d" $FILE; -done; diff --git a/dev/translation/erp_comparison_translation.txt b/dev/translation/erp_comparison_translation.txt index fb96c17e3f9..c99a5f4cc1c 100644 --- a/dev/translation/erp_comparison_translation.txt +++ b/dev/translation/erp_comparison_translation.txt @@ -12,3 +12,6 @@ Balance ?? Net profit Subledger account Subledger account ?? +Proposal ?? Quotation Proposal is ok but proposition looks better (proposal is for a detailed proposition). We can say also "business proposition or business proposal". + Indian are using "Quotation". + diff --git a/dev/translation/strip_language_file.php b/dev/translation/strip_language_file.php index 647b571c788..92233d71b98 100755 --- a/dev/translation/strip_language_file.php +++ b/dev/translation/strip_language_file.php @@ -303,6 +303,8 @@ foreach($filesToProcess as $fileToProcess) // ----- Process output now ----- + //print "Found primary key = ".$key."\n"; + // Key not in other file if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key)) { @@ -321,7 +323,7 @@ foreach($filesToProcess as $fileToProcess) || in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/',$key) || preg_match('/^FormatHour/',$key) ) { - //print "Key $key differs so we add it into new secondary language (line: $cnt).\n"; + //print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n"; fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n"); } } diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index e369081f7e1..905fd8b97ef 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -97,7 +97,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_account = ""; $search_label = ""; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index fd8c67246f4..f9200a575be 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -46,7 +46,7 @@ if ($cat_id == 0) { } // Security check -if (! empty($user->rights->accountancy->chartofaccount)) +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -104,7 +104,7 @@ $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0 print ''; print ''; -if (! empty($cat_id)) +if (! empty($cat_id)) { $return = $accountingcategory->getAccountsWithNoCategory($cat_id); if ($return < 0) { @@ -164,4 +164,4 @@ if ($action == 'display' || $action == 'delete') { llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index cb852d82e0c..270d882eac7 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -57,7 +57,7 @@ $rowid=GETPOST('rowid','alpha'); $code=GETPOST('code','alpha'); // Security access -if (! empty($user->rights->accountancy->chartofaccount)) +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 9cf4d2977fd..ce99bd6296c 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -42,7 +42,7 @@ $langs->load("salaries"); $langs->load("loan"); // Security check -if (! empty($user->rights->accountancy->chartofaccount)) +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 7a209be45b1..433448fa688 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -38,7 +38,7 @@ $langs->load("admin"); $langs->load("accountancy"); // Security check -if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount)) +if (empty($user->admin) && empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 7a8ab0673a7..fa817942a54 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -43,10 +43,10 @@ $id = GETPOST('id', 'int'); // List of statut static $tmpstatut2label = array ( '0' => 'OpenFiscalYear', - '1' => 'CloseFiscalYear' + '1' => 'CloseFiscalYear' ); $statut2label = array ( - '' + '' ); foreach ( $tmpstatut2label as $key => $val ) $statut2label[$key] = $langs->trans($val); @@ -69,7 +69,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { } else { setEventMessages($object->error, $object->errors, 'errors'); } -} +} else if ($action == 'add') { if (! GETPOST('cancel', 'alpha')) { @@ -113,7 +113,7 @@ else if ($action == 'add') { header("Location: ./fiscalyear.php"); exit(); } -} +} // Update record else if ($action == 'update') { @@ -126,7 +126,7 @@ else if ($action == 'update') { $object->statut = GETPOST('statut', 'int'); $result = $object->update($user); - + if ($result > 0) { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); @@ -151,7 +151,7 @@ llxHeader("",$title,$helpurl); $form = new Form($db); -if ($action == 'create') +if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); @@ -184,7 +184,7 @@ if ($action == 'create') print $form->selectarray('statut', $statut2label, GETPOST('statut')); print ''; */ - + print ''; dol_fiche_end(); @@ -306,9 +306,9 @@ if ($action == 'create') print '
'; print '' . $langs->trans('Modify') . ''; - + // print '' . $langs->trans('Delete') . ''; - + print '
'; } } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index ead997a5d8c..b6aceb52ad4 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -266,7 +266,7 @@ if (! empty($user->admin)) } -// Param a user $user->rights->accountancy->chartofaccount can access +// Param a user $user->rights->accounting->chartofaccount can access foreach ($list as $key) { print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index dca29fd28b8..a3912aebc89 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -41,7 +41,7 @@ $rowid=GETPOST('rowid','alpha'); $code=GETPOST('code','alpha'); // Security access -if (! empty($user->rights->accountancy->chartofaccount)) +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -134,6 +134,7 @@ $elementList = array(); '2' => $langs->trans('AccountingJournalType2'), '3' => $langs->trans('AccountingJournalType3'), '4' => $langs->trans('AccountingJournalType4'), + '5' => $langs->trans('AccountingJournalType5'), '9' => $langs->trans('AccountingJournalType9') ); @@ -743,4 +744,4 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; } } -} \ No newline at end of file +} diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 311aab692ff..c72ce8cc134 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -98,7 +98,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref = ''; $search_label = ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index e742f4651cf..fb503c17ca0 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -98,7 +98,7 @@ if (! empty($search_accountancy_code_end)) { * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 9be65e7261a..d05dc11ed26 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2013-2017 Florian Henry * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2017 Laurent Destailleur * * 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 @@ -16,13 +17,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + /** * \file htdocs/accountancy/bookkeeping/card.php * \ingroup Advanced accountancy * \brief Page to show book-entry */ -require '../../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; @@ -38,7 +40,7 @@ if ($user->societe_id > 0) { accessforbidden(); } $action = GETPOST('action','aZ09'); -$mode = GETPOST('mode'); +$mode = GETPOST('mode','aZ09'); // '' or 'tmp' $piece_num = GETPOST("piece_num"); $mesg = ''; @@ -53,29 +55,41 @@ $label_operation= GETPOST('label_operation'); $debit = price2num(GETPOST('debit')); $credit = price2num(GETPOST('credit')); -$save = GETPOST('save'); -if (! empty($save)) { - $action = 'add'; -} -$update = GETPOST('update'); -if (! empty($update)) { - $action = 'confirm_update'; -} +$save = GETPOST('save','alpha'); +if (! empty($save)) $action = 'add'; +$update = GETPOST('update','alpha'); +if (! empty($update)) $action = 'confirm_update'; + $object = new BookKeeping($db); + + +/* + * Actions + */ + if ($action == "confirm_update") { $error = 0; if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $action='update'; } + if (empty($account_number) || $account_number == '-1') + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action='update'; + } - if (empty($error)) { + if (! $error) + { $book = new BookKeeping($db); $result = $book->fetch($id, null, $mode); if ($result < 0) { + $error++; setEventMessages($book->error, $book->errors, 'errors'); } else { $book->numero_compte = $account_number; @@ -98,7 +112,14 @@ if ($action == "confirm_update") { if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + if ($mode != '_tmp') + { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + } + + $debit = 0; + $credit = 0; + $action = ''; } } @@ -108,12 +129,20 @@ if ($action == "confirm_update") { else if ($action == "add") { $error = 0; - if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; + if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) + { + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $action=''; + } + if (empty($account_number) || $account_number == '-1') + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action=''; } - if (empty($error)) { + if (! $error) { $book = new BookKeeping($db); $book->numero_compte = $account_number; @@ -144,7 +173,14 @@ else if ($action == "add") { if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + if ($mode != '_tmp') + { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + } + + $debit = 0; + $credit = 0; + $action = ''; } } @@ -172,6 +208,11 @@ else if ($action == "confirm_create") { $book = new BookKeeping($db); + if (! GETPOST('code_journal') || GETPOST('code_journal') == '-1') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); + $action='create'; + $error++; + } if (! GETPOST('next_num_mvt')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); @@ -196,7 +237,10 @@ else if ($action == "confirm_create") { if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + if ($mode != '_tmp') + { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + } $action = 'update'; $id=$book->id; $piece_num = $book->piece_num; @@ -210,39 +254,43 @@ if ($action == 'setdate') { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + if ($mode != '_tmp') + { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + } $action = ''; } } if ($action == 'setjournal') { $journaldoc = trim(GETPOST('code_journal')); - if (!empty($journaldoc)) { - $journaldoc='\''.$journaldoc.'\''; - } $result = $object->updateByMvt($piece_num,'code_journal',$journaldoc,$mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + if ($mode != '_tmp') + { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + } $action = ''; } } if ($action == 'setdocref') { $refdoc = trim(GETPOST('doc_ref')); - if (!empty($refdoc)) { - $refdoc='\''.$refdoc.'\''; - } - $result = $object->updateByMvt(doc_ref,'code_journal',$refdoc,$mode); + $result = $object->updateByMvt($piece_num,'doc_ref',$refdoc,$mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + if ($mode != '_tmp') + { + setEventMessages($langs->trans('Saved'), null, 'mesgs'); + } $action = ''; } } +// Validate transaction if ($action == 'valid') { $result = $object->transformTransaction(0,$piece_num); if ($result < 0) { @@ -253,14 +301,17 @@ if ($action == 'valid') { } } + /* * View */ -llxHeader(); + $html = new Form($db); $formaccounting = new FormAccounting($db); $accountjournal = new AccountingJournal($db); +llxHeader('', $langs->trans("CreateMvts")); + // Confirmation to delete the command if ($action == 'delete') { $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); @@ -300,7 +351,7 @@ if ($action == 'create') { print ''; print '' . $langs->trans("Codejournal") . ''; - print '' . $formaccounting->select_journal(GETPOST('code_journal'),'code_journal',0,0,array(),1,1) . ''; + print '' . $formaccounting->select_journal(GETPOST('code_journal'),'code_journal',0,1,array(),1,1) . ''; print ''; print ''; @@ -328,29 +379,45 @@ if ($action == 'create') { if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } + if (! empty($book->piece_num)) { - print load_fiche_titre($langs->trans("UpdateMvts"), '' . $langs->trans('BackToList') . ''); + $backlink = '' . $langs->trans('BackToList') . ''; - dol_fiche_head(); + print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); + $head=array(); + $h=0; + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$book->piece_num.($mode?'&mode='.$mode:''); + $head[$h][1] = $langs->trans("Transaction"); + $head[$h][2] = 'transaction'; + $h++; + + dol_fiche_head($head, 'transaction', '', -1); + + + //dol_banner_tab($book, '', $backlink); + + + print '
'; print '
'; + print '
'; - print ''; + print '
'; // account movement - print ''; + print ''; print ''; print ''; print ''; // date - print ''; print ''; //journal - print ''; print ''; //docref - print ''; print ''; - //doctype - print ''; - print ''; - print ''; - print ''; + print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
'; + print '
'; print ''; if ($action != 'editdate') - print 'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).''; + print ''; print '
'; print $langs->trans('Docdate'); print 'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'
'; print '
'; if ($action == 'editdate') { @@ -361,18 +428,18 @@ if ($action == 'create') { $form->select_date($book->doc_date ? $book->doc_date : - 1, 'doc_date', '', '', '', "setdate"); print ''; print ''; - } else { - print $book->doc_date ? dol_print_date($book->doc_date, 'daytext') : ' '; + } else { + print $book->doc_date ? dol_print_date($book->doc_date, 'daytext') : ' '; } print '
'; + print '
'; print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; + print ''; print '
'; print $langs->trans('Codejournal'); print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'
'; print '
'; if ($action == 'editjournal') { @@ -389,12 +456,12 @@ if ($action == 'create') { print '
'; + print '
'; print ''; if ($action != 'editdocref') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; + print ''; print '
'; print $langs->trans('Docref'); print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'
'; print '
'; if ($action == 'editdocref') { @@ -410,21 +477,25 @@ if ($action == 'create') { } print '
' . $langs->trans("Doctype") . '' . $book->doc_type . '
'; print '
'; print '
'; + print '
'; print ''; + // Doc type + print ''; + print ''; + print ''; + print ''; + // Validate - print ''; + /* + print ''; print ''; print ''; print ''; + */ + // check data - print ''; - print ''; /* + print ''; + print ''; if ($book->doc_type == 'customer_invoice') { $sqlmid = 'SELECT rowid as ref'; @@ -457,14 +530,19 @@ if ($action == 'create') { } else dol_print_error($db); } - */ print ''; + print ''; + */ print "
' . $langs->trans("Doctype") . '' . $book->doc_type . '
' . $langs->trans("Status") . ''; if (empty($book->validated)) { @@ -438,10 +509,12 @@ if ($action == 'create') { } print '
' . $langs->trans("Control") . '
' . $langs->trans("Control") . '' . $ref .'
\n"; - print '
'; + print '
'; + print ''; + print '
'; + print '
'; + $result = $book->fetchAllPerMvt($piece_num, $mode); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -490,11 +568,11 @@ if ($action == 'create') { print ''; print_liste_field_titre($langs->trans("AccountAccountingShort")); - print_liste_field_titre($langs->trans("Subledger_account")); + print_liste_field_titre($langs->trans("SubledgerAccount")); print_liste_field_titre($langs->trans("Labelcompte")); - print_liste_field_titre($langs->trans("Labeloperation")); - print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="center"'); - print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="center"'); + print_liste_field_titre($langs->trans("Label")); + print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); + print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"'); print "\n"; @@ -506,15 +584,24 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; - print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($line->numero_compte, 'account_number', 1, array (), 1, 1, ''); print ''; print ''; - print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); + // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not + // use setup of keypress to select thirdparty and this hang browser on large database. + if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + { + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); + } + else + { + print ''; + } print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '' . "\n"; print ''; @@ -528,10 +615,14 @@ if ($action == 'create') { print '' . price($line->credit) . ''; print ''; - print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; + print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; print img_edit(); - print ' '; - print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; + print '  '; + + $actiontodelete='detele'; + if ($mode == '_tmp') $actiontodelete='confirm_delete'; + + print ''; print img_delete(); print ''; @@ -548,22 +639,46 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; - print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($account_number, 'account_number', 1, array (), 1, 1, ''); print ''; print ''; - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); + // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not + // use setup of keypress to select thirdparty and this hang browser on large database. + if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + { + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); + } + else + { + print ''; + } print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; } print ''; - if ($mode=='_tmp' && $total_debit == $total_credit && $action=='') { - print '
'; - print ''.$langs->trans("ValidTransaction").''; + + + if ($mode=='_tmp' && $action=='') + { + print '
'; + print '
'; + if ($total_debit == $total_credit) + { + print ''.$langs->trans("ValidTransaction").''; + } + else + { + print ''; + } + + print '   '; + print ''.$langs->trans("Cancel").''; + print "
"; } print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 6f994eb1110..93968644a8f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2016 Laurent Destailleur +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2016-2017 Laurent Destailleur * * 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 @@ -16,7 +16,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -112,7 +111,7 @@ if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_mvt_num = ''; $search_doc_type = ''; @@ -377,33 +376,51 @@ print ''; print ''; print ''; print '
'; -print $langs->trans('From') . ': '; +print $langs->trans('From') . ' '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print '
'; print '
'; -print $langs->trans('to') . ': '; +print $langs->trans('to') . ' '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print '
'; print ''; print ''; print ''; print '
'; -print $langs->trans('From'); +print $langs->trans('From').' '; print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; -print $langs->trans('to'); +print $langs->trans('to').' '; print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print '
'; print ''; print ''; print '
'; -print $langs->trans('From'); -print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); +print $langs->trans('From').' '; +// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not +// use setup of keypress to select thirdparty and this hang browser on large database. +if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) +{ + print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); +} +else +{ + print ''; +} print '
'; print '
'; -print $langs->trans('to'); -print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); +print $langs->trans('to').' '; +// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not +// use setup of keypress to select thirdparty and this hang browser on large database. +if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) +{ + print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); +} +else +{ + print ''; +} print '
'; print ''; print ''; @@ -437,7 +454,10 @@ print "\n"; $total_debit = 0; $total_credit = 0; -foreach ($object->lines as $line ) { +$i=0; +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; $total_debit += $line->debit; $total_credit += $line->credit; @@ -463,6 +483,8 @@ foreach ($object->lines as $line ) { print '' . img_delete() . ''; print ''; print "\n"; + + $i++; } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index a1398df6fb2..1f43964bd0a 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -92,7 +92,7 @@ if (! empty($search_doc_date)) { } -if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (! GETPOST('button_removefilter_x','alpha') && ! GETPOST('button_removefilter.x','alpha') && ! GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { if (! empty($search_accountancy_code_start)) { $filter['t.numero_compte'] = $search_accountancy_code_start; @@ -121,7 +121,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_doc_date = ''; $search_accountancy_code = ''; @@ -160,7 +160,6 @@ $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By" llxHeader('', $title_page); // List - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); @@ -173,7 +172,9 @@ $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $f if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -$nbtotalofrecords = $result; + +$num=count($object->lines); + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); @@ -204,7 +205,7 @@ if ($action == 'delbookkeepingyear') { -print '
'; +print ''; $viewflat = ' ' . $langs->trans("ViewFlatList") . ''; @@ -236,7 +237,7 @@ print ''; print ' '; print ' '; -print ''; +print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -250,7 +251,7 @@ print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_re print_liste_field_titre($langs->trans("Label")); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; @@ -263,7 +264,10 @@ $sous_total_debit = 0; $sous_total_credit = 0; $displayed_account_number = null; // Start with undefined to be able to distinguish with empty -foreach ( $object->lines as $line ) { +$i=0; +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; $total_debit += $line->debit; $total_credit += $line->credit; @@ -323,10 +327,11 @@ foreach ( $object->lines as $line ) { print ''; print "\n"; - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + $i++; } // Affiche un Sous-Total du dernier compte comptable affiché diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index becb700761a..d10f621d9e3 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -86,7 +86,7 @@ $offset = $limit * $page; * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_doc_type = ""; $search_doc_date = ""; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php new file mode 100644 index 00000000000..41e1570ae83 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php @@ -0,0 +1,331 @@ + + * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2013 Olivier Geffroy + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accounting/bookkeeping/thirdparty_lettrage.php + * \ingroup Advanced accountancy + * \brief Onglet de gestion de parametrages des ventilations + */ + +require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + +$action=GETPOST('action','aZ09'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if ($sortorder == "") $sortorder = "ASC"; +if ($sortfield == "") $sortfield = "bk.rowid"; + +$search_year = GETPOST ( "search_year" ); + +// Security check +$socid = GETPOST("socid",'int'); +// if ($user->societe_id) $socid=$user->societe_id; + +$object = new Societe($db); +$object->id = $socid; +$object->fetch($socid); + + +$form = new Form($db); +$BookKeeping = new lettering($db); +$formaccounting = new FormAccounting($db); + + +/* + * Action + */ + +if ($action == 'lettering') { + + $result = $BookKeeping->updatelettrage($_POST['ids']); + +// var_dump($result); + if( $result < 0 ){ + setEventMessages('', $BookKeeping->errors, 'errors' ); + $error++; + + } +} + +if ($action == 'autolettrage') { + + $result = $BookKeeping->LettrageTiers($socid); + + if( $result < 0 ){ + setEventMessages('', $BookKeeping->errors, 'errors' ); + $error++; + + } + +} + + +llxHeader ( '', 'Compta - Grand Livre' ); + + + /* + * Affichage onglets + */ + $head = societe_prepare_head($object); + + dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); + + dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company'); + + + + + print ''; + print ''; + + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } + + + print ''; + print ''; + print ''; + + $langs->load('compta'); + print ''; + print ''; + print ''; + + + // Address + print ''; + + // Zip / Town + print ''; + print ''; + + // Country + print ''; + + print '
'.$langs->trans("ThirdPartyName").''; + $object->next_prev_filter="te.fournisseur = 1"; + print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); + print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans("CustomerCode"). ''; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print '
'; + print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer); + print ''; + print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer); + print '
'.$langs->trans("Address").''; + dol_print_address($object->address,'gmap','thirdparty',$object->id); + print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'
'.$langs->trans("Country").''; + //$img=picto_from_langcode($object->country_code); + $img=''; + if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); + else print ($img?$img.' ':'').$object->country; + print '
'; + + + + + + $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; + $sql .= " WHERE (bk.code_tiers = '" . $object->code_compta . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER. "' )" ; + + + + if (dol_strlen ( $search_year )) { + $sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )"; + } + + + $sql .= " ORDER BY bk.lettering_code ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset ); + +// echo $sql; +// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG ); + $resql = $db->query ( $sql ); + if ($resql) { + $num = $db->num_rows ( $resql ); + $i = 0; + + + print ''; + print ''; + print ''; + + print ""; + print ''; + print ''; + print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" ); + print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" ); + print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" ); +// print_liste_field_titre ( $langs->trans ( "Numerocompte" ), "liste.php", "bk.numero_compte" ); +// print_liste_field_titre ( $langs->trans ( "Code_tiers" ), "liste.php", "bk.code_tiers" ); + print_liste_field_titre ( $langs->trans ( "Labelcompte" ), "liste.php", "bk_label_compte" ); + print_liste_field_titre ( $langs->trans ( "Debit" ), "liste.php", "bk.debit" ); + print_liste_field_titre ( $langs->trans ( "Credit" ), "liste.php", "bk.credit" ); +// print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" ); +// print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" ); + print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" ); + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +// print ''; +// print ''; + print ''; + print ''; + print ''; +// print ''; +// print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = false; + + $debit = 0; + $credit = 0; + $solde = 0; + $tmp = ''; + while ( $i < $num ) { + $obj = $db->fetch_object ( $resql ); + + if($tmp !=$obj->lettering_code || empty($tmp) ) + $tmp =$obj->lettering_code; + + if($tmp !=$obj->lettering_code || empty($obj->lettering_code)) + $var = ! $var; + + + $debit+= $obj->debit; + $credit+= $obj->credit; + + $solde+=($obj->credit-$obj->debit); + print ""; + + print ''; + if(empty($obj->lettering_code)){ + print '' . "\n"; + } + else + print '' . "\n"; + + + + print ''; + print ''; +// print ''; +// print ''; + print ''; + print ''; + print ''; +// print ''; +// print ''; + print ''; + print ''; + + if(empty($obj->lettering_code)){ + print ''; + } + else + print ''; + + print "\n"; + + $i ++; + + + + + } + + print ''; + + print '' . "\n"; + print ''; + // print ''; + // print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ""; + print '' . "\n"; + // print ''; + // print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print "
     '; + print ''; + print '   
' . $obj->rowid . ''; + print img_edit (); + print ' ' . $obj->doc_type . ''.$obj->doc_type . '' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '' . $obj->doc_ref . '' . $obj->numero_compte . '' . $obj->code_tiers . '' . $obj->label_compte . '' . $obj->debit . '' . $obj->credit . '' . $obj->montant . '' . $obj->sens . '' . $obj->code_journal . '' . round($solde, 2) . '' . $obj->lettering_code . '
Mouvement totaux' . $debit . '' . $credit . ' 
Solde Comptable' . ($credit-$debit) . ' 
"; + + print ''; + print 'auto lettering'; + print ""; + $db->free($resql); + } else { + dol_print_error($db); + } + + +// End of page +llxFooter(); +$db->close(); + diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php new file mode 100644 index 00000000000..17f0194628d --- /dev/null +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php @@ -0,0 +1,335 @@ + + * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2013 Olivier Geffroy + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file accounting/bookkeeping/thirdparty_lettrage.php + * \ingroup Advanced accountancy + * \brief Tab to setup lettering + */ + +// Dolibarr environment +require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + + +$action=GETPOST('action','aZ09'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if ($sortorder == "") $sortorder = "ASC"; +if ($sortfield == "") $sortfield = "bk.rowid"; + +$search_year = GETPOST ( "search_year" ); + + +// Security check +$socid = GETPOST("socid",'int'); +// if ($user->societe_id) $socid=$user->societe_id; + +$object = new Societe($db); +$object->id = $socid; +$object->fetch($socid); + +$form = new Form($db); +$BookKeeping = new lettering($db); +$formaccounting = new FormAccounting($db); + + +/* + * Action + */ +if ($action == 'lettering') { + + $result = $BookKeeping->updatelettrage($_POST['ids']); + +// var_dump($result); + if( $result < 0 ){ + setEventMessages('', $BookKeeping->errors, 'errors' ); + $error++; + + } +} + +if ($action == 'autolettrage') { + + $result = $BookKeeping->LettrageTiers($socid); + + if( $result < 0 ){ + setEventMessages('', $BookKeeping->errors, 'errors' ); + $error++; + + } + +} + + +llxHeader ( '', 'Compta - Grand Livre' ); + + + /* + * Affichage onglets + */ + $head = societe_prepare_head($object); + + dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); + + dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company'); + + + + + print ''; + print ''; + + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } + + + print ''; + print ''; + print ''; + + $langs->load('compta'); + print ''; + print ''; + print ''; + + + // Address + print ''; + + // Zip / Town + print ''; + print ''; + + // Country + print ''; + + print '
'.$langs->trans("ThirdPartyName").''; + $object->next_prev_filter="te.fournisseur = 1"; + print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); + print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans("SupplierCode"). ''; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print '
'; + print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer); + print ''; + print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer); + print '
'.$langs->trans("Address").''; + dol_print_address($object->address,'gmap','thirdparty',$object->id); + print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'
'.$langs->trans("Country").''; + //$img=picto_from_langcode($object->country_code); + $img=''; + if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); + else print ($img?$img.' ':'').$object->country; + print '
'; + +// print_r($soc); +// exit; +// [code_compta] => 411DOUA +// [code_compta_fournisseur] => 401SUPPCODE + +/* + * Mode Liste + * + * + * + */ + + $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; + $sql .= " WHERE (bk.code_tiers = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER. "' )" ; + + + + if (dol_strlen ( $search_year )) { + $sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )"; + } + + + $sql .= " ORDER BY bk.lettering ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset ); + +// echo $sql; +// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG ); + $resql = $db->query ( $sql ); + if ($resql) { + $num = $db->num_rows ( $resql ); + $i = 0; + + + print '
'; + print ''; + print ''; + + print ""; + print ''; + print ''; + print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" ); + print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" ); + print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" ); +// print_liste_field_titre ( $langs->trans ( "Numerocompte" ), "liste.php", "bk.numero_compte" ); +// print_liste_field_titre ( $langs->trans ( "Code_tiers" ), "liste.php", "bk.code_tiers" ); + print_liste_field_titre ( $langs->trans ( "Labelcompte" ), "liste.php", "bk_label_compte" ); + print_liste_field_titre ( $langs->trans ( "Debit" ), "liste.php", "bk.debit" ); + print_liste_field_titre ( $langs->trans ( "Credit" ), "liste.php", "bk.credit" ); + print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" ); + print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" ); + print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" ); + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +// print ''; +// print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = false; + + $debit = 0; + $credit = 0; + $solde = 0; + $tmp = ''; + while ( $i < $num ) { + $obj = $db->fetch_object ( $resql ); + + if($tmp !=$obj->lettering || empty($tmp) ) + $tmp =$obj->lettering; + + if($tmp !=$obj->lettering || empty($obj->lettering)) + $var = ! $var; + + + $debit+= $obj->debit; + $credit+= $obj->credit; + + $solde+=($obj->credit-$obj->debit); + print ""; + + print ''; + if(empty($obj->lettering)){ + print '' . "\n"; + } + else + print '' . "\n"; + + + + print ''; + print ''; +// print ''; +// print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if(empty($obj->lettering)){ + print ''; + } + else + print ''; + + print "\n"; + + $i ++; + } + + print ''; + + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ""; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print "
     '; + print ''; + print '   
' . $obj->rowid . ''; + print img_edit (); + print ' ' . $obj->doc_type . ''.$obj->doc_type . '' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '' . $obj->doc_ref . '' . $obj->numero_compte . '' . $obj->code_tiers . '' . $obj->label_compte . '' . $obj->debit . '' . $obj->credit . '' . $obj->montant . '' . $obj->sens . '' . $obj->code_journal . '' . round($solde, 2) . '' . $obj->lettering . '
Mouvement totaux' . $debit . '' . $credit . ' 
Solde Comptable' . ($credit-$debit) . ' 
"; + + print ''; + print 'auto lettering'; + print ""; + $db->free ( $resql ); + } else { + dol_print_error ( $db ); + } + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 66f72ea9bf6..a7bab16b30d 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -539,8 +539,9 @@ class AccountancyCategory /** * get cpts of category * - * @param int $cat_id Category id - * @return array Result in table + * @param int $cat_id Id accounting account category + * + * @return array Result in table */ public function getCptsCat($cat_id) { global $mysoc; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 51ef317e917..1431df9f8a2 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -176,7 +176,7 @@ class BookKeeping extends CommonObject if (empty($this->credit)) $this->credit = 0; // Check parameters - if (empty($this->numero_compte) || $this->numero_compte == '-1') + if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') { $langs->load("errors"); if (in_array($this->doc_type, array('bank', 'expense_report'))) @@ -430,6 +430,9 @@ class BookKeeping extends CommonObject if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; + $this->debit = price2num($this->debit, 'MT'); + $this->credit = price2num($this->credit, 'MT'); + $now = dol_now(); if (empty($this->date_create)) { $this->date_create = $now; @@ -609,6 +612,7 @@ class BookKeeping extends CommonObject } } + /** * Load object in memory from the database * @@ -799,7 +803,7 @@ class BookKeeping extends CommonObject if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } - $this->lines = array (); + $this->lines = array(); $resql = $this->db->query($sql); if ($resql) { @@ -998,6 +1002,9 @@ class BookKeeping extends CommonObject $this->piece_num = trim($this->piece_num); } + $this->debit = price2num($this->debit, 'MT'); + $this->credit = price2num($this->credit, 'MT'); + // Check parameters // Put here code to add a control on parameters values @@ -1068,9 +1075,10 @@ class BookKeeping extends CommonObject public function updateByMvt($piece_num='', $field='', $value='', $mode='') { $this->db->begin(); $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; - $sql .= ' SET ab.' . $field . '=' . $value; + $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'"); $sql .= ' WHERE ab.piece_num=' . $piece_num ; $resql = $this->db->query($sql); + if (! $resql) { $error ++; $this->errors[] = 'Error ' . $this->db->lasterror(); @@ -1093,7 +1101,6 @@ class BookKeeping extends CommonObject * @param User $user User that deletes * @param bool $notrigger false=launch triggers after, true=disable triggers * @param string $mode Mode - * * @return int <0 if KO, >0 if OK */ public function delete(User $user, $notrigger = false, $mode='') { @@ -1576,6 +1583,7 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } + /* $sql = "DELETE FROM "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; @@ -1584,6 +1592,7 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY account_number ASC"; + */ } /** @@ -1761,4 +1770,4 @@ class BookKeepingLine public $code_journal; public $journal_label; public $piece_num; -} \ No newline at end of file +} diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php new file mode 100644 index 00000000000..97721669f91 --- /dev/null +++ b/htdocs/accountancy/class/lettering.class.php @@ -0,0 +1,330 @@ + + * Copyright (C) 2013 Olivier Geffroy + * Copyright (C) 2013 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 accountancy/class/bookkeeping.class.php + * \ingroup Advanced accountancy + * \brief File of class for lettering + */ + +include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php"; +include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; + + +/** + * Class lettering + */ +class lettering extends BookKeeping +{ + /** + * lettrageTiers + * + * @param int $socid Thirdparty id + * @return void + */ + public function lettrageTiers($socid) { + + $db = $this->db; + + $object = new Societe($this->db); + $object->id = $socid; + $object->fetch($socid); + + + if( $object->code_compta == '411CUSTCODE') + $object->code_compta = ''; + + if( $object->code_compta_fournisseur == '401SUPPCODE') + $object->code_compta_fournisseur = ''; + + + + $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.lettering_code, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; + $sql .= " WHERE code_journal = 'BQ' AND ( "; + if(!empty($object->code_compta) ) + $sql .= " bk.code_tiers = '" . $object->code_compta . "' "; + if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) ) + $sql .= " OR "; + if(!empty($object->code_compta_fournisseur) ) + $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; + + $sql .= " ) AND ( bk.date_lettering ='' OR bk.date_lettering IS NULL ) AND bk.lettering_code !='' "; + + $sql .= " GROUP BY bk.lettering_code "; + + + $resql = $db->query ( $sql ); + if ($resql) { + $num = $db->num_rows ( $resql ); + $i = 0; + + while ( $i < $num ) { + $obj = $db->fetch_object ( $resql ); + $i++; + + $sql = "SELECT bk.rowid "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; + $sql .= " WHERE bk.lettering_code = '".$obj->lettering_code."' "; + $sql .= " AND ( "; + if(!empty($object->code_compta) ) + $sql .= " bk.code_tiers = '" . $object->code_compta . "' "; + if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) ) + $sql .= " OR "; + if(!empty($object->code_compta_fournisseur) ) + $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; + $sql .= " ) "; +// echo $sql; + $resql2 = $db->query ( $sql ); + if ($resql2) { + $num2 = $db->num_rows ( $resql2 ); + $i2 = 0; + $ids = array(); + while ( $i2 < $num2 ) { + $obj2 = $db->fetch_object ( $resql2 ); + $i2++; + $ids[] = $obj2->rowid; + } + + + if(count($ids) > 1 ){ + $result = $this->updatelettrage($ids); + + // var_dump($result); +// if( $result < 0 ){ +// setEventMessages('', $BookKeeping->errors, 'errors' ); +// $error++; +// +// } + } + } + } + } + + + /** + Prise en charge des lettering complexe avec prelevment , virement + */ + $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type "; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; + $sql .= " WHERE code_journal = 'BQ' AND ( "; + if(!empty($object->code_compta) ) + $sql .= " bk.code_tiers = '" . $object->code_compta . "' "; + if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) ) + $sql .= " OR "; + if(!empty($object->code_compta_fournisseur) ) + $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; + + $sql .= " ) AND date_lettering ='' "; + $sql .= " GROUP BY bk.lettering_code "; + +// echo $sql; +// + $resql = $db->query ( $sql ); + if ($resql) { + $num = $db->num_rows ( $resql ); + $i = 0; + + while ( $i < $num ) { + $obj = $db->fetch_object ( $resql ); + $ids = array(); + $i++; + + // print_r($obj); + + + + if($obj->type =='payment_supplier' ) { + $ids[] = $obj->rowid; + + $sql= 'SELECT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank '; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sql.= " INNER JOIN " .MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = facf.ref) "; + // $sqlmid.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid=facf.fk_soc"; + // $sqlmid.= " INNER JOIN " . MAIN_DB_PREFIX . "c_paiement as payc ON payc.id=payf.fk_paiement"; + $sql .= " WHERE 1 "; + $sql .= " AND fk_paiementfourn = '".$obj->url_id."' "; + // $sql .= " AND (bk.numero_compte = '" . $object->code_compta . "' OR bk.numero_compte = '" . $object->code_compta_fournisseur . "') "; + $sql .= " AND ( "; + if(!empty($object->code_compta) ) + $sql .= " bk.code_tiers = '" . $object->code_compta . "' "; + if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) ) + $sql .= " OR "; + if(!empty($object->code_compta_fournisseur) ) + $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; + $sql .= " ) "; + // echo $sql; + // exit; + } + elseif($obj->type =='payment' ){ + $ids[] = $obj->rowid; + + $sql= 'SELECT bk.rowid,fac.facnumber , pay.fk_bank '; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture fac "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sql.= " INNER JOIN " .MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid) "; + $sql .= " WHERE 1 "; + $sql .= " AND payfac.fk_paiement = '".$obj->url_id."' "; + $sql .= " AND ( "; + if(!empty($object->code_compta) ) + $sql .= " bk.code_tiers = '" . $object->code_compta . "' "; + if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) ) + $sql .= " OR "; + if(!empty($object->code_compta_fournisseur) ) + $sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' "; + $sql .= " ) "; + + // echo $sql; + } + + + + $resql2 = $db->query ( $sql ); + if ($resql2) { + $num2 = $db->num_rows ( $resql2 ); + $i2 = 0; + + while ( $i2 < $num2 ) { + $obj2 = $db->fetch_object ( $resql2 ); + $i2++; + $ids[] = $obj2->rowid; + } + + // print_r($ids); + // exit; + if(count($ids) > 1 ){ + $result = $this->updatelettrage($ids); + + // var_dump($result); +// if( $result < 0 ){ +// setEventMessages('', $BookKeeping->errors, 'errors' ); +// $error++; +// +// } + } + + // exit; + } + } + } + + + } + + + public function updatelettrage($ids, $notrigger=false){ + $error = 0; + + $sql = "SELECT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; + $sql .= " lettering_code != '' GROUP BY lettering_code ORDER BY lettering_code DESC limit 1; "; +// echo $sql; + $result = $this->db->query ( $sql ); + if ($result) { + $obj = $this->db->fetch_object ( $result ); + $lettre = (empty($obj->lettering_code)? 'AAA' : $obj->lettering_code ); + if(!empty($obj->lettering_code)) + $lettre++; + } + else{ + $this->errors[] = 'Error'.$this->db->lasterror();; + $error++; + } +// var_dump(__line__, $error); + + $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; + $sql .= " rowid IN (".implode(',', $ids).") "; + $result = $this->db->query ( $sql ); + if ($result) { + $obj = $this->db->fetch_object ( $result ); +// print_r($obj); + if( !(round(abs($obj->deb),2) === round(abs($obj->cred),2)) ){ +// echo $sql; +// print_r($obj); + $this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2); + $error++; + } + } + else{ + $this->errors[] = 'Erreur sql'.$this->db->lasterror();; + $error++; + } + + + // Update request + + $now = dol_now(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; + $sql.= " lettering_code='".$lettre."'"; + $sql.= " , date_lettering = " .$now ; // todo correct date it's false + $sql.= " WHERE rowid IN (".implode(',', $ids).") "; +// echo $sql ; +// +// var_dump(__line__, $error); +// print_r($this->errors); +// exit; + $this->db->begin(); + + dol_syslog(get_class($this)."::update sql=".$sql, 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 calls 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 + } + } +// var_dump(__line__, $error); + // Commit or rollback + if ($error) + { +// foreach($this->errors as $errmsg) +// { +// dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); +// $this->error.=($this->error?', '.$errmsg:$errmsg); +// } + $this->db->rollback(); +// echo $this->error; +// var_dump(__line__, $error); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + +} + diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index a10cd24adc4..d307169dfcc 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/accountancy/customer/card.php - * \ingroup Accountancy - * \brief Card customer ventilation + * \file htdocs/accountancy/customer/card.php + * \ingroup Advanced accountancy + * \brief Card customer ventilation */ require '../../main.inc.php'; @@ -47,11 +47,11 @@ if ($user->societe_id > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (! GETPOST('cancel', 'alpha')) { if ($codeventil < 0) $codeventil = 0; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; - + $resql = $db->query($sql); if (! $resql) { setEventMessages($db->lasterror(), null, 'errors'); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f1bea3bd4a1..b46739ca1c2 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -21,9 +21,9 @@ */ /** - * \file htdocs/accountancy/customer/index.php + * \file htdocs/accountancy/customer/index.php * \ingroup Advanced accountancy - * \brief Home customer journalization page + * \brief Home customer journalization page */ require '../../main.inc.php'; @@ -363,7 +363,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. } print "\n"; - + if (! empty($conf->margin->enabled)) { print "
\n"; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index d6d006c6556..d48f81259df 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -85,7 +85,7 @@ $formaccounting = new FormAccounting($db); */ // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_lineid = ''; $search_ref = ''; @@ -153,7 +153,7 @@ print ''; - $return .= ''; - - if ($showempty) - $return .= ''; - - // Find if keys is in selected array value - if (is_array($selected_array) && count($selected_array)>0) { - $intersect_array = array_intersect_key($options_array, array_flip($selected_array)); - } else { - $intersect_array=array(); - } - - if (count($options_array) > 0) { - foreach ($options_array as $keyoption => $valoption) { - // If key is in intersect table then it have to e selected - $selected = ''; - if (count ( $intersect_array ) > 0) { - if (array_key_exists ( $keyoption, $intersect_array )) { - $selected = ' selected="selected"'; - } - } - $return .= '' . $valoption . ''; - } - } - - $return .= ''; - + $form=new Form($this->db); + $return = $form->multiselectarray($htmlname, $options_array, $selected_array,0,0,'',0,295); return $return; } @@ -448,7 +407,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray( $htmlname, $options_array, $selected_array ); } /** diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4668c6a56a4..b1d8aa03022 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1250,6 +1250,8 @@ $now = dol_now(); // Add new proposal if ($action == 'create') { + $currency_code = $conf->currency; + print load_fiche_titre($langs->trans("NewProp")); $soc = new Societe($db); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a59fefc7a89..f007cbdbf81 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -618,9 +618,10 @@ class Propal extends CommonObject * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency + * @param int $notrigger disable line update trigger * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0) + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0, $notrigger=0) { global $mysoc; @@ -745,7 +746,7 @@ class Propal extends CommonObject $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - $result=$this->line->update(); + $result=$this->line->update($notrigger); if ($result > 0) { // Reorder if child line @@ -909,23 +910,23 @@ class Propal extends CommonObject $sql.= $this->socid; $sql.= ", 0"; $sql.= ", ".$this->remise; - $sql.= ", ".($this->remise_percent?$this->db->escape($this->remise_percent):'null'); - $sql.= ", ".($this->remise_absolue?$this->db->escape($this->remise_absolue):'null'); + $sql.= ", ".($this->remise_percent?$this->db->escape($this->remise_percent):'NULL'); + $sql.= ", ".($this->remise_absolue?$this->db->escape($this->remise_absolue):'NULL'); $sql.= ", 0"; $sql.= ", 0"; $sql.= ", '".$this->db->idate($this->date)."'"; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '(PROV)'"; - $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"NULL"); $sql.= ", '".$this->db->escape($this->note_private)."'"; $sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null"); - $sql.= ", ".$this->cond_reglement_id; - $sql.= ", ".$this->mode_reglement_id; + $sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"NULL"); + $sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); + $sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", '".$this->db->escape($this->ref_client)."'"; - $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); + $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"NULL"); $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); $sql.= ", ".$this->availability_id; $sql.= ", ".$this->demand_reason_id; @@ -2361,7 +2362,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED; - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); @@ -3501,7 +3502,7 @@ class Propal extends CommonObject /** * Class to manage commercial proposal lines */ -class PropaleLigne extends CommonObjectLine +class PropaleLigne extends CommonObjectLine { public $element='propaldet'; public $table_element='propaldet'; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e9626a638b8..6062f6033dc 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -178,7 +178,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_categ=''; $search_user=''; @@ -355,6 +355,7 @@ if ($resql) $soc = new Societe($db); $soc->fetch($socid); $title = $langs->trans('ListOfProposals') . ' - '.$soc->name; + if (empty($search_societe)) $search_societe = $soc->name; } else { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 13fe07f78df..a4888b44861 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2039,7 +2039,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print $object->date ? dol_print_date($object->date, 'day') : ' '; - if ($object->hasDelay() && empty($object->date_livraison)) { + if ($object->hasDelay() && ! empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0910fedcb9d..f9ebf8a4cde 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -65,9 +65,8 @@ class Commande extends CommonOrder public $contactid; /** - * Status of the order. Check the following constants: + * Status of the order * @var int - * @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED */ public $statut; /** @@ -1359,10 +1358,10 @@ class Commande extends CommonOrder $this->line->vat_src_code=$vat_src_code; $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=$txlocaltax1; - $this->line->localtax2_tx=$txlocaltax2; - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax1_tx=$localtaxes_type[1]; + $this->line->localtax2_tx=$localtaxes_type[3]; + $this->line->localtax1_type=$localtaxes_type[0]; + $this->line->localtax2_type=$localtaxes_type[2]; $this->line->fk_product=$fk_product; $this->line->product_type=$product_type; $this->line->fk_remise_except=$fk_remise_except; @@ -1411,7 +1410,7 @@ class Commande extends CommonOrder if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); // Mise a jour informations denormalisees au niveau de la commande meme - $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -2778,9 +2777,10 @@ class Commande extends CommonOrder * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Amount in currency + * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0, $notrigger=0) { global $conf, $mysoc, $langs, $user; @@ -2935,7 +2935,7 @@ class Commande extends CommonOrder $this->line->array_options=$array_options; } - $result=$this->line->update($user); + $result=$this->line->update($user, $notrigger); if ($result > 0) { // Reorder if child line @@ -3243,7 +3243,8 @@ class Commande extends CommonOrder $response->nbtodo++; $generic_commande->statut = $obj->fk_statut; - $generic_commande->date_livraison = $obj->delivery_date; + $generic_commande->date_commande = $this->db->jdate($obj->date_commande); + $generic_commande->date_livraison = $this->db->jdate($obj->delivery_date); if ($generic_commande->hasDelay()) { $response->nbtodolate++; @@ -3370,14 +3371,14 @@ class Commande extends CommonOrder * Return clicable link of object (with eventually picto) * * @param int $withpicto Add picto into link - * @param int $option Where point the link (0=> main card, 1,2 => shipment) + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) * @param int $max Max length to show * @param int $short ??? * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto=0, $option=0, $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1) + function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1) { global $conf, $langs, $user; @@ -3385,7 +3386,7 @@ class Commande extends CommonOrder $result=''; - if (! empty($conf->expedition->enabled) && ($option == 1 || $option == 2)) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; + if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id; if ($option !== 'nolink') diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8ce3ba7cd04..565f39e62a2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -162,7 +162,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_categ=''; $search_user=''; @@ -191,6 +191,11 @@ if (empty($reshook)) $toselect=''; $search_array_options=array(); } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } // Mass actions $objectclass='Commande'; @@ -371,7 +376,7 @@ if (empty($reshook)) } - $cmd->classifyBilled($user); + //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; @@ -573,6 +578,7 @@ if ($resql) $soc = new Societe($db); $soc->fetch($socid); $title = $langs->trans('ListOfOrders') . ' - '.$soc->name; + if (empty($search_company)) $search_company = $soc->name; } else { @@ -754,7 +760,7 @@ if ($resql) //var_dump($_REQUEST); print ''; - print '
'; + print '
'; print ''; print ''; print ''; print ''; print '
'; print $langs->trans('DateInvoice'); @@ -776,7 +782,15 @@ if ($resql) print $langs->trans('ValidateInvoices'); print ''; - print $form->selectyesno('valdate_invoices', 1, 1); + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + { + print $form->selectyesno('valdate_invoices', 0, 1, 1); + print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; + } + else + { + print $form->selectyesno('valdate_invoices', 0, 1); + } print '
'; @@ -838,7 +852,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -976,6 +990,7 @@ if ($resql) Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4); @@ -1033,7 +1048,7 @@ if ($resql) if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'],$_SERVER["PHP_SELF"],"c.fk_statut","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'],$_SERVER["PHP_SELF"],'c.facture','',$param,'align="center"',$sortfield,$sortorder,''); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print ''."\n"; $total=0; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 2bc2242abc4..a19ccbb6b7c 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; @@ -46,17 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("banks"); -$langs->load("bills"); -$langs->load("categories"); -$langs->load("companies"); -$langs->load("margins"); -$langs->load("salaries"); -$langs->load("loan"); -$langs->load("donations"); -$langs->load("trips"); -$langs->load("members"); -$langs->load("compta"); +$langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy")); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); @@ -84,6 +75,7 @@ $debit=GETPOST("debit",'alpha'); $credit=GETPOST("credit",'alpha'); $type=GETPOST("type",'alpha'); $account=GETPOST("account",'int'); +$accountancy_code=GETPOST('accountancy_code', 'alpha'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); @@ -178,7 +170,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_dt_start=''; $search_dt_end=''; @@ -276,11 +268,11 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $amount = - price2num($_POST["adddebit"]); } - $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $label=$_POST["label"]; - $cat1=$_POST["cat1"]; + $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); + $operation = GETPOST("operation",'alpha'); + $num_chq = GETPOST("num_chq",'alpha'); + $label = GETPOST("label",'alpha'); + $cat1 = GETPOST("cat1",'alpha'); if (! $dateop) { $error++; @@ -290,15 +282,24 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); } + if (! $label) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Label")), null, 'errors'); + } if (! $amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); } + /*if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + }*/ if (! $error) { $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user); + $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -331,6 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m $form = new Form($db); $formother = new FormOther($db); +$formaccounting = new FormAccounting($db); $companystatic=new Societe($db); $bankaccountstatic=new Account($db); @@ -365,6 +367,7 @@ if (!empty($debit)) $param.='&debit='.$debit; if (!empty($credit)) $param.='&credit='.$credit; if (!empty($account)) $param.='&account='.$account; if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); +if ($search_conciliated != '') $param.='&search_conciliated='.urlencode($search_conciliated); if (!empty($bid)) $param.='&bid='.$bid; if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); @@ -408,19 +411,32 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); + /* * Buttons actions */ + if ($action != 'reconcile') { print '
'; if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - if ($user->rights->banque->modifier) { - print ''.$langs->trans("AddBankRecord").''; - } else { - print ''.$langs->trans("AddBankRecord").''; + if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } + } + else // If direct entries is not done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } } } else @@ -431,7 +447,7 @@ if ($id > 0 || ! empty($ref)) if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } @@ -637,6 +653,60 @@ if ($resql) // print '
'; } + // Form to add a transaction with no invoice + if ($user->rights->banque->modifier && $action == 'addline') + { + print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*if (! empty($conf->accounting->enabled)) + { + print ''; + }*/ + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*if (! empty($conf->accounting->enabled)) + { + print ''; + }*/ + print ''; + + print '
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''; + print $langs->trans("AccountAccounting"); + print ' 
'; + $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction'); + print ''; + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); + print ''; + print ''; + print ''; + if ($options) { + print '
'.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); + } + print '
'; + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); + print ''; + print '
'; + print ''; + print '
'; + print '
'; + } /// ajax to adjust value date with plus and less picto print ' diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 43b6dace19c..08631abec79 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -39,7 +39,7 @@ class Account extends CommonObject public $element = 'bank_account'; public $table_element = 'bank_account'; public $picto = 'account'; - + /** * @var int Use id instead of rowid * @deprecated @@ -394,9 +394,10 @@ class Account extends CommonObject * @param User $user User that create * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer + * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') { // Deprecatîon warning if (is_numeric($oper)) { @@ -456,6 +457,7 @@ class Account extends CommonObject $accline->fk_user_author = $user->id; $accline->fk_account = $this->rowid; $accline->fk_type = $oper; + $accline->numero_compte = $accountancycode; if ($num_chq) { $accline->num_chq = $num_chq; @@ -538,7 +540,7 @@ class Account extends CommonObject $now=dol_now(); $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; $sql.= "datec"; $sql.= ", ref"; @@ -619,14 +621,14 @@ class Account extends CommonObject $result=$this->insertExtraFields(); if ($result < 0) $error++; } - + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('BANKACCOUNT_CREATE',$user); if ($result < 0) $error++; // End call triggers - } + } } else { @@ -670,9 +672,9 @@ class Account extends CommonObject global $langs,$conf, $hookmanager; $error=0; - + $this->db->begin(); - + // Clean parameters $this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id); @@ -739,7 +741,7 @@ class Account extends CommonObject if ($result < 0) $error++; } } - + if (! $error && ! $notrigger) { // Call trigger @@ -754,7 +756,7 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); dol_print_error($this->db); } - + if (! $error) { $this->db->commit(); @@ -906,7 +908,7 @@ class Account extends CommonObject $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_update = $this->db->jdate($obj->date_update); - + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -983,15 +985,15 @@ class Account extends CommonObject global $conf; $error=0; - + $this->db->begin(); - + // Delete link between tag and bank account if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; $sql.= " WHERE fk_account = ".$this->id; - + $resql = $this->db->query($sql); if (!$resql) { @@ -999,15 +1001,15 @@ class Account extends CommonObject $this->error = "Error ".$this->db->lasterror(); } } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE rowid = ".$this->rowid; - + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) + if ($result) { // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used @@ -1020,13 +1022,13 @@ class Account extends CommonObject } } } - else + else { $error++; $this->error = "Error ".$this->db->lasterror(); - } + } } - + if (! $error) { $this->db->commit(); @@ -1433,7 +1435,7 @@ class Account extends CommonObject * - DeskCode * * Some countries show less or more bank account properties to the user - * + * * @param int $includeibanbic 1=Return also key for IBAN and BIC * @return array * @see useDetailedBBAN @@ -1554,7 +1556,7 @@ class AccountLine extends CommonObject var $element='bank'; var $table_element='bank'; var $picto = 'generic'; - + var $id; var $ref; var $datec; @@ -1683,8 +1685,9 @@ class AccountLine extends CommonObject $sql .= ", num_chq"; $sql .= ", fk_account"; $sql .= ", fk_type"; - $sql .= ",emetteur,banque"; + $sql .= ", emetteur,banque"; $sql .= ", rappro"; + $sql .= ", numero_compte"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->datec)."'"; $sql .= ", '".$this->db->idate($this->dateo)."'"; @@ -1698,6 +1701,7 @@ class AccountLine extends CommonObject $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); $sql .= ", ".(int) $this->rappro; + $sql .= ", ".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''"); $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); @@ -1842,7 +1846,7 @@ class AccountLine extends CommonObject function update_conciliation(User $user, $cat) { global $conf; - + $this->db->begin(); // Check statement field @@ -1854,7 +1858,7 @@ class AccountLine extends CommonObject return -1; } } - + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; $sql.= " rappro = 1"; $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; @@ -2042,7 +2046,7 @@ class AccountLine extends CommonObject return $result; } - + /** * Return label of status (activity, closed) * @@ -2053,7 +2057,7 @@ class AccountLine extends CommonObject { return $this->LibStatut($this->status,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -2097,6 +2101,6 @@ class AccountLine extends CommonObject if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ } - + } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 939872ce7fd..9812269dcb6 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -325,14 +325,14 @@ class PaymentVarious extends CommonObject $sql.= " VALUES ("; $sql.= "'".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->sens."'"; + $sql.= ", '".$this->db->escape($this->sens)."'"; $sql.= ", ".$this->amount; - $sql.= ", '".$this->type_payment."'"; - $sql.= ", '".$this->num_payment."'"; + $sql.= ", '".$this->db->escape($this->type_payment)."'"; + $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->accountancy_code."'"; - $sql.= ", '".$user->id."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql.= ", ".$user->id; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", NULL"; $sql.= ", ".$conf->entity; @@ -342,7 +342,6 @@ class PaymentVarious extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); if ($this->id > 0) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 9d8cf29ee39..9bc8608692d 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -121,7 +121,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $statut = 'all'; $search_ref=''; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 61a88aa9c2f..ec61c39ee84 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -122,7 +122,7 @@ if ($action=="dl" && $numref > 0) { // TODO Replace this with a standard builddoc action that use a document generation module to build the ZIP $log = ''; - + $outdir = $conf->bank->dir_temp.'/'.$numref.'-'.$object->label; $outdirinvoices = $outdir.'/'.$langs->trans("BillsCustomers"); $outdirsupplierinvoices = $outdir.'/'.$langs->trans("BillsSuppliers"); @@ -130,7 +130,7 @@ if ($action=="dl" && $numref > 0) dol_mkdir($outdir); dol_mkdir($outdirinvoices); dol_mkdir($outdirsupplierinvoices); - + //$zipname = $object->label.'-'.$numref . '.zip'; //$zip = new ZipArchive(); //$zip->open($zipname, ZipArchive::OVERWRITE); @@ -138,7 +138,7 @@ if ($action=="dl" && $numref > 0) $sql = $sqlrequestforbankline; $facturestatic=new Facture($db); - + $resd = $db->query($sql); if ($resd) { $numd = $db->num_rows($resd); @@ -146,7 +146,7 @@ if ($action=="dl" && $numref > 0) if ($numd > 0) { $objd = $db->fetch_object($resd); - + $log.='Transaction '.$objd->rowid; $links = $object->get_url($objd->rowid); @@ -165,7 +165,7 @@ if ($action=="dl" && $numref > 0) { $facturestatic->fetch($billid); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice'); - + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other // TODO Use get_exdir $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); @@ -202,7 +202,7 @@ if ($action=="dl" && $numref > 0) { $facturestatic->fetch($billid); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier'); - + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other // TODO Use get_exdir $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); @@ -227,7 +227,7 @@ if ($action=="dl" && $numref > 0) dol_copy($srcfile, $destfile); } } - } + } break; case "payment_expensereport": /*$subdir = dol_sanitizeFileName($objd->refe); @@ -246,7 +246,7 @@ if ($action=="dl" && $numref > 0) } } $log.="\n"; - + /*if (! empty($upload_dir)) { $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); @@ -259,24 +259,24 @@ if ($action=="dl" && $numref > 0) } else { $log .= $key . ',' . $langs->trans("Nofile") . "\n"; } - + }*/ } } - + $db->free($resd); - - + + //$zip->addFromString('log '.$numref.'.csv', $log); //$zip->close(); - + // /Then download the zipped file. /*header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=' . $zipname); header('Content-Length: ' . filesize($zipname)); - + readfile($zipname); - + exit;*/ } @@ -329,18 +329,18 @@ if (empty($numref)) dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - + dol_fiche_end(); - + print '
'; if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } @@ -348,7 +348,7 @@ if (empty($numref)) print '
'; print '

'; - + print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); @@ -481,8 +481,8 @@ else //$mesprevnext.='   '; $mesprevnext.=''; $mesprevnext.='
'; - - $title=$langs->trans("AccountStatement").' '.$numref.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'); + + $title=$langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, $mesprevnext, 'title_bank.png'); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1); print '
'; @@ -520,7 +520,7 @@ else // Recherche les ecritures pour le releve $sql = $sqlrequestforbankline; - + $result = $db->query($sql); if ($result) { @@ -553,7 +553,7 @@ else print img_edit_add() .""; print "\n"; print ''; - + // Type and num if ($objp->fk_type == 'SOLD') { $type_label=' '; @@ -753,9 +753,9 @@ else print "\n"; print ""; print "
"; - + print "\n"; - + // Add a download button if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Started a rewrite to make this feature more Dolibarr compliant. Still need dev to be completed. { diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 73e94a3d197..0d9a9a94aea 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -37,38 +37,40 @@ if (! $user->rights->banque->transfer) accessforbidden(); $action = GETPOST('action','alpha'); +$error = 0; /* * Actions */ -if ($action == 'add') +if ($action == 'add_confirm') { $langs->load("errors"); $dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); $label = GETPOST('label','alpha'); $amount= GETPOST('amount'); + $amount_to= GETPOST('amount_to'); if (! $label) { - $error=1; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors'); } if (! $amount) { - $error=1; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); } if (! GETPOST('account_from','int')) { - $error=1; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), null, 'errors'); } if (! GETPOST('account_to','int')) { - $error=1; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferTo")), null, 'errors'); } if (! $error) @@ -81,17 +83,16 @@ if ($action == 'add') $accountto=new Account($db); $accountto->fetch(GETPOST('account_to','int')); - if (($accountto->id != $accountfrom->id) && ($accountto->currency_code == $accountfrom->currency_code)) + if ($accountto->id != $accountfrom->id) { $db->begin(); - $error=0; $bank_line_id_from=0; $bank_line_id_to=0; $result=0; // By default, electronic transfert from bank to bank - $typefrom='VIR'; + $typefrom='PRE'; $typeto='VIR'; if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { @@ -102,7 +103,8 @@ if ($action == 'add') if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user); if (! ($bank_line_id_from > 0)) $error++; - if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user); + if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user); + if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user); if (! ($bank_line_id_to > 0)) $error++; if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert'); @@ -112,7 +114,7 @@ if ($action == 'add') if (! $error) { - $mesgs = $langs->trans("TransferFromToDone","id."\">".$accountfrom->label."","id."\">".$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency)); + $mesgs = $langs->trans("TransferFromToDone","id."\">".$accountfrom->label."","id."\">".$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency)); setEventMessages($mesgs, null, 'mesgs'); $db->commit(); } @@ -124,6 +126,7 @@ if ($action == 'add') } else { + $error++; setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors'); } } @@ -143,8 +146,9 @@ $account_from=''; $account_to=''; $label=''; $amount=''; +$amount_to=''; -if($error) +if ($error) { $account_from = GETPOST('account_from','int'); $account_to = GETPOST('account_to','int'); @@ -160,11 +164,12 @@ print "

"; print '
'; print ''; -print ''; +print ''; print ''; print ''; -print ''; +print ''; +print ''; print ''; $var=false; @@ -181,7 +186,6 @@ $form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); print "\n"; print ''; print ''; - print "
'.$langs->trans("TransferFrom").''.$langs->trans("TransferTo").''.$langs->trans("Date").''.$langs->trans("Description").''.$langs->trans("Amount").''.$langs->trans("TransferFrom").''.$langs->trans("TransferTo").''.$langs->trans("Date").''.$langs->trans("Description").''.$langs->trans("Amount").'
"; print '
'; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index e19deca91c9..f75c111094d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -29,15 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); -$langs->load("users"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); + +// Get parameters +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); -$id=GETPOST("id",'int'); -$action=GETPOST('action','alpha'); -$cancel=GETPOST('cancel','alpha'); $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $label=GETPOST("label","alpha"); $sens=GETPOST("sens","int"); @@ -61,115 +60,139 @@ $hookmanager->initHooks(array('variouscard','globalcard')); * Actions */ -if (! empty($cancel)) +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - header("Location: index.php"); - exit; -} - -if ($action == 'add' && empty($cancel)) -{ - $error=0; - - $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); - $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); - if (empty($datev)) $datev=$datep; - - $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment"); - $object->fk_user_author=$user->id; - $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; - - if (empty($datep) || empty($datev)) + if ($cancel) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error++; - } - if (empty($object->type_payment) || $object->type_payment < 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); - $error++; - } - if (empty($object->amount)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); - $error++; - } - if (! empty($conf->banque->enabled) && ! $object->accountid > 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); - $error++; - } - - if (! $error) - { - $db->begin(); - - $ret=$object->create($user); - if ($ret > 0) + if ($action != 'addlink') { - $db->commit(); - header("Location: index.php"); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); + header("Location: ".$urltogo); exit; } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action="create"; - } + if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); + $action=''; } - $action='create'; -} - -if ($action == 'delete') -{ - $result=$object->fetch($id); - - if ($object->rappro == 0) + if ($action == 'add') { - $db->begin(); + $error=0; - $ret=$object->delete($user); - if ($ret > 0) + $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); + $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + if (empty($datev)) $datev=$datep; + + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; + $object->datev=$datev; + $object->datep=$datep; + $object->amount=price2num(GETPOST("amount")); + $object->label=GETPOST("label"); + $object->note=GETPOST("note"); + $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment=GETPOST("num_payment"); + $object->fk_user_author=$user->id; + $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; + $object->sens=GETPOST('sens'); + + if (empty($datep) || empty($datev)) { - if ($object->fk_bank) - { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) - } + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); + $error++; + } + if (empty($object->type_payment) || $object->type_payment < 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); + $error++; + } + if (empty($object->amount)) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); + $error++; + } + if (! empty($conf->banque->enabled) && ! $object->accountid > 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); + $error++; + } + if (! empty($conf->accounting->enabled) && ! $object->accountancy_code) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + } - if ($result >= 0) + if (! $error) + { + $db->begin(); + + $ret=$object->create($user); + if ($ret > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + header("Location: index.php"); exit; } else { - $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $action="create"; + } + } + + $action='create'; + } + + if ($action == 'delete') + { + $result=$object->fetch($id); + + if ($object->rappro == 0) + { + $db->begin(); + + $ret=$object->delete($user); + if ($ret > 0) + { + if ($object->fk_bank) + { + $accountline=new AccountLine($db); + $result=$accountline->fetch($object->fk_bank); + if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + } + + if ($result >= 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + exit; + } + else + { + $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); } } - else - { - setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); - } } @@ -200,8 +223,9 @@ if ($id) /* ************************************************************************** */ if ($action == 'create') { - print ''; + print ''; print ''; + print ''; print ''; print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png'); @@ -269,7 +293,7 @@ if ($action == 'create') // Accountancy account if (! empty($conf->accounting->enabled)) { - print ''.$langs->trans("AccountAccounting").''; + print ''.$langs->trans("AccountAccounting").''; print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print ''; @@ -292,7 +316,7 @@ if ($action == 'create') print '
'; print ''; - print '     '; + print '   '; print ''; print '
'; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 39c6d27be4f..5b2488cc5e8 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 Laurent Destailleur * * 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 @@ -16,9 +17,9 @@ */ /** - * \file htdocs/compta/bank/various_payment/index.php - * \ingroup bank - * \brief List of various payments + * \file htdocs/compta/bank/various_payment/index.php + * \ingroup bank + * \brief List of various payments */ require '../../../main.inc.php'; @@ -34,6 +35,8 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'banque', '', '', ''); +$optioncss = GETPOST('optioncss','alpha'); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); @@ -44,17 +47,16 @@ $search_account = GETPOST('search_account','int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +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; if (! $sortfield) $sortfield="v.datep"; if (! $sortorder) $sortorder="DESC"; -$optioncss = GETPOST('optioncss','alpha'); -$filtre=$_GET["filtre"]; +$filtre=GETPOST("filtre",'alpha'); -if (empty($_REQUEST['typeid'])) +if (! GETPOST('typeid')) { $newfiltre=str_replace('filtre=','',$filtre); $filterarray=explode('-',$newfiltre); @@ -66,16 +68,16 @@ if (empty($_REQUEST['typeid'])) } else { - $typeid=$_REQUEST['typeid']; + $typeid=GETPOST('typeid'); } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; $search_amount=""; $search_account=''; - $typeid=""; + $typeid=""; } /* @@ -103,11 +105,11 @@ if ($search_label) $sql.=natural_search(array('v.label'), $search_label); if ($search_amount) $sql.=natural_search("v.amount", $search_amount, 1); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($filtre) { - $filtre=str_replace(":","=",$filtre); - $sql .= " AND ".$filtre; + $filtre=str_replace(":","=",$filtre); + $sql .= " AND ".$filtre; } if ($typeid) { - $sql .= " AND v.fk_typepayment=".$typeid; + $sql .= " AND v.fk_typepayment=".$typeid; } $sql.= $db->order($sortfield,$sortorder); @@ -116,48 +118,48 @@ $totalnboflines=0; $result=$db->query($sql); if ($result) { - $totalnboflines = $db->num_rows($result); + $totalnboflines = $db->num_rows($result); } $sql.= $db->plimit($limit+1,$offset); $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0 ; + $num = $db->num_rows($result); + $i = 0; + $total = 0 ; $var=true; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($typeid) $param.='&typeid='.$typeid; if ($optioncss != '') $param.='&optioncss='.$optioncss; print ''; - if ($optioncss != '') print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - + print ''; + print ''; + print ''; + print ''; + print_barre_liste($langs->trans("VariousPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); - - print '
'; - print ''."\n"; + + print '
'; + print '
'."\n"; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); - if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("BankAccount"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("BankAccount"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Sens"),$_SERVER["PHP_SELF"],"v.sens","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; + print "\n"; print ''; // Ref @@ -174,85 +176,88 @@ if ($result) print ''; // Account if (! empty($conf->banque->enabled)) - { - print ''; - } + { + print ''; + } // Amount print ''; // Sens print ''; - print ''; - + print ''; + print "\n"; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($result); - - print ''; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($result); - $variousstatic->id=$obj->rowid; + print ''; + + $variousstatic->id=$obj->rowid; $variousstatic->ref=$obj->rowid; - // Ref + // Ref print "\n"; // Label payment - print "\n"; + print "\n"; // Date payment - print '\n"; - // Type - print ''; + print '\n"; + // Type + print ''; // Account - if (! empty($conf->banque->enabled)) - { - print ''; - } - // Amount - print ""; - // Sens + if (! empty($conf->banque->enabled)) + { + print ''; + } + // Amount + print ""; + // Sens if ($obj->sens == '1') $sens = $langs->trans("Credit"); else $sens = $langs->trans("Debit"); - print ""; - print ""; - print "\n"; + print ""; + print ""; + print "\n"; - $total = $total + $obj->amount; + $total = $total + $obj->amount; - $i++; - } + $i++; + } - $colspan=4; - if (! empty($conf->banque->enabled)) $colspan++; - print ''; - print '"; - print ""; + $colspan=4; + if (! empty($conf->banque->enabled)) $colspan++; + print ''; + print ''; + print '"; + print ''; + print ''; + print ''; - print "
'; - $form->select_comptes($search_account,'search_account',0,'',1); - print ''; + $form->select_comptes($search_account,'search_account',0,'',1); + print ' '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
".$variousstatic->getNomUrl(1)."".dol_trunc($obj->label,40)."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->datep),'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.dol_print_date($db->jdate($obj->datep),'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal; - $accountstatic->label=$obj->blabel; - print $accountstatic->getNomUrl(1); - } - else print ' '; - print '".price($obj->amount)."'; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id=$obj->bid; + $accountstatic->ref=$obj->bref; + $accountstatic->number=$obj->bnumber; + $accountstatic->accountancy_number=$obj->account_number; + $accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal; + $accountstatic->label=$obj->blabel; + print $accountstatic->getNomUrl(1); + } + else print ' '; + print '".price($obj->amount)."".$sens."
".$sens."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("Total").''.price($total)."
"; - print '
'; + print ""; + print ''; print ''; - $db->free($result); + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index de5e00045e7..e42e9f2325a 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -57,7 +57,7 @@ if (! $sortfield) $sortfield="d.dated"; $year=GETPOST("year"); $month=GETPOST("month"); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_name=""; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index dd89ae944ef..63b978a9e04 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4185,7 +4185,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print ''; + print ''; } } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 6bc88e47490..52fb375000c 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -475,7 +475,13 @@ class FactureRec extends CommonInvoice { $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid; dol_syslog($sql); - if (! $this->db->query($sql)) + if ($this->db->query($sql)) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error=-3; + } + else { $this->error=$this->db->lasterror(); $error=-1; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ce441ee213e..508f71fdc86 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2044,7 +2044,12 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); return 0; } - + if (count($this->lines) <= 0) + { + $langs->load("errors"); + $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + return -1; + } if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { @@ -2652,9 +2657,10 @@ class Facture extends CommonInvoice * @param int $situation_percent Situation advance percentage * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency + * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0, $notrigger=0) { global $conf,$user; // Deprecation warning @@ -2812,7 +2818,7 @@ class Facture extends CommonInvoice $this->line->array_options=$array_options; } - $result=$this->line->update($user); + $result=$this->line->update($user, $notrigger); if ($result > 0) { // Reorder if child line @@ -3848,11 +3854,12 @@ class Facture extends CommonInvoice } $this->lines[$xnbp]=$line; - $xnbp++; $this->total_ht += $line->total_ht; $this->total_tva += $line->total_tva; $this->total_ttc += $line->total_ttc; + + $xnbp++; } $this->revenuestamp = 0; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 22306e498f2..d38ea012c3c 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -46,13 +46,18 @@ $langs->load('compta'); $langs->load('admin'); $langs->load('other'); +$action = GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); +$show_files = GETPOST('show_files','int'); +$confirm = GETPOST('confirm','alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search + // Security check $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); $lineid=GETPOST('lineid','int'); $ref=GETPOST('ref','alpha'); -$action=GETPOST('action', 'alpha'); if ($user->societe_id) $socid=$user->societe_id; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; @@ -112,7 +117,7 @@ $arrayfields=array( 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbGeneration"), 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -132,6 +137,9 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab * Actions */ +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -140,6 +148,9 @@ if (empty($reshook)) { if (GETPOST('cancel')) $action=''; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Set note include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -148,7 +159,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Do we click on purge search criteria ? - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=''; $search_societe=''; @@ -165,6 +176,14 @@ if (empty($reshook)) $search_array_options=array(); } + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ + // Create predefined invoice if ($action == 'add') { @@ -517,7 +536,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { @@ -905,7 +924,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + dol_fiche_head(null, '', '', 0); $rowspan=4; if (! empty($conf->projet->enabled)) $rowspan++; @@ -942,7 +961,7 @@ if ($action == 'create') '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')' ); $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { @@ -952,10 +971,10 @@ if ($action == 'create') // Public note print ''; - print ''; + print ''; print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); print ''; - print ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -963,7 +982,7 @@ if ($action == 'create') if (empty($user->societe_id)) { print ''; - print ''; + print ''; print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); print ''; print ''; @@ -1007,12 +1026,14 @@ if ($action == 'create') print ""; - print '

'; + dol_fiche_end(); // Autogeneration $title = $langs->trans("Recurrence"); - print load_fiche_titre($title, '', 'calendar'); + print load_fiche_titre(' '.$title, '', ''); + + dol_fiche_head(null, '', '', 0); print ''; @@ -1040,7 +1061,8 @@ if ($action == 'create') print "
"; - print '

'; + dol_fiche_end(); + $title = $langs->trans("ProductsAndServices"); if (empty($conf->service->enabled)) @@ -1078,8 +1100,6 @@ if ($action == 'create') } print "\n"; - dol_fiche_end(); - print '
'; print '     '; print ''; @@ -1260,7 +1280,7 @@ else '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')' ); $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { @@ -1323,7 +1343,7 @@ else print ''; print ''; - + // if "frequency" is empty or = 0, the reccurence is disabled print '"; - if (! $i) $totalarray['nbfield']++; + print '"; + if (! $i) $totalarray['nbfield']++; } // Action column diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 321c2456ddd..103ec747e37 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -378,7 +378,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; $total_ttc += $obj->total_ttc; - $total += $obj->total; + $total += $obj->total_ht; $totalam += $obj->am; $i++; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 13c753db464..a70066bdb5d 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -54,8 +54,9 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); + +$date_start = dol_mktime( 0, 0, 0, GETPOST( "date_startmonth" ), GETPOST( "date_startday" ), GETPOST( "date_startyear" ) ); +$date_end = dol_mktime( 23, 59, 59, GETPOST( "date_endmonth" ), GETPOST( "date_endday" ), GETPOST( "date_endyear" ) ); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { @@ -92,12 +93,9 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); - - -/* +/** * View */ - $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); foreach($listofparams as $param) @@ -118,6 +116,7 @@ $paymentfourn_static=new PaiementFourn($db); $fsearch.=' '; $fsearch.=' '; +$fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; @@ -196,9 +195,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); - +$x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); echo '
'.$title.'
'; print ''; print "\n"; + print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountVAT"),$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.nb_gen_done']['checked'])) - { - print_liste_field_titre($langs->trans("NbOfGenerationDone"),$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); - } - print_liste_field_titre($langs->trans("DateLastGeneration"),$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NextDateToExecution"),$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); // Field may contains ling text + if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; - - + + if ($num > 0) { $var=true; @@ -1800,26 +1828,67 @@ else { $objp = $db->fetch_object($resql); - print ''; - - print '\n"; - $companystatic->id=$objp->socid; $companystatic->name=$objp->name; - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; + print ''; + + if (! empty($arrayfields['f.titre']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.total']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.tva']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.total_ttc']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.frequency']['checked'])) + { + print ''; + } if (! empty($arrayfields['f.nb_gen_done']['checked'])) { - print ''; + print ''; } - print ''; - print ''; - + if (! empty($arrayfields['f.date_last_gen']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.date_when']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.datec']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.tms']['checked'])) + { + print ''; + } + // Action column print ''; + else + { + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; + } print "
'; @@ -1558,7 +1578,8 @@ else * List mode */ $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency,"; - $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when"; + $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,"; + $sql.= " f.datec, f.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; if (! $user->rights->societe->client->voir && ! $socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1570,10 +1591,10 @@ else } if ($search_ref) $sql .= natural_search('f.titre', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); - if ($search_frequency) $sql .= natural_search('f.frequency', $search_frequency); if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); + if ($search_frequency > 0) $sql.= natural_search('f.frequency', $search_frequency); if ($search_frequency == '1') $sql.= ' AND f.frequency > 0'; if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)'; @@ -1605,23 +1626,24 @@ else } $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($limit+1,$offset); + $sql.= $db->order($sortfield, $sortorder); + $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($socid) $param.='&socid='.$socid; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; @@ -1631,9 +1653,9 @@ else if ($search_ref) $param.='&search_ref=' .$search_ref; if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; - if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; + if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; - if ($search_frequency) $param.='&search_frequency=' .$search_frequency; + if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency; if ($option) $param.="&option=".$option; if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields @@ -1646,14 +1668,20 @@ else $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - print '
'."\n"; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print ''."\n"; if ($optioncss != '') print ''; print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; + print ''; print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); @@ -1776,23 +1804,23 @@ else print '
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; - print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; + print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).''.($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '').''; + print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : ''.$langs->trans('NA').''); + print ''.($objp->frequency ? dol_print_date($objp->date_last_gen,'day') : '').''.($objp->frequency ? dol_print_date($objp->date_when,'day') : '').''; + print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : ''.$langs->trans('NA').''); + print ''; + print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : ''.$langs->trans('NA').''); + print ''; + print dol_print_date($db->jdate($objp->datec),'dayhour'); + print ''; + print dol_print_date($db->jdate($objp->tms),'dayhour'); + print ''; if ($user->rights->facture->creer) { @@ -1842,7 +1911,12 @@ else $i++; } } - else print '
'.$langs->trans("NoneF").'
'.$langs->trans("NoRecordFound").'
"; print ""; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 513c6854eb8..13e9a22d717 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -191,7 +191,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests are required to be compatible with all browsers { $search_user=''; $search_sale=''; @@ -531,6 +531,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); + if (empty($search_societe)) $search_societe = $soc->name; } $param='&socid='.$socid; @@ -594,6 +595,7 @@ if ($resql) $i = 0; print ''."\n"; + if ($optioncss != '') print ''; print ''; print ''; @@ -1253,10 +1255,10 @@ if ($resql) // Status if (! empty($arrayfields['f.fk_statut']['checked'])) { - print '
'; - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); - print "'; + print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); + print "
'; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index cdc5eb2e545..394e2f23841 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -99,7 +99,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice=new Facture($db); foreach ($_POST as $key => $value) { if (substr($key,0,7) == 'amount_') @@ -188,7 +188,7 @@ if (empty($reshook)) setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); $error++; } - + // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { @@ -228,7 +228,7 @@ if (empty($reshook)) $newvalue = price2num($value,'MT'); $amounts[$key] = -$newvalue; } - + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch { $newvalue = price2num($value,'MT'); @@ -319,7 +319,7 @@ llxHeader('', $langs->trans("Payment")); if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); - $result=$facture->fetch($facid); + $result = $facture->fetch($facid); if ($result >= 0) { @@ -389,7 +389,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { subJson[n["name"]] = n["value"]; }); - + return subJson; } function callForResult(imgId) @@ -516,31 +516,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; - + print '
'.$langs->trans('Comments').''; print '
'; dol_fiche_end(); - + /* * List of unpaid invoices */ - + $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; $sql.= ' f.datef as df, f.fk_soc as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - + $sql.= ' WHERE f.entity = '.$conf->entity; $sql.= ' AND (f.fk_soc = '.$facture->socid; - + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } - + $sql.= ') AND f.paye = 0'; $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) @@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //print ''; print '
'; print ''; - + print ''; print ''; print ''; @@ -602,7 +602,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie while ($i < $num) { $objp = $db->fetch_object($resql); - + $soc = new Societe($db); $soc->fetch($objp->socid); @@ -614,9 +614,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $deposits=$invoice->getSumDepositsUsed(); $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); - + // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); @@ -624,7 +624,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT'); $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT'); } - + print ''; print '\n"; - + // Currency if (!empty($conf->multicurrency->enabled)) print '\n"; - + // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; - + // Multicurrency Price print ''; - + // Multicurrency Price print ''; } - + // Price print ''; - + // Received or paid back print '"; // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) + if (! empty($conf->multicurrency->enabled)) { print ''; print ''; - print ''; + print ''; // Autofilled if (!empty($conf->multicurrency->enabled)) print ''; print ''; print "\n"; @@ -802,9 +802,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'; if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) + if (!empty($multicurrency_totalpayment)) { - $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); + $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { @@ -864,7 +864,7 @@ if (! GETPOST('action','aZ09')) while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; print '\n"; print '\n"; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index aeed72d93d1..3e2b43b7f34 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -68,7 +68,7 @@ $accountstatic=new Account($db); */ // If click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=''; $search_amount=''; diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index d6031ae1685..b089cac6aab 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -42,7 +42,7 @@ class Cpaiement /** */ - + public $code; public $libelle; public $type; @@ -52,7 +52,7 @@ class Cpaiement /** */ - + /** * Constructor @@ -79,7 +79,7 @@ class Cpaiement $error = 0; // Clean parameters - + if (isset($this->code)) { $this->code = trim($this->code); } @@ -99,14 +99,14 @@ class Cpaiement $this->module = trim($this->module); } - + // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - + $sql.= 'id,'; $sql.= 'code,'; $sql.= 'libelle,'; @@ -115,9 +115,9 @@ class Cpaiement $sql.= 'accountancy_code,'; $sql.= 'module'; - + $sql .= ') VALUES ('; - + $sql .= ' '.(! isset($this->id)?'NULL':$this->id).','; $sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").','; $sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").','; @@ -126,7 +126,7 @@ class Cpaiement $sql .= ' '.(! isset($this->accountancy_code)?'NULL':"'".$this->db->escape($this->accountancy_code)."'").','; $sql .= ' '.(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'"); - + $sql .= ')'; $this->db->begin(); @@ -198,7 +198,7 @@ class Cpaiement $obj = $this->db->fetch_object($resql); $this->id = $obj->id; - + $this->code = $obj->code; $this->libelle = $obj->libelle; $this->type = $obj->type; @@ -206,7 +206,7 @@ class Cpaiement $this->accountancy_code = $obj->accountancy_code; $this->module = $obj->module; - + } $this->db->free($resql); @@ -238,7 +238,7 @@ class Cpaiement dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->code)) { $this->code = trim($this->code); } @@ -258,7 +258,7 @@ class Cpaiement $this->module = trim($this->module); } - + // Check parameters // Put here code to add a control on parameters values @@ -356,8 +356,8 @@ class Cpaiement return 1; } } - - + + /** * Initialise object with example values * Id must be 0 if object instance is a specimen @@ -367,7 +367,7 @@ class Cpaiement public function initAsSpecimen() { $this->id = 0; - + $this->code = ''; $this->libelle = ''; $this->type = ''; @@ -375,7 +375,7 @@ class Cpaiement $this->accountancy_code = ''; $this->module = ''; - + } } diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index ec2bbc78fc6..4a7a2e3c81a 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -77,7 +77,7 @@ $extrafields = new ExtraFields($db); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_account=""; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 9a5585c2513..6fcbb62b5d9 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -57,7 +57,7 @@ $search_ref = GETPOST('search_ref','alpha'); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 208be88aeae..6251a6f6521 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -65,7 +65,7 @@ $ligne=new LignePrelevement($db,$user); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_line=""; $search_bon=""; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 45bde4bcd32..2b8b6a6fe5b 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -44,7 +44,7 @@ $action=GETPOST('action','aZ09'); // Security check $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'salaries', '', '', ''); +$result = restrictedArea($user, 'salaries', '', '', 'payment'); $object = new PaymentSalary($db); diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index baf99182993..b25df5a71ac 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -79,7 +79,7 @@ else * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 630197cfc78..0ab82a7cae3 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -67,7 +67,7 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) { if ($object->paye) { $result = $object->set_unpaid($user); - if ($result > 0) + if ($result > 0) { header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); exit(); @@ -350,7 +350,7 @@ if ($action == 'create') print ''; } @@ -405,7 +405,7 @@ if ($id > 0) $head=tax_prepare_head($object); $totalpaye = $object->getSommePaiement(); - + // Clone confirmation if ($action === 'clone') { @@ -473,21 +473,21 @@ if ($id > 0) $morehtmlref.=''; } } - } + } $morehtmlref.=''; - + $linkback = '' . $langs->trans("BackToList") . ''; - + $object->totalpaye = $totalpaye; // 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); - + print '
'; print '
'; print '
'; - + print '
'.$arraytitle.''.$langs->trans('Date').'
'; @@ -634,36 +634,36 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Date print ''.dol_print_date($db->jdate($objp->df),'day')."'.$objp->multicurrency_code."'; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($sign * $multicurrency_payment); if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); } print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); print ''.price($sign * $objp->total_ttc).''.price($sign * $paiement); if ($creditnotes) print '+'.price($creditnotes); @@ -685,7 +685,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); - print ''; + print ''; print ''; } else @@ -696,14 +696,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "'; - + // Add remind multicurrency amount $namef = 'multicurrency_amount_'.$objp->facid; $nameRemain = 'multicurrency_remain_'.$objp->facid; - + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { if ($action != 'add_paiement') @@ -723,7 +723,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Warning - print ''; + print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) @@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $totalrecudeposits+=$deposits; $i++; } - + if ($i > 1) { // Print total @@ -760,7 +760,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($totalrecudeposits) print '+'.price($totalrecudeposits); print '
'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).' 
'.$objp->facnumber."'.dol_print_date($db->jdate($objp->dp))."
'.$langs->trans("Project").''; $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1); - + print '
'; - + // Type print '"; print ""; @@ -588,7 +588,7 @@ if ($id > 0) if ($resql) { $totalpaye = 0; - + $num = $db->num_rows($resql); $i = 0; $total = 0; print '
'.$langs->trans("Type")."".$object->type_libelle."
'; @@ -598,14 +598,14 @@ if ($id > 0) print ''; print ''; print ''; - + $var=true; if ($num > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); - + print "'; print '\n"; @@ -619,18 +619,18 @@ if ($id > 0) } else { - + print ''; } - + //if ($object->status == ChargeSociales::STATUS_DRAFT) //{ print "\n"; print "\n"; - + $resteapayer = $object->amount - $totalpaye; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; - + print ""; print '\n"; //} @@ -640,12 +640,12 @@ if ($id > 0) else { dol_print_error($db); - } - + } + print ''; print ''; print ''; - + print '
'; dol_fiche_end(); diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 2ab2cb1c172..50dd4d430ed 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -71,7 +71,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 045284bd47c..ff26347576e 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -173,7 +173,6 @@ class Tva extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; - $sql.= " tms=".$this->db->idate($this->tms).","; $sql.= " datep=".$this->db->idate($this->datep).","; $sql.= " datev=".$this->db->idate($this->datev).","; @@ -182,9 +181,7 @@ class Tva extends CommonObject $sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " fk_bank=".$this->fk_bank.","; $sql.= " fk_user_creat=".$this->fk_user_creat.","; - $sql.= " fk_user_modif=".$this->fk_user_modif.""; - - + $sql.= " fk_user_modif=".($this->fk_user_modif>0?$this->fk_user_modif:$user->id).""; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -580,7 +577,7 @@ class Tva extends CommonObject } else { $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), '', '', $user); } - + // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction if ($bank_line_id > 0) { @@ -731,7 +728,7 @@ class Tva extends CommonObject { return $this->LibStatut($this->statut,$mode); } - + /** * Renvoi le libelle d'un statut donne * diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 105bfcb2bf6..618ba11a37e 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -83,7 +83,7 @@ function pt ($db, $sql, $date) while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; print '\n"; $total = $total + $obj->mm; @@ -147,14 +147,14 @@ for ($m = 1 ; $m < 13 ; $m++ ) { $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); - + $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; $parameters["type"] = 'vat'; - + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -171,7 +171,7 @@ for ($m = 1 ; $m < 13 ; $m++ ) break; } - + print ''; print ''; @@ -220,22 +220,67 @@ print '
'.$langs->trans("Type").''.$langs->trans("Amount").'
"; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."
'.$langs->trans("None").'
".$langs->trans("AlreadyPaid")." :".price($totalpaye)."
".$langs->trans("AmountExpected")." :".price($object->amount)."
".$langs->trans("RemainderToPay")." :'.price($resteapayer)."
'.$obj->dm."
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'
'; print '
'; + print load_fiche_titre($langs->trans("VATPaid"), '', ''); /* * Payed */ -$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; +$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'"; -$sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'"; +$sql.= " AND f.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; +$sql.= " AND f.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql.= " GROUP BY dm ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); +print '
'; + + + +if (! empty($conf->global->MAIN_FEATURES_LEVEL)) +{ + /* + * Recap + */ + + print load_fiche_titre($langs->trans("VATRecap"), '', ''); // need to add translation + + $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; + $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; + $sql1 .= " WHERE f.entity = " . $conf->entity; + $sql1 .= " AND f.datev >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql1 .= " AND f.datev <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql1 .= " GROUP BY dm ORDER BY dm ASC"; + + $result = $db->query($sql1); + if ($result) { + $obj = $db->fetch_object($result); + print ''; + + print ""; + print ''; // need to add translation + print ''; + print "\n"; + + print ""; + print ''; + print '\n"; + print "\n"; + + $restopay = $total - $obj->mm; + print ""; + print ''; // need to add translation + print ''; + print "\n"; + + print '
' . $langs->trans("VATDue") . '' . price(price2num($total, 1)) . '
' . $langs->trans("VATPaid") . '' . price(price2num($obj->mm, 1)) . "
' . $langs->trans("VATRestopay") . '' . price(price2num($restopay, 1)) . '
'; + } +} + print '
'; llxFooter(); diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 44c45a65dc7..c75730d2f8e 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -74,7 +74,7 @@ else $typeid=$_REQUEST['typeid']; } -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','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 74ec89bf5d1..7f35c71cd11 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -122,7 +122,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index fbd27b0d841..d5854297f43 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -625,7 +625,7 @@ else // EMail if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print ''; - print 'email).'">'; + print 'email).'">'; if (! empty($conf->mailing->enabled)) { print ''; @@ -860,7 +860,7 @@ else // EMail print ''; - print 'email).'">'; + print 'email).'">'; if (! empty($conf->mailing->enabled)) { $langs->load("mails"); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index b80a300431a..3b7ce848731 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -108,7 +108,7 @@ class Contact extends CommonObject $this->db = $db; $this->statut = 1; // By default, status is enabled } - + /** * Load indicators into this->nb for board * @@ -117,10 +117,10 @@ class Contact extends CommonObject function load_state_board() { global $user; - + $this->nb=array(); $clause = "WHERE"; - + $sql = "SELECT count(sp.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->societe_id) @@ -133,7 +133,7 @@ class Contact extends CommonObject $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')'; $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; - + $resql=$this->db->query($sql); if ($resql) { @@ -410,7 +410,9 @@ class Contact extends CommonObject { global $conf,$langs; - // Object classes + $info = array(); + + // Object classes $info["objectclass"]=explode(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname=$this->getFullName($langs); @@ -486,7 +488,7 @@ class Contact extends CommonObject $result=false; $this->db->begin(); - + // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); @@ -544,7 +546,7 @@ class Contact extends CommonObject if ($result < 0) { $error++; } // End call triggers } - + if (! $error) { $this->db->commit(); @@ -659,7 +661,7 @@ class Contact extends CommonObject $this->canvas = $obj->canvas; $this->import_key = $obj->import_key; - + // Define gender according to civility $this->setGenderFromCivility(); @@ -735,7 +737,7 @@ class Contact extends CommonObject /** * Set property ->gender from property ->civility_id - * + * * @return void */ function setGenderFromCivility() @@ -746,8 +748,8 @@ class Contact extends CommonObject } else if(in_array($this->civility_id, array('MME','MLE'))) { $this->gender = 'woman'; } - } - + } + /** * Load number of elements the contact is used as a link for * ref_facturation @@ -1007,13 +1009,13 @@ class Contact extends CommonObject if ($this->phone_perso) $phonelist[]=$this->phone_perso; $label.= '
' . $langs->trans("Phone") . ': '.join(', ',$phonelist); $label.= '
' . $langs->trans("Address") . ': '.dol_format_address($this, 1, ' ', $langs); - + $link = 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label=$langs->trans("ShowContact"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' class="classfortooltip">'; @@ -1029,15 +1031,15 @@ class Contact extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; $link.=$linkclose; - + $linkend=''; - + if ($option == 'xxx') { $link = ''; $linkend=''; } - + if ($withpicto) $result.=($link.img_object($label, 'contact', 'class="classfortooltip"').$linkend.' '); $result.=$link.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$linkend; return $result; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 608f5614cd8..46078931ebd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -228,7 +228,7 @@ class Contrat extends CommonObject */ function active_line($user, $line_id, $date, $date_end='', $comment='') { - $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); } @@ -243,7 +243,7 @@ class Contrat extends CommonObject */ function close_line($user, $line_id, $date_end, $comment='') { - $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); } @@ -1633,8 +1633,8 @@ class Contrat extends CommonObject if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_option; - $contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element); + $contractline->array_options=$array_options; + $contractline->id= $rowid; $result=$contractline->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a526a9bd78c..48a9afaaa56 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -146,7 +146,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $day=''; $month=''; @@ -305,8 +305,15 @@ if ($resql) $i = 0; $arrayofselected=is_array($toselect)?$toselect:array(); + + if ($socid > 0) + { + $soc = new Societe($db); + $soc->fetch($socid); + if (empty($search_name)) $search_name = $soc->name; + } - $param=''; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sall != '') $param.='&sall='.$sall; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index aea03a73df5..2fdec21f735 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -152,7 +152,7 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_name=""; $search_contract=""; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5313b79dc04..be6f13a22c7 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2017 Laurent Destailleur * * 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 @@ -26,6 +26,7 @@ // $objectclass and $$objectlabel must be defined // $parameters, $object, $action must be defined for the hook. +// $permtoread, $permtocreate and $permtodelete may be defined // $uploaddir may be defined (example to $conf->projet->dir_output."/";) // $toselect may be defined @@ -524,6 +525,66 @@ if ($action == 'remove_file') $action=''; } +// Validate records +if (! $error && $massaction == 'validate' && $permtocreate) +{ + if ($object->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); + $error++; + } + if (! $error) + { + $db->begin(); + + $objecttmp=new $objectclass($db); + $nbok = 0; + foreach($toselect as $toselectid) + { + $result=$objecttmp->fetch($toselectid); + if ($result > 0) + { + //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + //else + $result = $objecttmp->validate($user); + if ($result == 0) + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); + $error++; + break; + } + elseif ($result < 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + else $nbok++; + } + else + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (! $error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } + //var_dump($listofobjectthirdparties);exit; + } +} + // Delete records if (! $error && $massaction == 'delete' && $permtodelete) { diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index a796a94c68c..1998808bf11 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -391,6 +391,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; + if (is_array($attachedfiles) && count($attachedfiles)>0) { + $object->attachedfiles = $attachedfiles; + } // Call of triggers if (! empty($trigger_name)) diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 03b33b19eb1..b8ae96cb920 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -32,16 +32,19 @@ if ($action == 'setModuleOptions') $db->begin(); // Process common param fields - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + foreach($_POST as $key => $val) { - $param=GETPOST("param".$reg[1],'alpha'); - $value=GETPOST("value".$reg[1],'alpha'); - if ($param) + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... { - $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; + $param=GETPOST("param".$reg[1],'alpha'); + $value=GETPOST("value".$reg[1],'alpha'); + if ($param) + { + $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } } } } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index d83f0e80cba..9c496964942 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -375,6 +375,133 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" return ''; } + + /** + * Return list of widget. Function used by admin page htdoc/admin/widget. + * List is sorted by widget filename so by priority to run. + * + * @param array $forcedirwidget null=All default directories. This parameter is used by modulebuilder module only. + * @return array Array list of widget + */ + static function getWidgetsList($forcedirwidget=null) + { + global $conf, $langs, $db; + + $files = array(); + $fullpath = array(); + $relpath = array(); + $iscoreorexternal = array(); + $modules = array(); + $orders = array(); + $i = 0; + + $dirwidget=array_merge(array('/core/boxes/')); + if (is_array($forcedirwidget)) + { + $dirwidget=$forcedirwidget; + } + + foreach($dirwidget as $reldir) + { + $dir=dol_buildpath($reldir,0); + $newdir=dol_osencode($dir); + + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) + if (! is_dir($newdir)) continue; + + $handle=opendir($newdir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/',$file,$reg)) + { + if (preg_match('/\.back$/',$file)) continue; + + $part1=$reg[1]; + + $modName = ucfirst($reg[1]); + //print "file=$file"; print "modName=$modName"; exit; + if (in_array($modName,$modules)) + { + $langs->load("errors"); + print '
'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget",$modName,"").'
'; + } + else + { + try { + include_once $newdir.'/'.$file; + } + catch(Exception $e) + { + print $e->getMessage(); + } + } + + $files[$i] = $file; + $fullpath[$i] = $dir.'/'.$file; + $relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file; + $iscoreorexternal[$i] = ($reldir == '/core/boxes/'?'internal':'external'); + $modules[$i] = $modName; + $orders[$i] = $part1; // Set sort criteria value + + $i++; + } + } + closedir($handle); + } + } + + asort($orders); + + $widget = array(); + $j = 0; + + // Loop on each widget + foreach ($orders as $key => $value) + { + $modName = $modules[$key]; + if (empty($modName)) continue; + + if (! class_exists($modName)) + { + print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."
\n"; + continue; + } + + $objMod = new $modName($db); + if (is_object($objMod)) + { + // Define disabledbyname and disabledbymodule + $disabledbyname=0; + $module=''; + + // Check if widget file is disabled by name + if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1; + + // We set info of modules + $widget[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); + $widget[$j]['file'] = $files[$key]; + $widget[$j]['fullpath'] = $fullpath[$key]; + $widget[$j]['relpath'] = $relpath[$key]; + $widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; + //$widget[$j]['version'] = $objMod->getVersion(); + $widget[$j]['status'] = img_picto($langs->trans("Active"),'tick'); + if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = ''; + + $text =''.$langs->trans("Description").':
'; + $text.=$objMod->boxlabel.'
'; + $text.='
'.$langs->trans("Status").':
'; + if ($disabledbymodule == 2) $text.=$langs->trans("HooksDisabledAsModuleDisabled",$module).'
'; + + $widget[$j]['info'] = $text; + } + $j++; + } + return $widget; + } + + } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 00394b0e03f..1961cbb7af6 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -318,34 +318,6 @@ abstract class CommonDocGenerator return $array_other; } - - - - /** - * Define array with couple subtitution key => subtitution value - * - * @param Object $object Dolibarr Object - * @param Translate $outputlangs Language object for output - * @param boolean $recursive Want to fetch child array or child object - * @return array Array of substitution key->code - */ - function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) { - $array_other = array(); - if(!empty($object)) { - foreach($object as $key => $value) { - if(!empty($value)) { - if(!is_array($value) && !is_object($value)) { - $array_other['object_'.$key] = $value; - } - if(is_array($value) && $recursive){ - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false); - } - } - } - } - return $array_other; - } - /** @@ -410,10 +382,19 @@ abstract class CommonDocGenerator $array_key.'_total_ttc'=>price2num($object->total_ttc), $array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()), + $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), + $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), + $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), + $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), + $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), + $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), + $array_key.'_note_private'=>$object->note, $array_key.'_note_public'=>$object->note_public, $array_key.'_note'=>$object->note_public, // For backward compatibility - + // Payments $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), $array_key.'_already_payed'=>price2num($sumpayed), @@ -421,10 +402,10 @@ abstract class CommonDocGenerator $array_key.'_already_deposit'=>price2num($sumdeposit), $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), $array_key.'_already_creditnote'=>price2num($sumcreditnote), - + $array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), - $array_key.'already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), - + $array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), + // Remain to pay with all know infrmation (except open direct debit requests) $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') @@ -493,6 +474,16 @@ abstract class CommonDocGenerator 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), + + 'line_multicurrency_code' => price2num($line->multicurrency_code), + 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), + 'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht), + 'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva), + 'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc), + 'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs), + 'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs), + 'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), + 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), ); // Retrieve extrafields @@ -601,6 +592,33 @@ abstract class CommonDocGenerator ); } + + /** + * Define array with couple subtitution key => subtitution value + * + * @param Object $object Dolibarr Object + * @param Translate $outputlangs Language object for output + * @param boolean $recursive Want to fetch child array or child object + * @return array Array of substitution key->code + */ + function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) { + $array_other = array(); + if(!empty($object)) { + foreach($object as $key => $value) { + if(!empty($value)) { + if(!is_array($value) && !is_object($value)) { + $array_other['object_'.$key] = $value; + } + if(is_array($value) && $recursive){ + $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false); + } + } + } + } + return $array_other; + } + + /** * Fill array with couple extrafield key => extrafield value * diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1339512b3af..ddfb2780f3f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -600,47 +600,63 @@ abstract class CommonObject $datecreate = dol_now(); - $this->db->begin(); + // Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error + $TListeContacts=$this->liste_contact(-1, $source); + $already_added=false; + if(!empty($TListeContacts)) { + foreach($TListeContacts as $array_contact) { + if($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) { + $already_added=true; + break; + } + } + } - // Insertion dans la base - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; - $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; - $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; - $sql.= "'".$this->db->idate($datecreate)."'"; - $sql.= ", 4, ". $id_type_contact; - $sql.= ")"; + if(!$already_added) { - $resql=$this->db->query($sql); - if ($resql) - { - if (! $notrigger) - { - $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); - if ($result < 0) + $this->db->begin(); + + // Insertion dans la base + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; + $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; + $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; + $sql.= "'".$this->db->idate($datecreate)."'"; + $sql.= ", 4, ". $id_type_contact; + $sql.= ")"; + + $resql=$this->db->query($sql); + if ($resql) + { + if (! $notrigger) { + $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + } + + $this->db->commit(); + return 1; + } + else + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $this->error=$this->db->errno(); + $this->db->rollback(); + echo 'err rollback'; + return -2; + } + else + { + $this->error=$this->db->error(); $this->db->rollback(); return -1; } - } - - $this->db->commit(); - return 1; - } - else - { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $this->error=$this->db->errno(); - $this->db->rollback(); - return -2; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + } + } else return 0; } /** @@ -4153,6 +4169,9 @@ abstract class CommonObject $optionsArray = $extrafields->attributes[$this->table_element]['label']; } + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + // Request to get complementary values if (count($optionsArray) > 0) { @@ -4164,7 +4183,7 @@ abstract class CommonObject $sql.= ", ".$name; } } - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; + $sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; $sql.= " WHERE fk_object = ".$rowid; dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); @@ -4210,7 +4229,10 @@ abstract class CommonObject { $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); $resql=$this->db->query($sql_del); if (! $resql) @@ -4316,11 +4338,14 @@ abstract class CommonObject } $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object"; foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix @@ -4630,18 +4655,17 @@ abstract class CommonObject /** * Get buy price to use for margin calculation. This function is called when buy price is unknown. - * set buy price = sell price if ForceBuyingPriceIfNull configured, + * Set buy price = sell price if ForceBuyingPriceIfNull configured, * else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice * else set min buy price as buy price * - * @param float $unitPrice product unit price - * @param float $discountPercent line discount percent - * @param int $fk_product product id - * - * @return float <0 if ko, buyprice if ok + * @param float $unitPrice Product unit price + * @param float $discountPercent Line discount percent + * @param int $fk_product Product id + * @return float <0 if KO, buyprice if OK */ - public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) + public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0) { global $conf; @@ -4710,6 +4734,9 @@ abstract class CommonObject return $buyPrice; } + + + /** * Function test if type is date * @@ -4718,7 +4745,7 @@ abstract class CommonObject */ protected function isDate($info) { - if(isset($info['type']) && $info['type']=='date') return true; + if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; else return false; } @@ -4864,40 +4891,6 @@ abstract class CommonObject return $query; } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function createCommon(User $user, $notrigger = false) - { - - $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); - - foreach ($fields as $k => $v) { - - $keys[] = $k; - $values[] = $this->quote($v); - - } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' - ( '.implode( ",", $keys ).' ) - VALUES ( '.implode( ",", $values ).' ) '; - $res = $this->db->query( $sql ); - if($res===false) { - - return false; - } - - // TODO Add triggers - - return true; - - } - /** * Function to load data into current object this * @@ -4905,39 +4898,39 @@ abstract class CommonObject */ private function set_vars_by_db(&$obj) { - foreach ($this->fields as $field => $info) - { - if($this->isDate($info)) - { - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; - else $this->{$field} = strtotime($obj->{$field}); - } - elseif($this->isArray($info)) - { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); - } - elseif($this->isInt($info)) - { - $this->{$field} = (int) $obj->{$field}; - } - elseif($this->isFloat($info)) - { - $this->{$field} = (double) $obj->{$field}; - } - elseif($this->isNull($info)) - { - $val = $obj->{$field}; - // zero is not null - $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); - } - else - { - $this->{$field} = $obj->{$field}; - } + foreach ($this->fields as $field => $info) + { + if($this->isDate($info)) + { + if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; + else $this->{$field} = strtotime($obj->{$field}); + } + elseif($this->isArray($info)) + { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); + } + elseif($this->isInt($info)) + { + $this->{$field} = (int) $obj->{$field}; + } + elseif($this->isFloat($info)) + { + $this->{$field} = (double) $obj->{$field}; + } + elseif($this->isNull($info)) + { + $val = $obj->{$field}; + // zero is not null + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); + } + else + { + $this->{$field} = $obj->{$field}; + } - } + } } /** @@ -4947,21 +4940,136 @@ abstract class CommonObject */ private function get_field_list() { - $keys = array_keys($this->fields); - return implode(',', $keys); + $keys = array_keys($this->fields); + return implode(',', $keys); + } + + /** + * Add quote to field value if necessary + * + * @param string|int $value value to protect + * @return string|int + */ + protected function quote($value) { + + if(is_null($value)) return 'NULL'; + else if(is_numeric($value)) return $value; + else return "'".$this->db->escape( $value )."'"; + + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function createCommon(User $user, $notrigger = false) + { + $error = 0; + + $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); + + $keys=array(); + $values = array(); + foreach ($fields as $k => $v) { + $keys[] = $k; + $values[] = $this->quote($v); + } + + $this->db->begin(); + + if (! $error) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' + ( '.implode( ",", $keys ).' ) + VALUES ( '.implode( ",", $values ).' ) '; + $res = $this->db->query( $sql ); + if ($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + if (! $error && ! $notrigger) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromCloneCommon(User $user, $fromid) + { + global $user; + + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->createCommon($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } } /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetchCommon($id, $ref = null) { - if (empty($id) && empty($ref)) return false; $sql = 'SELECT '.$this->get_field_list().', datec, tms'; @@ -4975,13 +5083,20 @@ abstract class CommonObject { if ($obj = $this->db->fetch_object($res)) { - $this->id = $id; - $this->set_vars_by_db($obj); + if ($obj) + { + $this->id = $id; + $this->set_vars_by_db($obj); - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); + $this->datec = $this->db->idate($obj->datec); + $this->tms = $this->db->idate($obj->tms); - return $this->id; + return $this->id; + } + else + { + return 0; + } } else { @@ -5003,15 +5118,15 @@ abstract class CommonObject * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function updateCommon(User $user, $notrigger = false) { + $error = 0; + $fields = $this->set_save_query(); foreach ($fields as $k => $v) { - if (is_array($key)){ $i=array_search($k, $key); if ( $i !== false) { @@ -5024,57 +5139,93 @@ abstract class CommonObject continue; } } - $tmp[] = $k.'='.$this->quote($v); } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ; - $res = $this->db->query( $sql ); - if($res===false) { - //error - return false; + $this->db->begin(); + + if (! $error) + { + $res = $this->db->query($sql); + if ($res===false) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } } - // TODO Add triggers + if (! $error && ! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_MODIFY',$user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } - return true; + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } } /** * Delete object in database * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ public function deleteCommon(User $user, $notrigger = false) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + $error=0; - $res = $this->db->query( $sql ); - if($res===false) { - return false; + $this->db->begin(); + + if (! $error) { + if (! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } + + if (! $error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; } - - // TODO Add triggers - - return true; } /** - * Add quote to field value if necessary + * Initialise object with example values + * Id must be 0 if object instance is a specimen * - * @param string|int $value value to protect - * @return string|int + * @return void */ - protected function quote($value) { - - if(is_null($value)) return 'NULL'; - else if(is_numeric($value)) return $value; - else return "'".$this->db->escape( $value )."'"; + public function initAsSpecimenCommon() + { + $this->id = 0; + // TODO... } } - diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index a7e404383ea..db768b4c630 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -52,13 +52,13 @@ class DolEditor * @param string $content Content of WYSIWIG field * @param int $width Width in pixel of edit area (auto by default) * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly') + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly', 'ace'). * @param string $toolbarlocation Where bar is stored : * 'In' each window has its own toolbar * 'Out:name' share toolbar into the div called 'name' * @param boolean $toolbarstartexpanded Bar is visible or not at start * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. - * @param int $okforextendededitor True=Allow usage of extended editor tool (like fckeditor) + * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like fckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. * @param int $rows Size of rows for textarea tool * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') * @param int $readonly 0=Read/Edit, 1=Read only @@ -80,8 +80,9 @@ class DolEditor $this->readonly=$readonly; // Check if extended editor is ok. If not we force textarea - if (empty($conf->fckeditor->enabled) || ! $okforextendededitor) $this->tool = 'textarea'; - if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // TODO ckeditor ko with jmobile + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; + if ($okforextendededitor === 'ace') $this->tool='ace'; + if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // TODO ckeditor ko with mobile ? ace ko with mobile ? // Define content and some properties if ($this->tool == 'ckeditor') @@ -100,7 +101,7 @@ class DolEditor $this->editor->Height = $height; if (! empty($width)) $this->editor->Width = $width; $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js - $this->editor->Config['AutoDetectLanguage'] = 'true'; + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; @@ -122,7 +123,7 @@ class DolEditor } // Define some properties - if (in_array($this->tool,array('textarea','ckeditor'))) + if (in_array($this->tool,array('textarea','ckeditor','ace'))) { $this->content = $content; $this->htmlname = $htmlname; @@ -141,11 +142,13 @@ class DolEditor * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) * * @param int $noprint 1=Return HTML string instead of printing it to output - * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });" - * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. + * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. + * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. + * @param string $titlecontent Show title content before editor area. Used by ACE editor only. + * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) * @return void|string */ - function Create($noprint=0,$morejs='',$disallowAnyContent=true) + function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='') { global $conf,$langs; @@ -160,7 +163,7 @@ class DolEditor if ($this->tool == 'fckeditor') // not used anymore { - $found=1; + $found=1; $this->editor->Create(); } if (in_array($this->tool,array('textarea','ckeditor'))) @@ -196,7 +199,7 @@ class DolEditor htmlEncodeOutput :'.$htmlencode_force.', allowedContent :'.($disallowAnyContent?'false':'true').', extraAllowedContent : \'\', - fullPage : '.($fullpage?'true':'false').', + fullPage : '.($fullpage?'true':'false').', toolbar: \''.$this->toolbarname.'\', toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').', width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').', @@ -242,11 +245,84 @@ class DolEditor filebrowserImageWindowHeight : \'500\''; } $out.= ' })'.$morejs; - $out.= '}); - '; + $out.= '});'."\n"; + $out.= ''."\n"; } } + // Output editor ACE + // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. + if (preg_match('/^ace/', $this->tool)) + { + $found=1; + $format=$option; + + $out.= "\n".''."\n"; + + if ($titlecontent) + { + $out.= '
'.$titlecontent; + $out.= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; + $out.= '
'; + $out.= ''."\n"; + } + + $out.= '
$/'), array('<?php','?>'), $this->content); */
+        	$out.= htmlentities($this->content);
+        	$out.= '
'; + $out.= ''; + + $out.= ''."\n"; + } + if (empty($found)) { $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4b5f151ec72..e44fa8a5aec 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -197,6 +197,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/",$attrname) && ! is_numeric($attrname)) { @@ -350,6 +351,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; $error=0; @@ -460,6 +462,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e291277d8e4..06736ba5c5f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke @@ -5604,6 +5604,14 @@ class Form { $listofidcompanytoscan=$object->thirdparty->id; if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent; + if (($object->fk_project > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) + { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpproject=new Project($this->db); + $tmpproject->fetch($object->fk_project); + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan.=','.$tmpproject->socid; + unset($tmpproject); + } $possiblelinks=array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), @@ -5845,11 +5853,11 @@ class Form * @param string $morehtmlright More html code to show after ref. * @return string Portion HTML with ref + navigation buttons */ - function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') - { - global $langs,$conf,$hookmanager; + function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') + { + global $langs,$conf,$hookmanager; - $ret=''; + $ret=''; if (empty($fieldid)) $fieldid='rowid'; if (empty($fieldref)) $fieldref='ref'; @@ -5880,10 +5888,10 @@ class Form // Right part of banner if ($morehtmlright) $ret.='
'.$morehtmlright.'
'; - if ($previous_ref || $next_ref || $morehtml) - { - $ret.='