Update card
This commit is contained in:
parent
a0b4a0a3cd
commit
ba7a4d6f88
@ -31,8 +31,9 @@ $langs->load("bills");
|
|||||||
$langs->load("loan");
|
$langs->load("loan");
|
||||||
|
|
||||||
$id=GETPOST('id','int');
|
$id=GETPOST('id','int');
|
||||||
$action=GETPOST("action");
|
$action=GETPOST('action');
|
||||||
$confirm=GETPOST('confirm');
|
$confirm=GETPOST('confirm');
|
||||||
|
$cancel=GETPOST('cancel');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = GETPOST('socid','int');
|
$socid = GETPOST('socid','int');
|
||||||
@ -46,17 +47,17 @@ $result = restrictedArea($user, 'loan', $id, '','');
|
|||||||
// Classify paid
|
// Classify paid
|
||||||
if ($action == 'confirm_paid' && $confirm == 'yes')
|
if ($action == 'confirm_paid' && $confirm == 'yes')
|
||||||
{
|
{
|
||||||
$loan = new Loan($db);
|
$object = new Loan($db);
|
||||||
$loan->fetch($id);
|
$object->fetch($id);
|
||||||
$result = $loan->set_paid($user);
|
$result = $object->set_paid($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete loan
|
// Delete loan
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||||
{
|
{
|
||||||
$loan = new Loan($db);
|
$object = new Loan($db);
|
||||||
$loan->fetch($id);
|
$object->fetch($id);
|
||||||
$result=$loan->delete($user);
|
$result=$object->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
@ -72,8 +73,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
|
|||||||
// Add loan
|
// Add loan
|
||||||
if ($action == 'add' && $user->rights->loan->write)
|
if ($action == 'add' && $user->rights->loan->write)
|
||||||
{
|
{
|
||||||
$datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]);
|
$datestart=dol_mktime(12,0,0, $GETPOST("startmonth"), $GETPOST("startday"), $GETPOST("startyear"));
|
||||||
$dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
|
$dateend=dol_mktime(12,0,0, $GETPOST("endmonth"), $GETPOST("endday"), $GETPOST("endyear"));
|
||||||
if (! $datestart)
|
if (! $datestart)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors');
|
||||||
@ -91,33 +92,33 @@ if ($action == 'add' && $user->rights->loan->write)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$loan = new Loan($db);
|
$object = new Loan($db);
|
||||||
|
|
||||||
$loan->label = GETPOST("label");
|
$object->label = GETPOST("label");
|
||||||
$loan->fk_bank = GETPOST("accountid");
|
$object->fk_bank = GETPOST("accountid");
|
||||||
$loan->capital = GETPOST("capital");
|
$object->capital = GETPOST("capital");
|
||||||
$loan->datestart = $datestart;
|
$object->datestart = $datestart;
|
||||||
$loan->dateend = $dateend;
|
$object->dateend = $dateend;
|
||||||
$loan->nbterm = GETPOST("nbterm");
|
$object->nbterm = GETPOST("nbterm");
|
||||||
$loan->rate = GETPOST("rate");
|
$object->rate = GETPOST("rate");
|
||||||
|
|
||||||
$loan->account_capital = GETPOST("accountancy_account_capital");
|
$object->account_capital = GETPOST("accountancy_account_capital");
|
||||||
$loan->account_insurance = GETPOST("accountancy_account_insurance");
|
$object->account_insurance = GETPOST("accountancy_account_insurance");
|
||||||
$loan->account_interest = GETPOST("accountancy_account_interest");
|
$object->account_interest = GETPOST("accountancy_account_interest");
|
||||||
|
|
||||||
$id=$loan->create($user);
|
$id=$object->create($user);
|
||||||
if ($id <= 0)
|
if ($id <= 0)
|
||||||
{
|
{
|
||||||
setEventMessage($loan->error, 'errors');
|
setEventMessage($object->error, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write)
|
if ($action == 'update' && ! $cancel && $user->rights->loan->write)
|
||||||
{
|
{
|
||||||
$datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]);
|
$datestart=dol_mktime(12,0,0, $GETPOST("startmonth"), $GETPOST("startday"), $GETPOST("startyear"));
|
||||||
$dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
|
$dateend=dol_mktime(12,0,0, $GETPOST("endmonth"), $GETPOST("endday"), $GETPOST("endyear"));
|
||||||
if (! $datestart)
|
if (! $datestart)
|
||||||
{
|
{
|
||||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors');
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors');
|
||||||
@ -130,17 +131,22 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$loan = new Loan($db);
|
$object = new Loan($db);
|
||||||
$result=$loan->fetch($_GET["id"]);
|
if ($object->fetch($id))
|
||||||
|
|
||||||
$loan->label=$_POST["label"];
|
|
||||||
$loan->datestart=$datestart;
|
|
||||||
$loan->dateend=$dateend;
|
|
||||||
|
|
||||||
$result=$loan->update($user);
|
|
||||||
if ($result <= 0)
|
|
||||||
{
|
{
|
||||||
setEventMessage($loan->error, 'errors');
|
$object->label = $GETPOST("label");
|
||||||
|
$object->datestart = $datestart;
|
||||||
|
$object->dateend = $dateend;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($object->update($id, $user) > 0)
|
||||||
|
{
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$action = 'edit';
|
||||||
|
setEventMessage($object->error, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +186,7 @@ if ($action == 'create')
|
|||||||
if (! empty($conf->banque->enabled))
|
if (! empty($conf->banque->enabled))
|
||||||
{
|
{
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
|
||||||
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Show list of bank account with courant
|
$form->select_comptes($GETPOST["accountid"],"accountid",0,"courant=1",1); // Show list of bank account with courant
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -259,7 +265,7 @@ if ($action == 'create')
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br><center><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
print '<br><center><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
||||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></center';
|
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
@ -434,8 +440,8 @@ if ($id > 0)
|
|||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Boutons actions
|
* Buttons actions
|
||||||
*/
|
*/
|
||||||
if ($action != 'edit')
|
if ($action != 'edit')
|
||||||
{
|
{
|
||||||
print "<div class=\"tabsAction\">\n";
|
print "<div class=\"tabsAction\">\n";
|
||||||
@ -474,7 +480,6 @@ if ($id > 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
Loading…
Reference in New Issue
Block a user