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