Task #11003: checkbox on checks to deposit
This commit is contained in:
parent
38b3518df5
commit
6732c12910
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -117,9 +118,10 @@ class RemiseCheque extends CommonObject
|
||||
* @param user User making creation
|
||||
* @param account_id Bank account for cheque receipt
|
||||
* @param limit Limit number of cheque to this
|
||||
* @param toRemise array with cheques to remise
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function create($user, $account_id, $limit=40)
|
||||
function create($user, $account_id, $limit=40,$toRemise)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -207,19 +209,28 @@ class RemiseCheque extends CommonObject
|
||||
}
|
||||
|
||||
if ($this->id > 0 && $this->errno == 0)
|
||||
{
|
||||
{
|
||||
foreach ($lines as $lineid)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " SET fk_bordereau = ".$this->id;
|
||||
$sql.= " WHERE rowid = ".$lineid;
|
||||
|
||||
dol_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
$checkremise=false;
|
||||
foreach ($toRemise as $linetoremise)
|
||||
{
|
||||
$this->errno = -18;
|
||||
dol_syslog("RemiseCheque::Create Error update bank ".$this->errno, LOG_ERR);
|
||||
if($linetoremise==$lineid) $checkremise=true;
|
||||
}
|
||||
|
||||
if($checkremise==true)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " SET fk_bordereau = ".$this->id;
|
||||
$sql.= " WHERE rowid = ".$lineid;
|
||||
|
||||
dol_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errno = -18;
|
||||
dol_syslog("RemiseCheque::Create Error update bank ".$this->errno, LOG_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,42 +84,42 @@ if ($_POST['action'] == 'setdate' && $user->rights->banque->cheque)
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banque->cheque)
|
||||
if ($_POST['action'] == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque)
|
||||
{
|
||||
|
||||
$remisecheque = new RemiseCheque($db);
|
||||
//$result = $remisecheque->create($user, $_GET["accountid"], 0);
|
||||
|
||||
if (is_array($_POST['toRemise']))
|
||||
$result = $remisecheque->create($user, $_GET["accountid"], 0); // $result = $remisecheque->create($user, $_GET["accountid"], 0, $_POST['toRemise']);
|
||||
|
||||
else
|
||||
$result = $remisecheque->create($user, $_GET["accountid"], 0);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($remisecheque->statut == 1) // If statut is validated, we build doc
|
||||
{
|
||||
$remisecheque->fetch($remisecheque->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 = $remisecheque->generatePdf($_POST["model"], $outputlangs);
|
||||
}
|
||||
$remisecheque = new RemiseCheque($db);
|
||||
$result = $remisecheque->create($user, $_POST["accountid"], 0, $_POST['toRemise']);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($remisecheque->statut == 1) // If statut is validated, we build doc
|
||||
{
|
||||
$remisecheque->fetch($remisecheque->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 = $remisecheque->generatePdf($_POST["model"], $outputlangs);
|
||||
}
|
||||
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
|
||||
exit;
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$remisecheque->error.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$remisecheque->error.'</div>';
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]."?action=new");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,7 +343,11 @@ if ($_GET['action'] == 'new')
|
||||
foreach ($accounts as $bid => $account_label)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="create">';
|
||||
print '<input type="hidden" name="accountid" value="'.$bid.'">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td style="min-width: 120px">'.$langs->trans("DateChequeReceived")." </td>\n";
|
||||
@ -384,13 +388,14 @@ if ($_GET['action'] == 'new')
|
||||
print '<div class="tabsAction">';
|
||||
if ($user->rights->banque->cheque)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create&accountid='.$bid.'">'.$langs->trans('NewCheckDepositOn',$account_label).'</a>';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('NewCheckDepositOn',$account_label).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn',$account_label).'</a>';
|
||||
}
|
||||
print '</div><br>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user