Debug module salary
This commit is contained in:
parent
f4fa16797b
commit
c4f27cc29f
@ -213,10 +213,11 @@ if ($action == 'add' && empty($cancel)) {
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$ret = $object->create($user);
|
||||
if ($ret < 0) $error++;
|
||||
if (!empty($auto_create_paiement) && !$error) {
|
||||
$db->begin();
|
||||
// Create a line of payments
|
||||
$paiement = new PaymentSalary($db);
|
||||
$paiement->chid = $object->id;
|
||||
@ -243,15 +244,11 @@ if ($action == 'add' && empty($cancel)) {
|
||||
setEventMessages($paiement->error, null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$db->commit();
|
||||
|
||||
if (GETPOST('saveandnew', 'alpha')) {
|
||||
setEventMessages($langs->trans("RecordSaved"), '', 'mesgs');
|
||||
header("Location: card.php?action=create&fk_project=" . urlencode($projectid) . "&accountid=" . urlencode($accountid) . '&paymenttype=' . urlencode(GETPOST('paymenttype', 'az09')) . '&datepday=' . GETPOST("datepday", 'int') . '&datepmonth=' . GETPOST("datepmonth", 'int') . '&datepyear=' . GETPOST("datepyear", 'int'));
|
||||
@ -260,6 +257,8 @@ if ($action == 'add' && empty($cancel)) {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -498,6 +498,12 @@ class Salary extends CommonObject
|
||||
$label = '<u>'.$langs->trans("Salary").'</u>';
|
||||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
if ($this->label) {
|
||||
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
|
||||
}
|
||||
if ($this->datesp && $this->dateep) {
|
||||
$label .= '<br><b>'.$langs->trans('Period').':</b> '.dol_print_date($this->datesp, 'day').' - '.dol_print_date($this->dateep, 'day');
|
||||
}
|
||||
|
||||
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
|
||||
|
||||
@ -647,9 +653,9 @@ class Salary extends CommonObject
|
||||
/**
|
||||
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
|
||||
*
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
|
||||
* @return string Libelle
|
||||
* @return string Label
|
||||
*/
|
||||
public function getLibStatut($mode = 0, $alreadypaid = -1)
|
||||
{
|
||||
|
||||
@ -532,6 +532,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
|
||||
$salstatic->id = $obj->rowid;
|
||||
$salstatic->ref = $obj->rowid;
|
||||
$salstatic->label = $obj->label;
|
||||
$salstatic->paye = $obj->paye;
|
||||
$salstatic->datesp = $db->jdate($obj->datesp);
|
||||
$salstatic->dateep = $db->jdate($obj->dateep);
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -40,6 +40,7 @@ if (!empty($conf->expensereport->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
}
|
||||
if (!empty($conf->salaries->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
|
||||
}
|
||||
|
||||
@ -354,16 +355,18 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
||||
|
||||
// Latest payments of salaries
|
||||
if (!empty($conf->salaries->enabled) &&
|
||||
$user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id)
|
||||
(($user->rights->salaries->read && (in_array($object->id, $childids) || $object->id == $user->id)) || (!empty($user->rights->salaries->readall)))
|
||||
) {
|
||||
$payment_salary = new PaymentSalary($db);
|
||||
$salary = new Salary($db);
|
||||
|
||||
$sql = "SELECT ps.rowid, s.datesp, s.dateep, ps.amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON (s.rowid = ps.fk_salary)";
|
||||
$sql = "SELECT s.rowid as sid, s.ref as sref, s.label, s.datesp, s.dateep, s.paye, SUM(ps.amount) as alreadypaid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON (s.rowid = ps.fk_salary)";
|
||||
$sql .= " WHERE s.fk_user = ".$object->id;
|
||||
$sql .= " AND ps.entity = ".$conf->entity;
|
||||
$sql .= " ORDER BY ps.rowid DESC";
|
||||
$sql .= " AND s.entity IN (".getEntity('salary').")";
|
||||
$sql .= " GROUP BY s.rowid, s.ref, s.label, s.datesp, s.dateep, s.paye";
|
||||
$sql .= " ORDER BY s.dateep DESC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
@ -372,7 +375,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/payments.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/salaries/list.php?search_user='.$object->login.'">'.$langs->trans("AllSalaries").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
|
||||
print '</tr></table></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -380,16 +383,26 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
||||
while ($i < $num && $i < $MAXLIST) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$payment_salary->id = $objp->rowid;
|
||||
$payment_salary->ref = $objp->ref;
|
||||
$payment_salary->datep = $db->jdate($objp->datep);
|
||||
|
||||
$salary->id = $objp->sid;
|
||||
$salary->ref = $objp->sref ? $objp->sref : $objp->sid;
|
||||
$salary->label = $objp->label;
|
||||
$salary->datesp = $db->jdate($objp->datesp);
|
||||
$salary->dateep = $db->jdate($objp->dateep);
|
||||
$salary->paye = $objp->paye;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">';
|
||||
$payment_salary->id = $objp->rowid;
|
||||
$payment_salary->ref = $objp->rowid;
|
||||
print $payment_salary->getNomUrl(1);
|
||||
print $salary->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->datesp), 'day')."</td>\n";
|
||||
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dateep), 'day')."</td>\n";
|
||||
print '<td class="right" style="min-width: 60px">'.price($objp->amount).'</td>';
|
||||
//print '<td class="right" class="nowraponall"><span class="ampount">'.price($objp->amount).'</span></td>';
|
||||
print '<td class="right" class="nowraponall">'.$salary->getLibStatut(5, $objp->alreadypaid).'</td>';
|
||||
|
||||
print '</tr>';
|
||||
$i++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user