NEW Can clone expense report on another user
This commit is contained in:
parent
6f723490c2
commit
7066ec7dab
@ -156,10 +156,10 @@ if (empty($reshook))
|
||||
{
|
||||
if ($object->id > 0)
|
||||
{
|
||||
// Because createFromClone modifies the object, we must clone it so that we can restore it later
|
||||
// Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails
|
||||
$orig = clone $object;
|
||||
|
||||
$result=$object->createFromClone($socid);
|
||||
$result=$object->createFromClone(GETPOST('fk_user_author','int'));
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||
@ -1448,8 +1448,11 @@ else
|
||||
print '<td>'.$langs->trans("User").'</td>';
|
||||
print '<td>';
|
||||
$userfee=new User($db);
|
||||
$userfee->fetch($object->fk_user_author);
|
||||
print $userfee->getNomUrl(-1);
|
||||
if ($object->fk_user_author > 0)
|
||||
{
|
||||
$userfee->fetch($object->fk_user_author);
|
||||
print $userfee->getNomUrl(-1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Ref
|
||||
@ -1536,12 +1539,11 @@ else
|
||||
// Clone confirmation
|
||||
if ($action == 'clone') {
|
||||
// Create an array for form
|
||||
$criteriaforfilter='hierarchyme';
|
||||
if (! empty($user->rights->expensereport->readall)) $criteriaforfilter='';
|
||||
$formquestion = array(
|
||||
// 'text' => $langs->trans("ConfirmClone"),
|
||||
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
|
||||
// 1),
|
||||
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
|
||||
// => 1),
|
||||
'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))
|
||||
);
|
||||
// Paiement incomplet. On demande si motif = escompte ou autre
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneExpenseReport'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
|
||||
@ -1658,7 +1660,7 @@ else
|
||||
$userauthor=new User($db);
|
||||
$result=$userauthor->fetch($object->fk_user_author);
|
||||
if ($result < 0) dol_print_error('',$userauthor->error);
|
||||
print $userauthor->getNomUrl(-1);
|
||||
elseif ($result > 0) print $userauthor->getNomUrl(-1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1694,8 +1696,8 @@ else
|
||||
if ($object->fk_user_validator > 0)
|
||||
{
|
||||
$userfee=new User($db);
|
||||
$userfee->fetch($object->fk_user_validator);
|
||||
print $userfee->getNomUrl(-1);
|
||||
$result = $userfee->fetch($object->fk_user_validator);
|
||||
if ($result > 0) print $userfee->getNomUrl(-1);
|
||||
if (empty($userfee->email) || ! isValidEmail($userfee->email))
|
||||
{
|
||||
$langs->load("errors");
|
||||
@ -1712,8 +1714,8 @@ else
|
||||
if ($object->fk_user_cancel > 0)
|
||||
{
|
||||
$userfee=new User($db);
|
||||
$userfee->fetch($object->fk_user_cancel);
|
||||
print $userfee->getNomUrl(-1);
|
||||
$result = $userfee->fetch($object->fk_user_cancel);
|
||||
if ($result > 0) print $userfee->getNomUrl(-1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1734,8 +1736,8 @@ else
|
||||
if ($object->fk_user_approve > 0)
|
||||
{
|
||||
$userapp=new User($db);
|
||||
$userapp->fetch($object->fk_user_approve);
|
||||
print $userapp->getNomUrl(-1);
|
||||
$result = $userapp->fetch($object->fk_user_approve);
|
||||
if ($result > 0) print $userapp->getNomUrl(-1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1751,8 +1753,8 @@ else
|
||||
print '<td>'.$langs->trans("REFUSEUR").'</td>';
|
||||
print '<td>';
|
||||
$userfee=new User($db);
|
||||
$userfee->fetch($object->fk_user_refuse);
|
||||
print $userfee->getNomUrl(-1);
|
||||
$result = $userfee->fetch($object->fk_user_refuse);
|
||||
if ($result > 0) print $userfee->getNomUrl(-1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
|
||||
@ -256,17 +256,19 @@ class ExpenseReport extends CommonObject
|
||||
/**
|
||||
* Load an object from its id and create a new one in database
|
||||
*
|
||||
* @param int $socid Id of thirdparty
|
||||
* @return int New id of clone
|
||||
* @param int $fk_user_author Id of new user
|
||||
* @return int New id of clone
|
||||
*/
|
||||
function createFromClone($socid=0)
|
||||
function createFromClone($fk_user_author)
|
||||
{
|
||||
global $user,$hookmanager;
|
||||
|
||||
$error=0;
|
||||
|
||||
if (empty($fk_user_author)) $fk_user_author = $user->id;
|
||||
|
||||
$this->context['createfromclone'] = 'createfromclone';
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// get extrafields so they will be clone
|
||||
@ -282,7 +284,7 @@ class ExpenseReport extends CommonObject
|
||||
$this->fk_statut=0;
|
||||
|
||||
// Clear fields
|
||||
$this->fk_user_author = $user->id; // Note fk_user_author is not the 'author' but the guy the expense report is for.
|
||||
$this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
|
||||
$this->fk_user_valid = '';
|
||||
$this->date_create = '';
|
||||
$this->date_creation = '';
|
||||
|
||||
@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("banks");
|
||||
$langs->load("trips");
|
||||
|
||||
$chid=GETPOST("id",'int');
|
||||
$ref=GETPOST('ref','alpha');
|
||||
@ -285,16 +286,11 @@ if ($action == 'create' || empty($action))
|
||||
{
|
||||
$objp = $expensereport;
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td align="right">'.price($objp->total_ttc)."</td>";
|
||||
|
||||
print '<td align="right">'.price($sumpaid)."</td>";
|
||||
|
||||
print '<td align="right">'.price($objp->total_ttc - $sumpaid)."</td>";
|
||||
|
||||
print '<td align="center">';
|
||||
if ($sumpaid < $objp->total_ttc)
|
||||
{
|
||||
@ -308,6 +304,7 @@ if ($action == 'create' || empty($action))
|
||||
print "</td>";
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$total+=$objp->total;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$totalrecu+=$objp->am;
|
||||
@ -316,7 +313,7 @@ if ($action == 'create' || empty($action))
|
||||
if ($i > 1)
|
||||
{
|
||||
// Print total
|
||||
print "<tr ".$bc[!$var].">";
|
||||
print '<tr class="oddeven">';
|
||||
print '<td colspan="2" align="left">'.$langs->trans("Total").':</td>';
|
||||
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($totalrecu)."</b></td>";
|
||||
|
||||
@ -715,6 +715,7 @@ from=from
|
||||
toward=toward
|
||||
Access=Access
|
||||
SelectAction=Select action
|
||||
SelectTargetUser=Select target user/employee
|
||||
HelpCopyToClipboard=Use Ctrl+C to copy to clipboard
|
||||
SaveUploadedFileWithMask=Save file on server with name "<strong>%s</strong>" (otherwise "%s")
|
||||
OriginFileName=Original filename
|
||||
|
||||
@ -88,5 +88,5 @@ NoTripsToExportCSV=No expense report to export for this period.
|
||||
ExpenseReportPayment=Expense report payment
|
||||
ExpenseReportsToApprove=Expense reports to approve
|
||||
ExpenseReportsToPay=Expense reports to pay
|
||||
CloneExpenseReport=Clone expese report
|
||||
CloneExpenseReport=Clone expense report
|
||||
ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ?
|
||||
Loading…
Reference in New Issue
Block a user