Add function set_paid
This commit is contained in:
parent
50aa36502c
commit
9cf06ec21c
@ -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')
|
|||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?id=' . $object->id . '&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 . '&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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user