Skip to content
Snippets Groups Projects
Commit 9cf06ec2 authored by aspangaro's avatar aspangaro
Browse files

Add function set_paid

parent 50aa3650
No related branches found
No related tags found
No related merge requests found
...@@ -827,6 +827,18 @@ if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && ...@@ -827,6 +827,18 @@ if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 &&
} }
} }
if ($action == 'set_paid')
{
if ($object->set_paid($id) >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
else {
setEventMessage($object->error, 'errors');
}
}
if ($action == "addline") if ($action == "addline")
{ {
$error = 0; $error = 0;
...@@ -1988,7 +2000,11 @@ if ($action != 'create' && $action != 'edit') ...@@ -1988,7 +2000,11 @@ if ($action != 'create' && $action != 'edit')
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?id=' . $object->id . '&amp;action=create">' . $langs->trans('DoPayment') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?id=' . $object->id . '&amp;action=create">' . $langs->trans('DoPayment') . '</a></div>';
} }
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$object->id.'">'.$langs->trans('TO_PAID').'</a>';
if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
}
// Cancel // Cancel
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
......
...@@ -372,6 +372,36 @@ class ExpenseReport extends CommonObject ...@@ -372,6 +372,36 @@ class ExpenseReport extends CommonObject
} }
} }
/**
* Classify the expense report as paid
*
* @param int $id id of expense report
* @param int $modepayment mode of payment
* @return int <0 if KO, >0 if OK
*/
function set_paid($id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."expensereport SET fk_statut = 6";
$sql.= " WHERE rowid = $id AND fk_statut = 5";
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->affected_rows($resql))
{
return 1;
}
else
{
return 0;
}
}
else
{
dol_print_error($this->db);
return -1;
}
}
/** /**
* Returns the label status * Returns the label status
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment