Skip to content

Commit

Permalink
Fix missing hook
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-ph committed Jul 19, 2019
1 parent 9b8b3b1 commit a03bb00
Showing 1 changed file with 73 additions and 65 deletions.
138 changes: 73 additions & 65 deletions htdocs/compta/prelevement/card.php
Expand Up @@ -63,78 +63,86 @@
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals

$hookmanager->initHooks(array('directdebitprevcard','globalcard'));

/*
* Actions
*/

if ( $action == 'confirm_delete' )
{
$res=$object->delete($user);
if ($res > 0)
{
header("Location: index.php");
exit;
}
}

// Seems to no be used and replaced with $action == 'infocredit
if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes')
{
$res=$object->set_credite();
if ($res >= 0)
{
header("Location: card.php?id=".$id);
exit;
}
}

if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

$dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));

/*
if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
{
$dir = $conf->prelevement->dir_output.'/receipts';
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
{
$object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
}
header("Location: card.php?id=".$id);
exit;
}
else
{
dol_syslog("Fichier invalide",LOG_WARNING);
$mesg='BadFile';
}*/

$error = $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
$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');

if ($error)
{
header("Location: card.php?id=".$id."&error=$error");
exit;
}
}

// Set direct debit order to credited, create payment and close invoices
if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
if (empty($reshook))
{
$dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));

$error = $object->set_infocredit($user, $dt);

if ($error)
{
header("Location: card.php?id=".$id."&error=$error");
exit;
}
if ( $action == 'confirm_delete' )
{
$res=$object->delete($user);
if ($res > 0)
{
header("Location: index.php");
exit;
}
}

// Seems to no be used and replaced with $action == 'infocredit
if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes')
{
$res=$object->set_credite();
if ($res >= 0)
{
header("Location: card.php?id=".$id);
exit;
}
}

if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

$dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));

/*
if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
{
$dir = $conf->prelevement->dir_output.'/receipts';
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
{
$object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
}
header("Location: card.php?id=".$id);
exit;
}
else
{
dol_syslog("Fichier invalide",LOG_WARNING);
$mesg='BadFile';
}*/

$error = $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));

if ($error)
{
header("Location: card.php?id=".$id."&error=$error");
exit;
}
}

// Set direct debit order to credited, create payment and close invoices
if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
{
$dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));

$error = $object->set_infocredit($user, $dt);

if ($error)
{
header("Location: card.php?id=".$id."&error=$error");
exit;
}
}
}


Expand Down

0 comments on commit a03bb00

Please sign in to comment.