--- /tmp/dsg/dolibarr/htdocs/compta/paiement/cheque/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/cheque/client_card.php @@ -8 +8 @@ - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018 Frédéric France @@ -30 +29,0 @@ -// Load Dolibarr environment @@ -42 +41 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -44,35 +42,0 @@ - -$type = GETPOST('type'); -if (empty($type)) { - $type = 'CHQ'; -} - -$object = new RemiseCheque($db); - -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "b.dateo,b.rowid"; -} -if (empty($page) || $page == -1) { - $page = 0; -} -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$offset = $limit * $page; - -$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits"; - -// filter by dates from / to -$search_date_start_day = GETPOST('search_date_start_day', 'int'); -$search_date_start_month = GETPOST('search_date_start_month', 'int'); -$search_date_start_year = GETPOST('search_date_start_year', 'int'); -$search_date_end_day = GETPOST('search_date_end_day', 'int'); -$search_date_end_month = GETPOST('search_date_end_month', 'int'); -$search_date_end_year = GETPOST('search_date_end_year', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year); -$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year); -$filteraccountid = GETPOST('accountid', 'int'); @@ -82,3 +46 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -87,9 +49,14 @@ -$usercanread = $user->rights->banque->cheque; -$usercancreate = $user->rights->banque->cheque; -$usercandelete = $user->rights->banque->cheque; - -$permissiontodelete = $user->rights->banque->cheque; - -// List of payment mode to support -// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' -$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "b.dateo,b.rowid"; +if (empty($page) || $page == -1) { $page = 0; } +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$offset = $limit * $page; + +$dir = $conf->bank->dir_output.'/checkdeposits/'; +$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear')); +$filteraccountid = GETPOST('accountid'); + +$object = new RemiseCheque($db); @@ -102 +69,41 @@ -if ($action == 'setdate' && $user->hasRight('banque', 'cheque')) { +if ($action == 'setdate' && $user->rights->banque->cheque) +{ + $result = $object->fetch(GETPOST('id', 'int')); + if ($result > 0) + { + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date = dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']); + + $result = $object->set_date($user, $date); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +if ($action == 'setrefext' && $user->rights->banque->cheque) +{ + $result = $object->fetch(GETPOST('id', 'int')); + if ($result > 0) + { + $ref_ext = GETPOST('ref_ext'); + + $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +if ($action == 'setref' && $user->rights->banque->cheque) +{ @@ -104,5 +111,7 @@ - if ($result > 0) { - $date = dol_mktime(0, 0, 0, GETPOST('datecreate_month', 'int'), GETPOST('datecreate_day', 'int'), GETPOST('datecreate_year', 'int')); - - $result = $object->set_date($user, $date); - if ($result < 0) { + if ($result > 0) + { + $ref = GETPOST('ref'); + + $result = $object->set_number($user, $ref); + if ($result < 0) + { @@ -111 +120,3 @@ - } else { + } + else + { @@ -116,7 +127,28 @@ -if ($action == 'setrefext' && $user->hasRight('banque', 'cheque')) { - $result = $object->fetch(GETPOST('id', 'int')); - if ($result > 0) { - $ref_ext = GETPOST('ref_ext'); - - $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY'); - if ($result < 0) { +if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque) +{ + if (is_array($_POST['toRemise'])) + { + $result = $object->create($user, $_POST["accountid"], 0, $_POST['toRemise']); + if ($result > 0) + { + if ($object->statut == 1) // If statut is validated, we build doc + { + $object->fetch($object->id); // To force to reload all properties in correct property name + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = $object->generatePdf($_POST["model"], $outputlangs); + } + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + exit; + } + else + { @@ -125,48 +157,3 @@ - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == 'setref' && $user->hasRight('banque', 'cheque')) { - $result = $object->fetch(GETPOST('id', 'int')); - if ($result > 0) { - $ref = GETPOST('ref'); - - $result = $object->set_number($user, $ref); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->hasRight('banque', 'cheque')) { - if (GETPOSTISARRAY('toRemise')) { - $object->type = $type; - $arrayofid = GETPOST('toRemise', 'array:int'); - - $result = $object->create($user, GETPOST("accountid", "int"), 0, $arrayofid); - if ($result > 0) { - if ($object->statut == 1) { // If statut is validated, we build doc - $object->fetch($object->id); // To force to reload all properties in correct property name - // Define output language - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generatePdf(GETPOST("model"), $outputlangs); - } - - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { + } + else + { @@ -174,5 +161,6 @@ - $action = 'new'; - } -} - -if ($action == 'remove' && $id > 0 && GETPOST("lineid", 'int') > 0 && $user->hasRight('banque', 'cheque')) { + $action = 'new'; + } +} + +if ($action == 'remove' && $id > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque) +{ @@ -180,2 +168,3 @@ - $result = $object->removeCheck(GETPOST("lineid", "int")); - if ($result === 0) { + $result = $object->removeCheck($_GET["lineid"]); + if ($result === 0) + { @@ -184 +173,3 @@ - } else { + } + else + { @@ -189 +180,2 @@ -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->cheque) +{ @@ -191,2 +183,3 @@ - $result = $object->delete($user); - if ($result == 0) { + $result = $object->delete(); + if ($result == 0) + { @@ -195 +188,3 @@ - } else { + } + else + { @@ -200 +195,2 @@ -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) { +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->cheque) +{ @@ -203,15 +199,15 @@ - if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generatePdf(GETPOST('model'), $outputlangs); - - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = $object->generatePdf(GETPOST('model'), $outputlangs); + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); @@ -219 +215,3 @@ - } else { + } + else + { @@ -224 +222,2 @@ -if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) { +if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->banque->cheque) +{ @@ -226 +225 @@ - $rejected_check = GETPOST('bankid', 'int'); + $rejected_check = GETPOST('bankid'); @@ -230 +229,2 @@ - if ($paiement_id > 0) { + if ($paiement_id > 0) + { @@ -235 +235,3 @@ - } else { + } + else + { @@ -241 +243,2 @@ -if ($action == 'builddoc' && $user->hasRight('banque', 'cheque')) { +if ($action == 'builddoc' && $user->rights->banque->cheque) +{ @@ -247,12 +250,12 @@ - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generatePdf(GETPOST("model"), $outputlangs); - if ($result <= 0) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = $object->generatePdf($_POST["model"], $outputlangs); + if ($result <= 0) + { @@ -261,2 +264,4 @@ - } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(!getDolGlobalString('MAIN_JUMP_TAG') ? '' : '#builddoc')); + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); @@ -265,3 +270,7 @@ -} elseif ($action == 'remove_file' && $user->hasRight('banque', 'cheque')) { - // Remove file in doc form - if ($object->fetch($id) > 0) { +} + +// Remove file in doc form +elseif ($action == 'remove_file' && $user->rights->banque->cheque) +{ + if ($object->fetch($id) > 0) + { @@ -272,3 +281 @@ - $filetodelete = GETPOST('file', 'alpha'); - $file = $upload_dir.'/'.$filetodelete; - + $file = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque').GETPOST('file'); @@ -276,5 +283,2 @@ - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); - } + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); @@ -289,23 +293,7 @@ -if (GETPOST('removefilter')) { - // filter by dates from / to - $search_date_start_day = ''; - $search_date_start_month = ''; - $search_date_start_year = ''; - $search_date_end_day = ''; - $search_date_end_month = ''; - $search_date_end_year = ''; - $search_date_start = ''; - $search_date_end = ''; - $filteraccountid = 0; -} - -if ($action == 'new') { - $title = $langs->trans("NewChequeDeposit"); -} else { - if ($type == 'CHQ') { - $title = $langs->trans("Cheques"); - } else { - $title = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $langs->trans("PaymentMode").' '.$type); - } -} - +if (GETPOST('removefilter')) +{ + $filterdate = ''; + $filteraccountid = 0; +} + +$title = $langs->trans("Cheques")." - ".$langs->trans("Card"); @@ -319 +307,2 @@ -if ($action == 'new') { +if ($action == 'new') +{ @@ -327,2 +316,4 @@ - print load_fiche_titre($title, '', 'bank_account'); -} else { + print load_fiche_titre($langs->trans("Cheques"), '', 'bank_account'); +} +else +{ @@ -330 +321,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -344 +336 @@ - print dol_get_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); + dol_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); @@ -347 +339 @@ - * Confirmation of slip's delete + * Confirmation de la suppression du bordereau @@ -349 +341,2 @@ - if ($action == 'delete') { + if ($action == 'delete') + { @@ -354 +347 @@ - * Confirmation of slip's validation + * Confirmation de la validation du bordereau @@ -356,2 +349,3 @@ - if ($action == 'valide') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1); + if ($action == 'valide') + { + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide', '', '', 1); @@ -363 +357,2 @@ - if ($action == 'reject_check') { + if ($action == 'reject_check') + { @@ -365 +360 @@ - array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid', 'int')), + array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid')), @@ -374 +369,2 @@ -if ($action == 'new') { +if ($action == 'new') +{ @@ -382,6 +378 @@ - $labeltype = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $type); - if ($type == 'CHQ') { - print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; - } else { - print ''.$langs->trans("SelectPaymentTransactionAndGenerate", $labeltype).'

'."\n"; - } + print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; @@ -393 +384 @@ - print dol_get_fiche_head(); + dol_fiche_head(); @@ -396,25 +387,19 @@ - - if (count($arrayofpaymentmodetomanage) > 1) { - $arrayoflabels = array(); - foreach ($arrayofpaymentmodetomanage as $key => $val) { - $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); - $arrayoflabels[$key] = $labelval; - } - // Type - print ''; - print $langs->trans("Type"); - print ''; - print $form->selectarray('type', $arrayoflabels, $type); - print ''; - } - // Date - print ''; - if ($type == 'CHQ') { - print $langs->trans("DateChequeReceived"); - } else { - print $langs->trans("DatePaymentReceived"); - } - print ''; - // filter by dates from / to - print '
'; - print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From')); + //print ''.$langs->trans('Date').''.dol_print_date($now,'day').''; + // Filter + print ''.$langs->trans("DateChequeReceived").''; + print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1); + print ''; + print ''.$langs->trans("BankAccount").''; + $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1); + print ''; + print ''; + + dol_fiche_end(); + + print '
'; + print ''; + if ($filterdate || $filteraccountid > 0) + { + print '   '; + print ''; + } @@ -422,19 +407 @@ - print '
'; - print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print ''; - print ''.$langs->trans("BankAccount").''; - $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1); - print ''; - print ''; - - print dol_get_fiche_end(); - - print '
'; - print ''; - if ($search_date_start || $search_date_end || $filteraccountid > 0) { - print '   '; - print ''; - } - print '
'; - print ''; + print ''; @@ -442,6 +409,4 @@ - print '
'; - - $sql = "SELECT ba.rowid as bid, ba.label,"; - $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, "; - $sql .= " b.amount, b.emetteur, b.num_chq, b.banque,"; - $sql .= " p.rowid as paymentid, p.ref as paymentref"; + + $sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, "; + $sql .= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,"; + $sql .= " p.rowid as paymentid"; @@ -451 +416 @@ - $sql .= " WHERE b.fk_type = '".$db->escape($type)."'"; + $sql .= " WHERE b.fk_type = 'CHQ'"; @@ -455,9 +420,2 @@ - if ($search_date_start) { - $sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'"; - } - if ($search_date_end) { - $sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'"; - } - if ($filteraccountid > 0) { - $sql .= " AND ba.rowid = ".((int) $filteraccountid); - } + if ($filterdate) $sql .= " AND b.dateo = '".$db->idate($filterdate)."'"; + if ($filteraccountid > 0) $sql .= " AND ba.rowid= '".$filteraccountid."'"; @@ -467 +425,2 @@ - if ($resql) { + if ($resql) + { @@ -469 +428,2 @@ - while ($obj = $db->fetch_object($resql)) { + while ($obj = $db->fetch_object($resql)) + { @@ -471 +431 @@ - $lines[$obj->bid][$i]["date"] = $db->jdate($obj->datec); + $lines[$obj->bid][$i]["date"] = $db->jdate($obj->date); @@ -477,2 +436,0 @@ - $lines[$obj->bid][$i]["ref"] = $obj->transactionid; - $lines[$obj->bid][$i]["label"] = $obj->transactionlabel; @@ -480,2 +437,0 @@ - $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref; - $lines[$obj->bid][$i]["paymentdate"] = $db->jdate($obj->date); @@ -485,6 +441,3 @@ - if ($i == 0) { - if ($type == 'CHQ') { - print '
'.$langs->trans("NoWaitingChecks").'

'; - } else { - print '
'.$langs->trans("NoWaitingPaymentForDeposit", $labeltype).'

'; - } + if ($i == 0) + { + print '
'.$langs->trans("NoWaitingChecks").'

'; @@ -494,3 +447,4 @@ - foreach ($accounts as $bid => $account_label) { - print ' -