diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 6b9256102d9..6a530bbd2eb 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -69,14 +69,15 @@ else $result=restrictedArea($user,'banque'); } -$search_ref=GETPOST('search_ref','alpha'); $description=GETPOST("description",'alpha'); +$dateop = dol_mktime(12,0,0,GETPOST("opmonth",'int'),GETPOST("opday",'int'),GETPOST("opyear",'int')); $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_ref=GETPOST('search_ref','alpha'); $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')); $search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int')); @@ -85,9 +86,9 @@ $search_thirdparty=GETPOST("thirdparty",'alpha'); $search_req_nb=GETPOST("req_nb",'alpha'); $search_num_releve=GETPOST("search_num_releve",'alpha'); $search_conciliated=GETPOST("search_conciliated",'int'); -$num_releve=GETPOST("num_releve"); +$num_releve=GETPOST("num_releve","alpha"); $cat=GETPOST("cat"); - +if (empty($dateop)) $dateop=-1; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -253,9 +254,7 @@ if (GETPOST('confirm_reconcile') && $user->rights->banque->consolidate) } -$dateop=-1; - -if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) +if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) { $error = 0; @@ -268,27 +267,34 @@ 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 = GETPOST("operation",'alpha'); $num_chq = GETPOST("num_chq",'alpha'); $label = GETPOST("label",'alpha'); $cat1 = GETPOST("cat1",'alpha'); + $bankaccountid = $id; + if (GETPOST('add_account','int') > 0) $bankaccountid = GETPOST('add_account','int'); + if (! $dateop) { $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } if (! $operation) { $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } if (! $label) { $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Label")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); } if (! $amount) { $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); + } + if (! $bankaccountid > 0) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); } /*if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1')) { @@ -298,12 +304,13 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) if (! $error) { - $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); + $objecttmp = new Account($db); + $objecttmp->fetch($bankaccountid); + $insertid = $objecttmp->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + header("Location: ".$_SERVER['PHP_SELF'].($id ? "?id=".$id : '')); exit; } else @@ -630,12 +637,17 @@ if ($resql) print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; + //if (! $account > 0) + //{ + print ''; + //} print ''; print ''; /*if (! empty($conf->accounting->enabled)) @@ -644,33 +656,42 @@ if ($resql) print $langs->trans("AccountAccounting"); print ''; }*/ - print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + //if (! $account > 0) + //{ + print ''; + //} + print ''; + print ''; /*if (! empty($conf->accounting->enabled)) { print ''; }*/ - print ''; @@ -710,29 +731,32 @@ if ($resql) $morehtml.=''; $addbutton = ''; - if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) + if ($action != 'addline') { - if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments + if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - if ($user->rights->banque->modifier) { - $addbutton = ''.$langs->trans("AddBankRecord").''; - } else { - $addbutton = ''.$langs->trans("AddBankRecord").''; + if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + $addbutton = ''.$langs->trans("AddBankRecord").''; + } else { + $addbutton = ''.$langs->trans("AddBankRecord").''; + } + } + else // If direct entries is not done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + $addbutton = ''.$langs->trans("AddBankRecord").''; + } else { + $addbutton = ''.$langs->trans("AddBankRecord").''; + } } } - else // If direct entries is not done using miscellaneous payments + else { - if ($user->rights->banque->modifier) { - $addbutton = ''.$langs->trans("AddBankRecord").''; - } else { - $addbutton = ''.$langs->trans("AddBankRecord").''; - } + $addbutton = ''.$langs->trans("AddBankRecord").''; } } - else - { - $addbutton = ''.$langs->trans("AddBankRecord").''; - } $morehtml.=$addbutton; $picto='title_bank';
'.$langs->trans("Description").''.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("BankAccount").''.$langs->trans("Debit").''.$langs->trans("Credit").'  
'; - $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 ''; + print '
'; + print ''; if ($options) { print '
'.$langs->trans("Rubrique").': '; print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); } 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 ''; + $form->select_comptes(GETPOST('add_account','int')?GETPOST('add_account','int'):$account,'add_account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); + print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print ''; + print ''; print '
'; print ''; print '