Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/expensereport/card.php
This commit is contained in:
commit
b3d1cdf84c
@ -145,12 +145,12 @@ else if ($action == 'update') {
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card");
|
||||
$helpurl = "";
|
||||
llxHeader("",$title,$helpurl);
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print load_fiche_titre($langs->trans("NewFiscalYear"));
|
||||
|
||||
@ -131,12 +131,11 @@ if (preg_match('/del_(.*)/',$action,$reg))
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
|
||||
@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
|
||||
|
||||
$textobject=$langs->transnoentitiesnoconv("Agenda");
|
||||
|
||||
llxHeader('',$langs->trans("AgendaSetup"));
|
||||
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
|
||||
print "<br>\n";
|
||||
|
||||
$head=agenda_prepare_head();
|
||||
|
||||
|
||||
@ -125,11 +125,11 @@ $formother=new FormOther($db);
|
||||
$arrayofjs=array();
|
||||
$arrayofcss=array();
|
||||
|
||||
llxHeader('',$langs->trans("AgendaSetup"),'','',0,0,$arrayofjs,$arrayofcss);
|
||||
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
llxHeader('',$langs->trans("AgendaSetup"),$wikihelp,'',0,0,$arrayofjs,$arrayofcss);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
|
||||
print '<br>';
|
||||
|
||||
print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -210,7 +210,7 @@ while ($i <= $MAXAGENDA)
|
||||
$color='AGENDA_EXT_COLOR'.$key;
|
||||
$enabled='AGENDA_EXT_ENABLED'.$key;
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
// Nb
|
||||
print '<td width="180" class="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>";
|
||||
|
||||
@ -174,12 +174,12 @@ else if ($action == 'setdoc')
|
||||
|
||||
$formactions=new FormActions($db);
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
llxHeader();
|
||||
|
||||
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
llxHeader('', $langs->trans("AgendaSetup"),$wikihelp);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -71,11 +71,11 @@ if ($actionsave)
|
||||
|
||||
if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
|
||||
|
||||
llxHeader();
|
||||
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
||||
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
|
||||
@ -39,6 +39,8 @@ $ref=GETPOST("ref",'alpha');
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info');
|
||||
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
@ -60,6 +60,8 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer)
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
|
||||
$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info");
|
||||
|
||||
@ -39,8 +39,10 @@ $result = restrictedArea($user, 'contrat', $id, '');
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('',$langs->trans("Contract"),"");
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disable
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->
|
||||
|
||||
<body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' style="background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
|
||||
<body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
|
||||
|
||||
<?php if (empty($conf->dol_use_jmobile)) { ?>
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -35,7 +35,7 @@ print top_htmlhead('',$langs->trans('SendNewPassword'));
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE PASSWORDFORGOTTEN.TPL.PHP -->
|
||||
|
||||
<body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' style="background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
|
||||
<body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
|
||||
|
||||
<?php if (empty($conf->dol_use_jmobile)) { ?>
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -1059,17 +1059,17 @@ if (empty($reshook))
|
||||
if ($action == "addline" && $user->rights->expensereport->creer)
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
|
||||
// if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
|
||||
if (empty($vatrate)) $vatrate = "0.000";
|
||||
$vatrate = price2num($vatrate);
|
||||
|
||||
|
||||
$value_unit=price2num(GETPOST('value_unit'),'MU');
|
||||
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
|
||||
|
||||
|
||||
$qty = GETPOST('qty','int');
|
||||
if (empty($qty)) $qty=1;
|
||||
|
||||
|
||||
if (! $fk_c_type_fees > 0)
|
||||
{
|
||||
$error++;
|
||||
@ -1139,7 +1139,7 @@ if (empty($reshook))
|
||||
unset($fk_projet);
|
||||
|
||||
unset($date);
|
||||
|
||||
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
@ -1848,7 +1848,7 @@ else
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
|
||||
$sql.= " WHERE e.rowid = '".$id."'";
|
||||
$sql.= " AND p.fk_expensereport = e.rowid";
|
||||
$sql.= " AND e.entity = ".$conf->entity;
|
||||
$sql.= ' AND e.entity IN ('.getEntity('expensereport').')';
|
||||
$sql.= " AND p.fk_typepayment = c.id";
|
||||
$sql.= " ORDER BY dp";
|
||||
|
||||
@ -2091,7 +2091,7 @@ else
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add a line
|
||||
if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline' && $user->rights->expensereport->creer)
|
||||
{
|
||||
@ -2124,7 +2124,7 @@ else
|
||||
$formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, 1);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
|
||||
{
|
||||
print '<td class="fk_c_exp_tax_cat">';
|
||||
|
||||
@ -39,9 +39,9 @@ class ExpenseReport extends CommonObject
|
||||
var $picto = 'trip';
|
||||
|
||||
var $lignes=array();
|
||||
|
||||
|
||||
public $date_debut;
|
||||
|
||||
|
||||
public $date_fin;
|
||||
|
||||
var $fk_user_validator;
|
||||
@ -67,7 +67,7 @@ class ExpenseReport extends CommonObject
|
||||
// Update
|
||||
var $date_modif;
|
||||
var $fk_user_modif;
|
||||
|
||||
|
||||
// Refus
|
||||
var $date_refuse;
|
||||
var $detail_refuse;
|
||||
@ -93,7 +93,7 @@ class ExpenseReport extends CommonObject
|
||||
/*
|
||||
END ACTIONS
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Draft
|
||||
*/
|
||||
@ -108,18 +108,18 @@ class ExpenseReport extends CommonObject
|
||||
* Classified approved
|
||||
*/
|
||||
const STATUS_APPROVED = 5;
|
||||
|
||||
|
||||
/**
|
||||
* Classified refused
|
||||
*/
|
||||
const STATUS_REFUSED = 99;
|
||||
|
||||
|
||||
/**
|
||||
* Classified paid.
|
||||
*/
|
||||
const STATUS_CLOSED = 6;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -296,7 +296,7 @@ class ExpenseReport extends CommonObject
|
||||
if (empty($fk_user_author)) $fk_user_author = $user->id;
|
||||
|
||||
$this->context['createfromclone'] = 'createfromclone';
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// get extrafields so they will be clone
|
||||
@ -938,7 +938,7 @@ class ExpenseReport extends CommonObject
|
||||
{
|
||||
$this->lines=array();
|
||||
|
||||
$sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date,';
|
||||
$sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,';
|
||||
$sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet, de.tva_tx,';
|
||||
$sql.= ' de.total_ht, de.total_tva, de.total_ttc,';
|
||||
$sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,';
|
||||
@ -947,7 +947,14 @@ class ExpenseReport extends CommonObject
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid';
|
||||
$sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id;
|
||||
$sql.= ' ORDER BY de.date ASC';
|
||||
if (! empty($conf->global->EXPENSEREPORT_LINES_SORTED_BY_ROWID))
|
||||
{
|
||||
$sql.= ' ORDER BY de.rang ASC, de.rowid ASC';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= ' ORDER BY de.rang ASC, de.date ASC';
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -969,13 +976,13 @@ class ExpenseReport extends CommonObject
|
||||
$deplig->dates = $this->db->jdate($objp->date);
|
||||
|
||||
$deplig->fk_expensereport = $objp->fk_expensereport;
|
||||
$deplig->fk_c_type_fees = $objp->fk_c_type_fees;
|
||||
$deplig->fk_c_type_fees = $objp->fk_c_type_fees;
|
||||
$deplig->fk_c_exp_tax_cat = $objp->fk_c_exp_tax_cat;
|
||||
$deplig->fk_projet = $objp->fk_projet;
|
||||
$deplig->fk_projet = $objp->fk_projet;
|
||||
|
||||
$deplig->total_ht = $objp->total_ht;
|
||||
$deplig->total_tva = $objp->total_tva;
|
||||
$deplig->total_ttc = $objp->total_ttc;
|
||||
$deplig->total_ht = $objp->total_ht;
|
||||
$deplig->total_tva = $objp->total_tva;
|
||||
$deplig->total_ttc = $objp->total_ttc;
|
||||
|
||||
$deplig->type_fees_code = empty($objp->code_type_fees)?'TF_OTHER':$objp->code_type_fees;
|
||||
$deplig->type_fees_libelle = $objp->libelle_type_fees;
|
||||
@ -984,6 +991,8 @@ class ExpenseReport extends CommonObject
|
||||
$deplig->projet_ref = $objp->ref_projet;
|
||||
$deplig->projet_title = $objp->title_projet;
|
||||
|
||||
$deplig->rang = $objp->rang;
|
||||
|
||||
$this->lines[$i] = $deplig;
|
||||
|
||||
$i++;
|
||||
@ -1603,7 +1612,7 @@ class ExpenseReport extends CommonObject
|
||||
|
||||
/**
|
||||
* addline
|
||||
*
|
||||
*
|
||||
* @param real $qty Qty
|
||||
* @param double $up Value init
|
||||
* @param int $fk_c_type_fees Type payment
|
||||
@ -1620,33 +1629,33 @@ class ExpenseReport extends CommonObject
|
||||
global $conf,$langs;
|
||||
|
||||
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 (empty($qty)) $qty = 0;
|
||||
if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 0;
|
||||
if (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) $fk_c_exp_tax_cat = 0;
|
||||
if (empty($vatrate) || $vatrate < 0) $vatrate = 0;
|
||||
if (empty($date)) $date = '';
|
||||
if (empty($fk_project)) $fk_project = 0;
|
||||
|
||||
|
||||
$qty = price2num($qty);
|
||||
$vatrate = price2num($vatrate);
|
||||
$up = price2num($up);
|
||||
|
||||
|
||||
if ($this->fk_statut == self::STATUS_DRAFT)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$this->line = new ExpenseReportLine($this->db);
|
||||
|
||||
$seller = ''; // seller is unknown
|
||||
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
|
||||
|
||||
|
||||
$this->line->value_unit = $up;
|
||||
$this->line->vatrate = price2num($vatrate);
|
||||
$this->line->total_ttc = $tmp[2];
|
||||
$this->line->total_ht = $tmp[0];
|
||||
$this->line->total_tva = $tmp[1];
|
||||
|
||||
|
||||
$this->line->fk_expensereport = $this->id;
|
||||
$this->line->qty = $qty;
|
||||
$this->line->date = $date;
|
||||
@ -1654,10 +1663,10 @@ class ExpenseReport extends CommonObject
|
||||
$this->line->fk_c_exp_tax_cat = $fk_c_exp_tax_cat;
|
||||
$this->line->comments = $comments;
|
||||
$this->line->fk_projet = $fk_project;
|
||||
|
||||
|
||||
$this->applyOffset();
|
||||
$this->checkRules($type, $seller);
|
||||
|
||||
|
||||
$result=$this->line->insert(0, true);
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -1687,50 +1696,50 @@ class ExpenseReport extends CommonObject
|
||||
$this->error = 'ErrorExpenseNotDraft';
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check constraint of rules and update price if needed
|
||||
*
|
||||
* @param int $type type of line
|
||||
*
|
||||
* @param int $type type of line
|
||||
* @param string $seller seller, but actually he is unknown
|
||||
* @return true or false
|
||||
*/
|
||||
function checkRules($type=0, $seller='')
|
||||
{
|
||||
global $user,$conf,$db,$langs;
|
||||
|
||||
|
||||
$langs->load('trips');
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_USE_EXPENSE_RULE)) return true; // if don't use rules
|
||||
|
||||
|
||||
$rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author);
|
||||
|
||||
|
||||
$violation = 0;
|
||||
$rule_warning_message_tab = array();
|
||||
|
||||
|
||||
$current_total_ttc = $this->line->total_ttc;
|
||||
$new_current_total_ttc = $this->line->total_ttc;
|
||||
|
||||
|
||||
// check if one is violated
|
||||
foreach ($rulestocheck as $rule)
|
||||
{
|
||||
if (in_array($rule->code_expense_rules_type, array('EX_DAY', 'EX_MON', 'EX_YEA'))) $amount_to_test = $this->line->getExpAmount($rule, $this->fk_user_author, $rule->code_expense_rules_type);
|
||||
else $amount_to_test = $current_total_ttc; // EX_EXP
|
||||
|
||||
|
||||
$amount_to_test = $amount_to_test - $current_total_ttc + $new_current_total_ttc; // if amount as been modified by a previous rule
|
||||
|
||||
|
||||
if ($amount_to_test > $rule->amount)
|
||||
{
|
||||
$violation++;
|
||||
|
||||
|
||||
if ($rule->restrictive)
|
||||
{
|
||||
$this->error = 'ExpenseReportConstraintViolationError';
|
||||
$this->errors[] = $this->error;
|
||||
|
||||
|
||||
$new_current_total_ttc -= $amount_to_test - $rule->amount; // ex, entered 16€, limit 12€, subtracts 4€;
|
||||
$rule_warning_message_tab[] = $langs->trans('ExpenseReportConstraintViolationError', $rule->id, price($amount_to_test,0,$langs,1,-1,-1,$conf->currency), price($rule->amount,0,$langs,1,-1,-1,$conf->currency), $langs->trans('by'.$rule->code_expense_rules_type, price($new_current_total_ttc,0,$langs,1,-1,-1,$conf->currency)));
|
||||
}
|
||||
@ -1738,25 +1747,25 @@ class ExpenseReport extends CommonObject
|
||||
{
|
||||
$this->error = 'ExpenseReportConstraintViolationWarning';
|
||||
$this->errors[] = $this->error;
|
||||
|
||||
|
||||
$rule_warning_message_tab[] = $langs->trans('ExpenseReportConstraintViolationWarning', $rule->id, price($amount_to_test,0,$langs,1,-1,-1,$conf->currency), price($rule->amount,0,$langs,1,-1,-1,$conf->currency), $langs->trans('nolimitby'.$rule->code_expense_rules_type));
|
||||
}
|
||||
|
||||
|
||||
// No break, we sould test if another rule is violated
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->line->rule_warning_message = implode('\n', $rule_warning_message_tab);
|
||||
|
||||
|
||||
if ($violation > 0)
|
||||
{
|
||||
$tmp = calcul_price_total($this->line->qty, $new_current_total_ttc/$this->line->qty, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
|
||||
|
||||
|
||||
$this->line->value_unit = $tmp[5];
|
||||
$this->line->total_ttc = $tmp[2];
|
||||
$this->line->total_ht = $tmp[0];
|
||||
$this->line->total_tva = $tmp[1];
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
@ -1764,15 +1773,15 @@ class ExpenseReport extends CommonObject
|
||||
|
||||
/**
|
||||
* Method to apply the offset if needed
|
||||
*
|
||||
*
|
||||
* @return boolean true=applied, false=not applied
|
||||
*/
|
||||
function applyOffset()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_USE_EXPENSE_IK)) return false;
|
||||
|
||||
|
||||
$userauthor = new User($this->db);
|
||||
if ($userauthor->fetch($this->fk_user_author) <= 0)
|
||||
{
|
||||
@ -1780,39 +1789,39 @@ class ExpenseReport extends CommonObject
|
||||
$this->errors[] = 'ErrorCantFetchUser';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat);
|
||||
|
||||
|
||||
if (empty($range))
|
||||
{
|
||||
$this->error = 'ErrorNoRangeAvailable';
|
||||
$this->errors[] = 'ErrorNoRangeAvailable';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($conf->global->MAIN_EXPENSE_APPLY_ENTIRE_OFFSET)) $offset = $range->offset;
|
||||
else $offset = $range->offset / 12; // The amount of offset is a global value for the year
|
||||
|
||||
|
||||
// Test if offset has been applied for the current month
|
||||
if (!$this->offsetAlreadyGiven())
|
||||
{
|
||||
$new_up = $range->coef + ($offset / $this->line->qty);
|
||||
$tmp = calcul_price_total($this->line->qty, $new_up, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
|
||||
|
||||
|
||||
$this->line->value_unit = $tmp[5];
|
||||
$this->line->total_ttc = $tmp[2];
|
||||
$this->line->total_ht = $tmp[0];
|
||||
$this->line->total_tva = $tmp[1];
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the sql find any rows then the offset is already given (offset is applied at the first expense report line)
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function offsetAlreadyGiven()
|
||||
@ -1823,7 +1832,7 @@ class ExpenseReport extends CommonObject
|
||||
$sql.= ' WHERE e.fk_user_author = '.(int) $this->fk_user_author;
|
||||
$sql.= ' AND YEAR(d.date) = "'.dol_print_date($this->line->date, '%Y').'" AND MONTH(d.date) = "'.dol_print_date($this->line->date, '%m').'"';
|
||||
if (!empty($this->line->id)) $sql.= ' AND d.rowid <> '.$this->line->id;
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::offsetAlreadyGiven sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -1835,10 +1844,10 @@ class ExpenseReport extends CommonObject
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* updateline
|
||||
*
|
||||
@ -1938,7 +1947,7 @@ class ExpenseReport extends CommonObject
|
||||
|
||||
$this->applyOffset();
|
||||
$this->checkRules();
|
||||
|
||||
|
||||
$result = $this->line->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -2389,7 +2398,7 @@ class ExpenseReportLine
|
||||
$this->qty = price2num($this->qty);
|
||||
$this->vatrate = price2num($this->vatrate);
|
||||
if (empty($this->fk_c_exp_tax_cat)) $this->fk_c_exp_tax_cat = 0;
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det';
|
||||
@ -2428,7 +2437,7 @@ class ExpenseReportLine
|
||||
$error++;
|
||||
$this->error = $tmpparent->error;
|
||||
$this->errors = $tmpparent->errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2449,10 +2458,10 @@ class ExpenseReportLine
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to get total amount in expense reports for a same rule
|
||||
*
|
||||
*
|
||||
* @param ExpenseReportRule $rule object rule to check
|
||||
* @param int $fk_user user author id
|
||||
* @param string $mode day|EX_DAY / month|EX_MON / year|EX_YEA to get amount
|
||||
@ -2461,7 +2470,7 @@ class ExpenseReportLine
|
||||
public function getExpAmount(ExpenseReportRule $rule, $fk_user, $mode='day')
|
||||
{
|
||||
$amount = 0;
|
||||
|
||||
|
||||
$sql = 'SELECT SUM(d.total_ttc) as total_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d';
|
||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)';
|
||||
@ -2471,9 +2480,9 @@ class ExpenseReportLine
|
||||
if ($mode == 'day' || $mode == 'EX_DAY') $sql .= ' AND d.date = \''.dol_print_date($this->date, '%Y-%m-%d').'\'';
|
||||
elseif ($mode == 'mon' || $mode == 'EX_MON') $sql .= ' AND DATE_FORMAT(d.date, \'%Y-%m\') = \''.dol_print_date($this->date, '%Y-%m').'\'';
|
||||
elseif ($mode == 'year' || $mode == 'EX_YEA') $sql .= ' AND DATE_FORMAT(d.date, \'%Y\') = \''.dol_print_date($this->date, '%Y').'\'';
|
||||
|
||||
|
||||
dol_syslog('ExpenseReportLine::getExpAmountByDay sql='.$sql);
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -2488,11 +2497,11 @@ class ExpenseReportLine
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $amount + $this->total_ttc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update
|
||||
*
|
||||
|
||||
@ -52,6 +52,8 @@ if (! $object->fetch($id, $ref) > 0)
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('',$langs->trans("Intervention"));
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
@ -46,6 +46,8 @@ $object = new FactureFournisseur($db);
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Info');
|
||||
$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
@ -43,6 +43,8 @@ $result = restrictedArea($user, 'loan', $id, '','');
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Info");
|
||||
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
||||
llxHeader("",$title,$help_url);
|
||||
|
||||
@ -43,6 +43,8 @@ $result = restrictedArea($user, 'supplier_proposal', $id);
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
|
||||
|
||||
$object = new SupplierProposal($db);
|
||||
@ -57,8 +59,8 @@ dol_fiche_head($head, 'info', $langs->trans('CommRequest'), -1, 'supplier_propos
|
||||
|
||||
// Supplier proposal card
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
|
||||
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Ref supplier
|
||||
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
|
||||
@ -99,11 +101,11 @@ if (! empty($conf->projet->enabled))
|
||||
}
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
@ -93,10 +93,10 @@ print '<br>'.$langs->trans("ForDocumentationSeeWiki",$urlwiki,$urlwiki);
|
||||
print '<br>';
|
||||
$urlforum='https://www.dolibarr.org/forum/';
|
||||
$urlforumlocal='https://www.dolibarr.org/forum/';
|
||||
if (preg_match('/fr/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.fr/forum/';
|
||||
if (preg_match('/es/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.es/index.php/foro/';
|
||||
if (preg_match('/fr/i',$langs->defaultlang)) $urlforumlocal='https://www.dolibarr.fr/forum/';
|
||||
if (preg_match('/es/i',$langs->defaultlang)) $urlforumlocal='https://www.dolibarr.es/foro/';
|
||||
if (preg_match('/it/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.it/forum/';
|
||||
if (preg_match('/gr/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.gr/forum/';
|
||||
if (preg_match('/gr/i',$langs->defaultlang)) $urlforumlocal='https://www.dolibarr.gr/forum/';
|
||||
print '<br>'.$langs->trans("ForAnswersSeeForum",$urlforumlocal,$urlforumlocal).'<br>';
|
||||
if ($urlforumlocal != $urlforum) print '<b><a href="'.$urlforum.'">'.$urlforum.'</a></b>';
|
||||
print '</td></tr></table>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user