--- /tmp/dsg/dolibarr/htdocs/compta/paiement/github_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/paiement/client_card.php @@ -39,24 +39,16 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$object = new Paiement($db); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -$result = restrictedArea($user, $object->element, $object->id, 'paiement', ''); - // Security check if ($user->socid) $socid = $user->socid; -// Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice. -// It should be enough because all payments are done on invoices of the same thirdparty. -if ($socid && $socid != $object->thirdparty->id) { - accessforbidden(); -} +// TODO ajouter regle pour restreindre acces paiement +//$result = restrictedArea($user, 'facture', $id,''); + +$object = new Paiement($db); /* @@ -65,48 +57,57 @@ if ($action == 'setnote' && $user->rights->facture->paiement) { + $db->begin(); + + $object->fetch($id); + $result = $object->update_note(GETPOST('note', 'none')); + if ($result > 0) + { + $db->commit(); + $action = ''; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } +} + +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) +{ $db->begin(); - $result = $object->update_note(GETPOST('note', 'restricthtml')); - if ($result > 0) - { - $db->commit(); - $action = ''; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } -} - -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) -{ - $db->begin(); - + $object->fetch($id); $result = $object->delete(); if ($result > 0) { - $db->commit(); - - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: list.php"); - exit; - } - } else { - $langs->load("errors"); + $db->commit(); + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: list.php"); + exit; + } + } + else + { + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } -} - -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement) + $db->rollback(); + } +} + +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->paiement) { $db->begin(); - if ($object->validate($user) > 0) + $object->fetch($id); + if ($object->valide($user) > 0) { $db->commit(); @@ -130,8 +131,10 @@ header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); exit; - } else { - $langs->load("errors"); + } + else + { + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -139,23 +142,29 @@ if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) { - $res = $object->update_num($_POST['num_paiement']); + $object->fetch($id); + $res = $object->update_num($_POST['num_paiement']); if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); - } else { + } + else + { setEventMessages($langs->trans('PaymentNumberUpdateFailed'), null, 'errors'); } } if ($action == 'setdatep' && !empty($_POST['datepday'])) { + $object->fetch($id); $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); if ($res === 0) { setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); - } else { + } + else + { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } @@ -180,19 +189,19 @@ $head = payment_prepare_head($object); -print dol_get_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); - -// Confirmation of payment delete +dol_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); + +// Confirmation de la suppression du paiement if ($action == 'delete') { print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } -// Confirmation of payment validation +// Confirmation de la validation du paiement if ($action == 'valide') { $facid = $_GET['facid']; - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2); } $linkback = ''.$langs->trans("BackToList").''; @@ -268,8 +277,10 @@ // Bank account if (!empty($conf->banque->enabled)) { - if ($object->fk_account > 0) { - if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) { + if ($object->fk_account > 0) + { + if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) + { dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php'); $bordereau = new RemiseCheque($db); $bordereau->fetch($bankline->fk_bordereau); @@ -286,12 +297,7 @@ print '
'.$langs->trans("Reporting").' | '; - print ''.$langs->trans("Size").' | '; - print ''.$langs->trans("Date").' | '; - print '
'.$langs->trans("Reporting").' | '; + print ''.$langs->trans("Size").' | '; + print ''.$langs->trans("Date").' | '; + print '
'.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).' | '; - print ''.dol_print_size(dol_filesize($tfile)).' | '; - print ''.dol_print_date(dol_filemtime($tfile), "dayhour").' | '; - print '
'.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.' | '; - print ''.dol_print_date($db->jdate($objp->dp), 'day')." | \n"; - print "$objp->paiement_type $objp->num_payment | \n"; - print ''.price($objp->amount).' | '; - print ''; + print ' |
'.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.' | '; + print ''.dol_print_date($db->jdate($objp->dp), 'day')." | \n"; + print "$objp->paiement_type $objp->num_payment | \n"; + print ''.price($objp->amount).' | '; + print ''; - if ($objp->statut == 0) - { - print ''.$langs->trans("PaymentStatusToValidShort").''; - } else { - print "-"; - } + if ($objp->statut == 0) + { + print ''.$langs->trans("PaymentStatusToValidShort").''; + } + else + { + print "-"; + } - print ' | '; - print "