--- /tmp/dsg/dolibarr/htdocs/compta/paiement/cheque/github_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/cheque/client_card.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018 Frédéric France * * 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 @@ -38,7 +38,7 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check @@ -46,8 +46,8 @@ if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$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"; @@ -57,7 +57,7 @@ $dir = $conf->bank->dir_output.'/checkdeposits/'; $filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear')); -$filteraccountid = GETPOST('accountid', 'int'); +$filteraccountid = GETPOST('accountid'); $object = new RemiseCheque($db); @@ -68,37 +68,41 @@ 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) - { + $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'); - } + } + } + 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'); - } + $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) @@ -113,7 +117,9 @@ { setEventMessages($object->error, $object->errors, 'errors'); } - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -125,42 +131,48 @@ $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 { + 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 + { setEventMessages($object->error, $object->errors, 'errors'); } - } else { + } + else + { setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs'); - $action = 'new'; - } -} - -if ($action == 'remove' && $id > 0 && GETPOST("lineid", 'int') > 0 && $user->rights->banque->cheque) + $action = 'new'; + } +} + +if ($action == 'remove' && $id > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque) { $object->id = $id; - $result = $object->removeCheck(GETPOST("lineid", "int")); + $result = $object->removeCheck($_GET["lineid"]); if ($result === 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -173,32 +185,36 @@ { header("Location: index.php"); exit; - } else { + } + else + { setEventMessages($paiement->error, $paiement->errors, 'errors'); } } -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->banque->cheque) +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->cheque) { $result = $object->fetch($id); $result = $object->validate($user); 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); + // 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); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -206,7 +222,7 @@ if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->banque->cheque) { $reject_date = dol_mktime(0, 0, 0, GETPOST('rejectdate_month'), GETPOST('rejectdate_day'), GETPOST('rejectdate_year')); - $rejected_check = GETPOST('bankid', 'int'); + $rejected_check = GETPOST('bankid'); $object->fetch($id); $paiement_id = $object->rejectCheck($rejected_check, $reject_date); @@ -216,7 +232,9 @@ //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id); //exit; $action = ''; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } @@ -229,25 +247,29 @@ // Save last template used to generate document //if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - $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); - } + $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) { dol_print_error($db, $object->error); exit; - } else { + } + else + { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); exit; } -} // Remove file in doc form +} + +// Remove file in doc form elseif ($action == 'remove_file' && $user->rights->banque->cheque) { if ($object->fetch($id) > 0) @@ -270,8 +292,8 @@ if (GETPOST('removefilter')) { - $filterdate = ''; - $filteraccountid = 0; + $filterdate = ''; + $filteraccountid = 0; } $title = $langs->trans("Cheques")." - ".$langs->trans("Card"); @@ -292,7 +314,9 @@ $h++; print load_fiche_titre($langs->trans("Cheques"), '', 'bank_account'); -} else { +} +else +{ $result = $object->fetch($id, $ref); if ($result < 0) { @@ -309,10 +333,10 @@ // $head[$h][1] = $langs->trans("Info"); // $h++; - print dol_get_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); + dol_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); /* - * Confirmation of slip's delete + * Confirmation de la suppression du bordereau */ if ($action == 'delete') { @@ -320,11 +344,11 @@ } /* - * Confirmation of slip's validation + * Confirmation de la validation du bordereau */ if ($action == 'valide') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide', '', '', 1); } /* @@ -333,7 +357,7 @@ if ($action == 'reject_check') { $formquestion = array( - array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid', 'int')), + array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid')), array('type' => 'date', 'name' => 'rejectdate_', 'label' => $langs->trans("RejectCheckDate"), 'value' => dol_now()) ); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("RejectCheck"), $langs->trans("ConfirmRejectCheck"), 'confirm_reject_check', $formquestion, '', 1); @@ -357,7 +381,7 @@ print ''; print ''; - print dol_get_fiche_head(); + dol_fiche_head(); print ''; //print ''; @@ -365,28 +389,27 @@ print ''; - print ''; + print ''; print '
'.$langs->trans('Date').''.dol_print_date($now,'day').'
'.$langs->trans("DateChequeReceived").''; print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1); print '
'.$langs->trans("BankAccount").''; - $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1); - print '
'.$langs->trans("BankAccount").''; + $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1); + print '
'; - print dol_get_fiche_end(); - - print '
'; + dol_fiche_end(); + + print '
'; print ''; - if ($filterdate || $filteraccountid > 0) - { - print '   '; - print ''; - } + if ($filterdate || $filteraccountid > 0) + { + print '   '; + print ''; + } print '
'; - print ''; + print ''; 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"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)"; @@ -395,7 +418,7 @@ $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.amount > 0"; if ($filterdate) $sql .= " AND b.dateo = '".$db->idate($filterdate)."'"; - if ($filteraccountid > 0) $sql .= " AND ba.rowid = ".((int) $filteraccountid); + if ($filteraccountid > 0) $sql .= " AND ba.rowid= '".$filteraccountid."'"; $sql .= $db->order("b.dateo,b.rowid", "ASC"); $resql = $db->query($sql); @@ -411,10 +434,7 @@ $lines[$obj->bid][$i]["numero"] = $obj->num_chq; $lines[$obj->bid][$i]["banque"] = $obj->banque; $lines[$obj->bid][$i]["id"] = $obj->transactionid; - $lines[$obj->bid][$i]["ref"] = $obj->transactionid; - $lines[$obj->bid][$i]["label"] = $obj->transactionlabel; $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid; - $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref; $i++; } @@ -426,7 +446,7 @@ foreach ($accounts as $bid => $account_label) { - print ' + print '