Minor bug fixes

This commit is contained in:
Laurent Destailleur 2020-10-02 12:54:56 +02:00
parent ce0fa53cb0
commit 0893f0250a
5 changed files with 166 additions and 71 deletions

View File

@ -94,7 +94,7 @@ function payment_expensereport_prepare_head(PaymentExpenseReport $object)
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("ExpenseReport");
$head[$h][1] = $langs->trans("ExpenseReportPayment");
$head[$h][2] = 'payment';
$h++;

View File

@ -225,7 +225,7 @@ if (empty($reshook))
$fuser = new User($db);
$fuser->fetch($object->fk_user_author);
$object->fk_statut = 1;
$object->status = 1;
$object->fk_c_paiement = GETPOST('fk_c_paiement', 'int');
$object->fk_user_validator = GETPOST('fk_user_validator', 'int');
$object->note_public = GETPOST('note_public', 'restricthtml');
@ -275,7 +275,7 @@ if (empty($reshook))
$object->date_debut = $date_start;
$object->date_fin = $date_end;
if ($object->fk_statut < 3)
if ($object->status < 3)
{
$object->fk_user_validator = GETPOST('fk_user_validator', 'int');
}
@ -288,7 +288,7 @@ if (empty($reshook))
$result = $object->update($user);
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int'));
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
@ -1505,7 +1505,7 @@ if ($action == 'create')
$head = expensereport_prepare_head($object);
if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut == 99))
if ($action == 'edit' && ($object->status < 3 || $object->status == 99))
{
print "<form name='update' action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -1513,7 +1513,7 @@ if ($action == 'create')
dol_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip');
if ($object->fk_statut == 99)
if ($object->status == 99)
{
print '<input type="hidden" name="action" value="updateFromRefuse">';
} else {
@ -1563,7 +1563,7 @@ if ($action == 'create')
print '</tr>';
}
if ($object->fk_statut < 3)
if ($object->status < 3)
{
print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>'; // Approbator
@ -1583,7 +1583,7 @@ if ($action == 'create')
print '</td></tr>';
}
if ($object->fk_statut == 6)
if ($object->status == 6)
{
print '<tr>';
print '<td>'.$langs->trans("AUTHORPAIEMENT").'</td>';
@ -1618,7 +1618,7 @@ if ($action == 'create')
if (!empty($user->rights->expensereport->readall)) $criteriaforfilter = '';
$formquestion = array(
'text' => '',
array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter))
array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter, '', '0', 0, 0, '', 0, '', 'maxwidth150'))
);
// Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
@ -1763,7 +1763,7 @@ if ($action == 'create')
print '</tr>';
// User to inform for approval
if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) // informed
if ($object->status <= ExpenseReport::STATUS_VALIDATED) // informed
{
print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>'; // approver
@ -1780,7 +1780,7 @@ if ($action == 'create')
}
}
print '</td></tr>';
} elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED)
} elseif ($object->status == ExpenseReport::STATUS_CANCELED)
{
print '<tr>';
print '<td>'.$langs->trans("CANCEL_USER").'</span></td>';
@ -1819,7 +1819,7 @@ if ($action == 'create')
print '</tr>';
}
if ($object->fk_statut == 99 || !empty($object->detail_refuse))
if ($object->status == 99 || !empty($object->detail_refuse))
{
print '<tr>';
print '<td>'.$langs->trans("REFUSEUR").'</td>';
@ -1837,7 +1837,7 @@ if ($action == 'create')
print '</tr>';
}
if ($object->fk_statut == $object::STATUS_CLOSED)
if ($object->status == $object::STATUS_CLOSED)
{
/* TODO this fields are not yet filled
print '<tr>';
@ -1872,11 +1872,11 @@ if ($action == 'create')
print '<td class="titlefieldmiddle">'.$langs->trans("AmountHT").'</td>';
print '<td class="nowrap amountcard">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td>';
$rowspan = 5;
if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) $rowspan++;
elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan += 2;
if ($object->status <= ExpenseReport::STATUS_VALIDATED) $rowspan++;
elseif ($object->status == ExpenseReport::STATUS_CANCELED) $rowspan += 2;
else $rowspan += 2;
if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan += 2;
if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan += 2;
if ($object->status == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan += 2;
if ($object->status == ExpenseReport::STATUS_CLOSED) $rowspan += 2;
print "</td>";
print '</tr>';
@ -2010,7 +2010,7 @@ if ($action == 'create')
print '<div style="clear: both;"></div>';
$actiontouse = 'updateline';
if (($object->fk_statut == 0 || $object->fk_statut == 99) && $action != 'editline') $actiontouse = 'addline';
if (($object->status == 0 || $object->status == 99) && $action != 'editline') $actiontouse = 'addline';
print '<form name="expensereport" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" method="post" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -2046,7 +2046,7 @@ if ($action == 'create')
print '<td>';
print '</td>';
// Ajout des boutons de modification/suppression
if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer)
if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer)
{
print '<td class="right"></td>';
}
@ -2195,7 +2195,7 @@ if ($action == 'create')
print '</td>';
// Ajout des boutons de modification/suppression
if (($object->fk_statut < ExpenseReport::STATUS_VALIDATED || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer)
if (($object->status < ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer)
{
print '<td class="nowrap right">';
@ -2349,7 +2349,7 @@ if ($action == 'create')
}
// Add a new line
if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED)
if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED)
&& $action != 'editline'
&& $user->rights->expensereport->creer)
{
@ -2549,7 +2549,7 @@ if ($action != 'create' && $action != 'edit')
// Send
if (empty($user->socid)) {
if ($object->fk_statut > ExpenseReport::STATUS_DRAFT) {
if ($object->status > ExpenseReport::STATUS_DRAFT) {
//if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expensereport->expensereport_advance->send)) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
//} else
@ -2562,7 +2562,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_DRAFT)
if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_DRAFT)
{
if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance))
{
@ -2582,7 +2582,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED)
if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_REFUSED)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
@ -2596,7 +2596,7 @@ if ($action != 'create' && $action != 'edit')
}
}
if ($user->rights->expensereport->to_paid && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
if ($user->rights->expensereport->to_paid && $object->status == ExpenseReport::STATUS_APPROVED)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
@ -2610,7 +2610,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_validator == user courant
* Afficher : "Valider" / "Refuser" / "Supprimer"
*/
if ($object->fk_statut == ExpenseReport::STATUS_VALIDATED)
if ($object->status == ExpenseReport::STATUS_VALIDATED)
{
if (in_array($object->fk_user_author, $user->getAllChildIds(1)))
{
@ -2619,7 +2619,7 @@ if ($action != 'create' && $action != 'edit')
}
}
if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_VALIDATED)
if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_VALIDATED)
{
//if($object->fk_user_validator==$user->id)
//{
@ -2640,13 +2640,13 @@ if ($action != 'create' && $action != 'edit')
// If status is Approved
// ---------------------
if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_APPROVED)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$object->id.'">'.$langs->trans('Deny').'</a></div>';
}
// If bank module is used
if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->status == ExpenseReport::STATUS_APPROVED)
{
// Pay
if ($remaintopay == 0)
@ -2658,7 +2658,7 @@ if ($action != 'create' && $action != 'edit')
}
// If bank module is not used
if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->status == ExpenseReport::STATUS_APPROVED)
{
//if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0)
if ($object->paid == 0)
@ -2667,20 +2667,20 @@ if ($action != 'create' && $action != 'edit')
}
}
if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status == ExpenseReport::STATUS_APPROVED)
{
// Cancel
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id.'">'.$langs->trans('Cancel').'</a></div>';
}
// TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled.
if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == ExpenseReport::STATUS_CLOSED)
if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status == ExpenseReport::STATUS_CLOSED)
{
// Cancel
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id.'">'.$langs->trans('Cancel').'</a></div>';
}
if ($user->rights->expensereport->to_paid && $object->paid && $object->fk_statut == ExpenseReport::STATUS_CLOSED)
if ($user->rights->expensereport->to_paid && $object->paid && $object->status == ExpenseReport::STATUS_CLOSED)
{
// Set unpaid
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=set_unpaid&token='.newToken().'&id='.$object->id.'">'.$langs->trans('ClassifyUnPaid').'</a></div>';
@ -2692,11 +2692,11 @@ if ($action != 'create' && $action != 'edit')
}
/* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */
if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut < ExpenseReport::STATUS_APPROVED)
if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->status < ExpenseReport::STATUS_APPROVED)
{
// Delete
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
} elseif ($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED)
} elseif ($user->rights->expensereport->supprimer && $object->status != ExpenseReport::STATUS_CLOSED)
{
// Delete
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';

View File

@ -64,6 +64,13 @@ class ExpenseReport extends CommonObject
* @var int Status
*/
public $status;
/**
* 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied
*
* @var int Status
* @deprecated
*/
public $fk_statut;
public $fk_c_paiement;
@ -398,7 +405,7 @@ class ExpenseReport extends CommonObject
$this->id = 0;
$this->ref = '';
$this->status = 0;
$this->fk_statut = 0;
$this->fk_statut = 0; // deprecated
// Clear fields
$this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
@ -407,6 +414,15 @@ class ExpenseReport extends CommonObject
$this->date_creation = '';
$this->date_validation = '';
// Remove link on lines to a joined file
if (is_array($this->lines) && count($this->lines) > 0)
{
foreach ($this->lines as $key => $line)
{
$this->lines[$key]->fk_ecm_files = 0;
}
}
// Create clone
$this->context['createfromclone'] = 'createfromclone';
$result = $this->create($user);
@ -578,7 +594,7 @@ class ExpenseReport extends CommonObject
$this->fk_c_paiement = $obj->fk_c_paiement;
$this->paid = $obj->paid;
if ($this->fk_statut == self::STATUS_APPROVED || $this->fk_statut == self::STATUS_CLOSED)
if ($this->status == self::STATUS_APPROVED || $this->status == self::STATUS_CLOSED)
{
$user_valid = new User($this->db);
if ($this->fk_user_valid > 0) $user_valid->fetch($this->fk_user_valid);
@ -668,9 +684,9 @@ class ExpenseReport extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Returns the label of a statut
* Returns the label of a status
*
* @param int $status id statut
* @param int $status ID status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label
*/
@ -857,7 +873,7 @@ class ExpenseReport extends CommonObject
{
$objp = $this->db->fetch_object($result);
$sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut";
$sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut as status";
$sql2 .= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql2 .= " WHERE d.rowid = ".((int) $objp->fk_expensereport);
@ -866,7 +882,7 @@ class ExpenseReport extends CommonObject
$objp->fk_user_author = $obj->fk_user_author;
$objp->ref = $obj->ref;
$objp->fk_c_expensereport_status = $obj->fk_statut;
$objp->fk_c_expensereport_status = $obj->status;
$objp->rowid = $obj->rowid;
$total_HT = $total_HT + $objp->total_ht;
@ -1107,7 +1123,7 @@ class ExpenseReport extends CommonObject
$now = dol_now();
// Protection
if ($this->statut == self::STATUS_VALIDATED)
if ($this->status == self::STATUS_VALIDATED)
{
dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING);
return 0;
@ -1195,7 +1211,7 @@ class ExpenseReport extends CommonObject
if (!$error)
{
$this->ref = $num;
$this->statut = self::STATUS_VALIDATED;
$this->status = self::STATUS_VALIDATED;
}
if (empty($error))
@ -1237,7 +1253,7 @@ class ExpenseReport extends CommonObject
$this->date_debut = $this->db->jdate($objp->date_debut);
if ($this->fk_statut != self::STATUS_VALIDATED)
if ($this->status != self::STATUS_VALIDATED)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_statut = ".self::STATUS_VALIDATED;
@ -1271,7 +1287,7 @@ class ExpenseReport extends CommonObject
// date approval
$this->date_approve = $now;
if ($this->fk_statut != self::STATUS_APPROVED)
if ($this->status != self::STATUS_APPROVED)
{
$this->db->begin();
@ -1327,7 +1343,7 @@ class ExpenseReport extends CommonObject
$error = 0;
// date de refus
if ($this->fk_statut != self::STATUS_REFUSED)
if ($this->status != self::STATUS_REFUSED)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.",";
@ -1337,7 +1353,8 @@ class ExpenseReport extends CommonObject
$sql .= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
{
$this->fk_statut = 99;
$this->fk_statut = 99; // deprecated
$this->status = 99;
$this->fk_user_refuse = $fuser->id;
$this->detail_refuse = $details;
$this->date_refuse = $now;
@ -1441,7 +1458,7 @@ class ExpenseReport extends CommonObject
// phpcs:enable
$error = 0;
$this->date_cancel = $this->db->idate(dol_now());
if ($this->fk_statut != self::STATUS_CANCELED)
if ($this->status != self::STATUS_CANCELED)
{
$this->db->begin();
@ -1565,6 +1582,9 @@ class ExpenseReport extends CommonObject
$label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
if (!empty($this->total_ttc))
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
if (isset($this->status)) {
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5);
}
if ($moretitle) $label .= ' - '.$moretitle;
//if ($option != 'nolink')
@ -1683,7 +1703,7 @@ class ExpenseReport extends CommonObject
dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG);
if ($this->fk_statut == self::STATUS_DRAFT)
if ($this->status == self::STATUS_DRAFT)
{
if (empty($qty)) $qty = 0;
if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 0;
@ -1925,7 +1945,7 @@ class ExpenseReport extends CommonObject
{
global $user, $mysoc;
if ($this->fk_statut == 0 || $this->fk_statut == 99)
if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED)
{
$this->db->begin();
@ -2268,8 +2288,8 @@ class ExpenseReport extends CommonObject
$sql = "SELECT ex.rowid, ex.date_valid";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
if ($option == 'toapprove') $sql .= " WHERE ex.fk_statut = 2";
else $sql .= " WHERE ex.fk_statut = 5";
if ($option == 'toapprove') $sql .= " WHERE ex.fk_statut = ".self::STATUS_VALIDATED;
else $sql .= " WHERE ex.fk_statut = ".self::STATUS_APPROVED;
$sql .= " AND ex.entity IN (".getEntity('expensereport').")";
if (empty($user->rights->expensereport->readall))
{
@ -2289,12 +2309,12 @@ class ExpenseReport extends CommonObject
$response->warning_delay = $conf->expensereport->approve->warning_delay / 60 / 60 / 24;
$response->label = $langs->trans("ExpenseReportsToApprove");
$response->labelShort = $langs->trans("ToApprove");
$response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=2';
$response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut='.self::STATUS_VALIDATED;
} else {
$response->warning_delay = $conf->expensereport->payment->warning_delay / 60 / 60 / 24;
$response->label = $langs->trans("ExpenseReportsToPay");
$response->labelShort = $langs->trans("StatusToPay");
$response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=5';
$response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut='.self::STATUS_APPROVED;
}
$response->img = img_object('', "trip");

View File

@ -3,7 +3,7 @@
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2014 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
*
* 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
@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
$hookmanager = new HookManager($db);
@ -52,6 +53,7 @@ if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INF
$holiday = new Holiday($db);
$holidaystatic = new Holiday($db);
$staticrecruitmentcandidature = new RecruitmentCandidature($db);
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
@ -173,7 +175,8 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Latest leave requests
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,";
$sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = x.fk_user";
$sql .= " AND x.entity = ".$conf->entity;
@ -203,8 +206,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
print '<th colspan="3">'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).'</th>';
print '<th>'.$langs->trans("from").'</th>';
print '<th>'.$langs->trans("to").'</th>';
print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
print '<th width="16">&nbsp;</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
@ -214,6 +216,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
$holidaystatic->id = $obj->rowid;
$holidaystatic->ref = $obj->ref;
$holidaystatic->statut = $obj->status;
$userstatic->id = $obj->uid;
$userstatic->lastname = $obj->lastname;
@ -221,7 +224,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
$userstatic->login = $obj->login;
$userstatic->photo = $obj->photo;
$userstatic->email = $obj->email;
$userstatic->statut = $obj->statut;
$userstatic->statut = $obj->user_status;
print '<tr class="oddeven">';
print '<td class="nowraponall">'.$holidaystatic->getNomUrl(1).'</td>';
@ -231,10 +234,10 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
$starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
$endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
print '<td>'.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]);
print '<td>'.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]);
print '<td>'.dol_print_date($db->jdate($obj->date_start), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
print '<td>'.dol_print_date($db->jdate($obj->date_end), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
print '<td>'.$holidaystatic->LibStatut($obj->status, 3).'</td>';
print '<td class="right nowrap" width="16">'.$holidaystatic->LibStatut($obj->status, 3).'</td>';
print '</tr>';
$i++;
@ -252,7 +255,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
// Latest expense report
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,";
$sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE u.rowid = x.fk_user_author";
@ -275,8 +279,7 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).'</th>';
print '<th class="right">'.$langs->trans("TotalTTC").'</th>';
print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
print '<th width="16">&nbsp;</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
@ -290,13 +293,14 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
$expensereportstatic->id = $obj->rowid;
$expensereportstatic->ref = $obj->ref;
$expensereportstatic->statut = $obj->status;
$userstatic->id = $obj->uid;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->email;
$userstatic->login = $obj->login;
$userstatic->statut = $obj->statut;
$userstatic->statut = $obj->user_status;
$userstatic->photo = $obj->photo;
print '<tr class="oddeven">';
@ -304,7 +308,7 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1).'</td>';
print '<td class="right">'.price($obj->total_ttc).'</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
print '<td>'.$expensereportstatic->LibStatut($obj->status, 3).'</td>';
print '<td class="right nowrap" width="16">'.$expensereportstatic->LibStatut($obj->status, 3).'</td>';
print '</tr>';
$i++;
@ -314,10 +318,75 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
}
print '</table>';
print '</div>';
print '<br>';
} else dol_print_error($db);
}
// Last modified job position
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
{
$sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.fk_soc = $socid";
$sql .= " ORDER BY rc.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">';
print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
print '</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$staticrecruitmentcandidature->id = $objp->rowid;
$staticrecruitmentcandidature->ref = $objp->ref;
$staticrecruitmentcandidature->email = $objp->email;
$staticrecruitmentcandidature->status = $objp->status;
$staticrecruitmentcandidature->date_creation = $objp->date_creation;
$staticrecruitmentcandidature->firstname = $objp->firstname;
$staticrecruitmentcandidature->lastname = $objp->lastname;
print '<tr class="oddeven">';
print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
print '<td class="right nowrap">';
print "</td>";
print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
print '<td class="right nowrap" width="16">';
print $staticrecruitmentcandidature->getLibStatut(3);
print "</td>";
print '</tr>';
$i++;
}
$db->free($resql);
} else {
print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table>";
print "</div>";
print "<br>";
} else {
dol_print_error($db);
}
}
print '</div></div></div>';
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array

View File

@ -338,6 +338,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
$num = $db->num_rows($resql);
$i = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">';
@ -361,7 +362,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
print '<td class="right nowrap">';
print "</td>";
print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
print '<td class="right nowrap">';
print '<td class="right nowrap" width="16">';
print $staticrecruitmentjobposition->getLibStatut(3);
print "</td>";
print '</tr>';
@ -372,7 +373,9 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
} else {
print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table><br>";
print "</table>";
print "</div>";
print "<br>";
} else {
dol_print_error($db);
}
@ -397,6 +400,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
$num = $db->num_rows($resql);
$i = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">';
@ -422,7 +426,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
print '<td class="right nowrap">';
print "</td>";
print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
print '<td class="right nowrap">';
print '<td class="right nowrap" width="16">';
print $staticrecruitmentcandidature->getLibStatut(3);
print "</td>";
print '</tr>';
@ -433,7 +437,9 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
} else {
print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table><br>";
print "</table>";
print "</div>";
print "<br>";
} else {
dol_print_error($db);
}