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) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* 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
|
* 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
|
* 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 user User making creation
|
||||||
* @param account_id Bank account for cheque receipt
|
* @param account_id Bank account for cheque receipt
|
||||||
* @param limit Limit number of cheque to this
|
* @param limit Limit number of cheque to this
|
||||||
|
* @param toRemise array with cheques to remise
|
||||||
* @return int <0 if KO, >0 if OK
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
@ -207,19 +209,28 @@ class RemiseCheque extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->id > 0 && $this->errno == 0)
|
if ($this->id > 0 && $this->errno == 0)
|
||||||
{
|
{
|
||||||
foreach ($lines as $lineid)
|
foreach ($lines as $lineid)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bank";
|
$checkremise=false;
|
||||||
$sql.= " SET fk_bordereau = ".$this->id;
|
foreach ($toRemise as $linetoremise)
|
||||||
$sql.= " WHERE rowid = ".$lineid;
|
|
||||||
|
|
||||||
dol_syslog("RemiseCheque::Create sql=".$sql, LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if (!$resql)
|
|
||||||
{
|
{
|
||||||
$this->errno = -18;
|
if($linetoremise==$lineid) $checkremise=true;
|
||||||
dol_syslog("RemiseCheque::Create Error update bank ".$this->errno, LOG_ERR);
|
}
|
||||||
|
|
||||||
|
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']))
|
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 = new RemiseCheque($db);
|
||||||
{
|
$result = $remisecheque->create($user, $_POST["accountid"], 0, $_POST['toRemise']);
|
||||||
$remisecheque->fetch($remisecheque->id); // To force to reload all properties in correct property name
|
if ($result > 0)
|
||||||
// Define output language
|
{
|
||||||
$outputlangs = $langs;
|
if ($remisecheque->statut == 1) // If statut is validated, we build doc
|
||||||
$newlang='';
|
{
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
$remisecheque->fetch($remisecheque->id); // To force to reload all properties in correct property name
|
||||||
//if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
// Define output language
|
||||||
if (! empty($newlang))
|
$outputlangs = $langs;
|
||||||
{
|
$newlang='';
|
||||||
$outputlangs = new Translate("",$conf);
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||||
$outputlangs->setDefaultLang($newlang);
|
//if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||||
}
|
if (! empty($newlang))
|
||||||
$result = $remisecheque->generatePdf($_POST["model"], $outputlangs);
|
{
|
||||||
}
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$result = $remisecheque->generatePdf($_POST["model"], $outputlangs);
|
||||||
|
}
|
||||||
|
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
|
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id);
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$remisecheque->error.'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
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)
|
foreach ($accounts as $bid => $account_label)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$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 '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td style="min-width: 120px">'.$langs->trans("DateChequeReceived")." </td>\n";
|
print '<td style="min-width: 120px">'.$langs->trans("DateChequeReceived")." </td>\n";
|
||||||
@ -384,13 +388,14 @@ if ($_GET['action'] == 'new')
|
|||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
if ($user->rights->banque->cheque)
|
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
|
else
|
||||||
{
|
{
|
||||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn',$account_label).'</a>';
|
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn',$account_label).'</a>';
|
||||||
}
|
}
|
||||||
print '</div><br>';
|
print '</div><br>';
|
||||||
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user