Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/expensereport/card.php
This commit is contained in:
Laurent Destailleur 2017-08-22 10:11:32 +02:00
commit b3d1cdf84c
18 changed files with 127 additions and 105 deletions

View File

@ -145,12 +145,12 @@ else if ($action == 'update') {
* View * View
*/ */
$form = new Form($db);
$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); $title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card");
$helpurl = ""; $helpurl = "";
llxHeader("",$title,$helpurl); llxHeader("",$title,$helpurl);
$form = new Form($db);
if ($action == 'create') if ($action == 'create')
{ {
print load_fiche_titre($langs->trans("NewFiscalYear")); print load_fiche_titre($langs->trans("NewFiscalYear"));

View File

@ -131,12 +131,11 @@ if (preg_match('/del_(.*)/',$action,$reg))
* View * 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>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
print "<br>\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

View File

@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
$textobject=$langs->transnoentitiesnoconv("Agenda"); $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>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
print "<br>\n";
$head=agenda_prepare_head(); $head=agenda_prepare_head();

View File

@ -125,11 +125,11 @@ $formother=new FormOther($db);
$arrayofjs=array(); $arrayofjs=array();
$arrayofcss=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>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
print '<br>';
print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -210,7 +210,7 @@ while ($i <= $MAXAGENDA)
$color='AGENDA_EXT_COLOR'.$key; $color='AGENDA_EXT_COLOR'.$key;
$enabled='AGENDA_EXT_ENABLED'.$key; $enabled='AGENDA_EXT_ENABLED'.$key;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Nb // Nb
print '<td width="180" class="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>"; print '<td width="180" class="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>";

View File

@ -174,12 +174,12 @@ else if ($action == 'setdoc')
$formactions=new FormActions($db); $formactions=new FormActions($db);
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); $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>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
print "<br>\n";

View File

@ -71,11 +71,11 @@ if ($actionsave)
if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100; 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>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
print '<br>';
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';

View File

@ -39,6 +39,8 @@ $ref=GETPOST("ref",'alpha');
* View * View
*/ */
$form = new Form($db);
$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); $title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl); llxHeader('', $title, $helpurl);

View File

@ -60,6 +60,8 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer)
* View * View
*/ */
$form = new Form($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info"); $title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info");

View File

@ -39,8 +39,10 @@ $result = restrictedArea($user, 'contrat', $id, '');
/* /*
* View * View
*/ */
$form = new Form($db);
llxHeader('',$langs->trans("Contract"),""); llxHeader('',$langs->trans("Contract"),"");

View File

@ -49,7 +49,7 @@ print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disable
?> ?>
<!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP --> <!-- 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)) { ?> <?php if (empty($conf->dol_use_jmobile)) { ?>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -35,7 +35,7 @@ print top_htmlhead('',$langs->trans('SendNewPassword'));
?> ?>
<!-- BEGIN PHP TEMPLATE PASSWORDFORGOTTEN.TPL.PHP --> <!-- 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)) { ?> <?php if (empty($conf->dol_use_jmobile)) { ?>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -1059,17 +1059,17 @@ if (empty($reshook))
if ($action == "addline" && $user->rights->expensereport->creer) if ($action == "addline" && $user->rights->expensereport->creer)
{ {
$error = 0; $error = 0;
// if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
if (empty($vatrate)) $vatrate = "0.000"; if (empty($vatrate)) $vatrate = "0.000";
$vatrate = price2num($vatrate); $vatrate = price2num($vatrate);
$value_unit=price2num(GETPOST('value_unit'),'MU'); $value_unit=price2num(GETPOST('value_unit'),'MU');
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
$qty = GETPOST('qty','int'); $qty = GETPOST('qty','int');
if (empty($qty)) $qty=1; if (empty($qty)) $qty=1;
if (! $fk_c_type_fees > 0) if (! $fk_c_type_fees > 0)
{ {
$error++; $error++;
@ -1139,7 +1139,7 @@ if (empty($reshook))
unset($fk_projet); unset($fk_projet);
unset($date); unset($date);
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); 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 .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
$sql.= " WHERE e.rowid = '".$id."'"; $sql.= " WHERE e.rowid = '".$id."'";
$sql.= " AND p.fk_expensereport = e.rowid"; $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.= " AND p.fk_typepayment = c.id";
$sql.= " ORDER BY dp"; $sql.= " ORDER BY dp";
@ -2091,7 +2091,7 @@ else
$i++; $i++;
} }
} }
// Add a line // Add a line
if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline' && $user->rights->expensereport->creer) 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); $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, 1);
print '</td>'; print '</td>';
} }
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
{ {
print '<td class="fk_c_exp_tax_cat">'; print '<td class="fk_c_exp_tax_cat">';

View File

@ -39,9 +39,9 @@ class ExpenseReport extends CommonObject
var $picto = 'trip'; var $picto = 'trip';
var $lignes=array(); var $lignes=array();
public $date_debut; public $date_debut;
public $date_fin; public $date_fin;
var $fk_user_validator; var $fk_user_validator;
@ -67,7 +67,7 @@ class ExpenseReport extends CommonObject
// Update // Update
var $date_modif; var $date_modif;
var $fk_user_modif; var $fk_user_modif;
// Refus // Refus
var $date_refuse; var $date_refuse;
var $detail_refuse; var $detail_refuse;
@ -93,7 +93,7 @@ class ExpenseReport extends CommonObject
/* /*
END ACTIONS END ACTIONS
*/ */
/** /**
* Draft * Draft
*/ */
@ -108,18 +108,18 @@ class ExpenseReport extends CommonObject
* Classified approved * Classified approved
*/ */
const STATUS_APPROVED = 5; const STATUS_APPROVED = 5;
/** /**
* Classified refused * Classified refused
*/ */
const STATUS_REFUSED = 99; const STATUS_REFUSED = 99;
/** /**
* Classified paid. * Classified paid.
*/ */
const STATUS_CLOSED = 6; const STATUS_CLOSED = 6;
/** /**
* Constructor * Constructor
@ -296,7 +296,7 @@ class ExpenseReport extends CommonObject
if (empty($fk_user_author)) $fk_user_author = $user->id; 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
@ -938,7 +938,7 @@ class ExpenseReport extends CommonObject
{ {
$this->lines=array(); $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.'.$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.= ' de.total_ht, de.total_tva, de.total_ttc,';
$sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $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.'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.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid';
$sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id; $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); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -969,13 +976,13 @@ class ExpenseReport extends CommonObject
$deplig->dates = $this->db->jdate($objp->date); $deplig->dates = $this->db->jdate($objp->date);
$deplig->fk_expensereport = $objp->fk_expensereport; $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_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_ht = $objp->total_ht;
$deplig->total_tva = $objp->total_tva; $deplig->total_tva = $objp->total_tva;
$deplig->total_ttc = $objp->total_ttc; $deplig->total_ttc = $objp->total_ttc;
$deplig->type_fees_code = empty($objp->code_type_fees)?'TF_OTHER':$objp->code_type_fees; $deplig->type_fees_code = empty($objp->code_type_fees)?'TF_OTHER':$objp->code_type_fees;
$deplig->type_fees_libelle = $objp->libelle_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_ref = $objp->ref_projet;
$deplig->projet_title = $objp->title_projet; $deplig->projet_title = $objp->title_projet;
$deplig->rang = $objp->rang;
$this->lines[$i] = $deplig; $this->lines[$i] = $deplig;
$i++; $i++;
@ -1603,7 +1612,7 @@ class ExpenseReport extends CommonObject
/** /**
* addline * addline
* *
* @param real $qty Qty * @param real $qty Qty
* @param double $up Value init * @param double $up Value init
* @param int $fk_c_type_fees Type payment * @param int $fk_c_type_fees Type payment
@ -1620,33 +1629,33 @@ class ExpenseReport extends CommonObject
global $conf,$langs; 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); 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($qty)) $qty = 0;
if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 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($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($vatrate) || $vatrate < 0) $vatrate = 0;
if (empty($date)) $date = ''; if (empty($date)) $date = '';
if (empty($fk_project)) $fk_project = 0; if (empty($fk_project)) $fk_project = 0;
$qty = price2num($qty); $qty = price2num($qty);
$vatrate = price2num($vatrate); $vatrate = price2num($vatrate);
$up = price2num($up); $up = price2num($up);
if ($this->fk_statut == self::STATUS_DRAFT) if ($this->fk_statut == self::STATUS_DRAFT)
{ {
$this->db->begin(); $this->db->begin();
$this->line = new ExpenseReportLine($this->db); $this->line = new ExpenseReportLine($this->db);
$seller = ''; // seller is unknown $seller = ''; // seller is unknown
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller);
$this->line->value_unit = $up; $this->line->value_unit = $up;
$this->line->vatrate = price2num($vatrate); $this->line->vatrate = price2num($vatrate);
$this->line->total_ttc = $tmp[2]; $this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0]; $this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1]; $this->line->total_tva = $tmp[1];
$this->line->fk_expensereport = $this->id; $this->line->fk_expensereport = $this->id;
$this->line->qty = $qty; $this->line->qty = $qty;
$this->line->date = $date; $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->fk_c_exp_tax_cat = $fk_c_exp_tax_cat;
$this->line->comments = $comments; $this->line->comments = $comments;
$this->line->fk_projet = $fk_project; $this->line->fk_projet = $fk_project;
$this->applyOffset(); $this->applyOffset();
$this->checkRules($type, $seller); $this->checkRules($type, $seller);
$result=$this->line->insert(0, true); $result=$this->line->insert(0, true);
if ($result > 0) if ($result > 0)
{ {
@ -1687,50 +1696,50 @@ class ExpenseReport extends CommonObject
$this->error = 'ErrorExpenseNotDraft'; $this->error = 'ErrorExpenseNotDraft';
return -3; return -3;
} }
} }
/** /**
* Check constraint of rules and update price if needed * 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 * @param string $seller seller, but actually he is unknown
* @return true or false * @return true or false
*/ */
function checkRules($type=0, $seller='') function checkRules($type=0, $seller='')
{ {
global $user,$conf,$db,$langs; global $user,$conf,$db,$langs;
$langs->load('trips'); $langs->load('trips');
if (empty($conf->global->MAIN_USE_EXPENSE_RULE)) return true; // if don't use rules 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); $rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author);
$violation = 0; $violation = 0;
$rule_warning_message_tab = array(); $rule_warning_message_tab = array();
$current_total_ttc = $this->line->total_ttc; $current_total_ttc = $this->line->total_ttc;
$new_current_total_ttc = $this->line->total_ttc; $new_current_total_ttc = $this->line->total_ttc;
// check if one is violated // check if one is violated
foreach ($rulestocheck as $rule) 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); 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 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 $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) if ($amount_to_test > $rule->amount)
{ {
$violation++; $violation++;
if ($rule->restrictive) if ($rule->restrictive)
{ {
$this->error = 'ExpenseReportConstraintViolationError'; $this->error = 'ExpenseReportConstraintViolationError';
$this->errors[] = $this->error; $this->errors[] = $this->error;
$new_current_total_ttc -= $amount_to_test - $rule->amount; // ex, entered 16€, limit 12€, subtracts 4€; $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))); $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->error = 'ExpenseReportConstraintViolationWarning';
$this->errors[] = $this->error; $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)); $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 // No break, we sould test if another rule is violated
} }
} }
$this->line->rule_warning_message = implode('\n', $rule_warning_message_tab); $this->line->rule_warning_message = implode('\n', $rule_warning_message_tab);
if ($violation > 0) 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); $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->value_unit = $tmp[5];
$this->line->total_ttc = $tmp[2]; $this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0]; $this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1]; $this->line->total_tva = $tmp[1];
return false; return false;
} }
else return true; else return true;
@ -1764,15 +1773,15 @@ class ExpenseReport extends CommonObject
/** /**
* Method to apply the offset if needed * Method to apply the offset if needed
* *
* @return boolean true=applied, false=not applied * @return boolean true=applied, false=not applied
*/ */
function applyOffset() function applyOffset()
{ {
global $conf; global $conf;
if (empty($conf->global->MAIN_USE_EXPENSE_IK)) return false; if (empty($conf->global->MAIN_USE_EXPENSE_IK)) return false;
$userauthor = new User($this->db); $userauthor = new User($this->db);
if ($userauthor->fetch($this->fk_user_author) <= 0) if ($userauthor->fetch($this->fk_user_author) <= 0)
{ {
@ -1780,39 +1789,39 @@ class ExpenseReport extends CommonObject
$this->errors[] = 'ErrorCantFetchUser'; $this->errors[] = 'ErrorCantFetchUser';
return false; return false;
} }
$range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); $range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat);
if (empty($range)) if (empty($range))
{ {
$this->error = 'ErrorNoRangeAvailable'; $this->error = 'ErrorNoRangeAvailable';
$this->errors[] = 'ErrorNoRangeAvailable'; $this->errors[] = 'ErrorNoRangeAvailable';
return false; return false;
} }
if (!empty($conf->global->MAIN_EXPENSE_APPLY_ENTIRE_OFFSET)) $offset = $range->offset; 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 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 // Test if offset has been applied for the current month
if (!$this->offsetAlreadyGiven()) if (!$this->offsetAlreadyGiven())
{ {
$new_up = $range->coef + ($offset / $this->line->qty); $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); $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->value_unit = $tmp[5];
$this->line->total_ttc = $tmp[2]; $this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0]; $this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1]; $this->line->total_tva = $tmp[1];
return true; return true;
} }
return false; return false;
} }
/** /**
* If the sql find any rows then the offset is already given (offset is applied at the first expense report line) * If the sql find any rows then the offset is already given (offset is applied at the first expense report line)
* *
* @return bool * @return bool
*/ */
function offsetAlreadyGiven() function offsetAlreadyGiven()
@ -1823,7 +1832,7 @@ class ExpenseReport extends CommonObject
$sql.= ' WHERE e.fk_user_author = '.(int) $this->fk_user_author; $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').'"'; $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; if (!empty($this->line->id)) $sql.= ' AND d.rowid <> '.$this->line->id;
dol_syslog(get_class($this)."::offsetAlreadyGiven sql=".$sql); dol_syslog(get_class($this)."::offsetAlreadyGiven sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -1835,10 +1844,10 @@ class ExpenseReport extends CommonObject
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
return false; return false;
} }
/** /**
* updateline * updateline
* *
@ -1938,7 +1947,7 @@ class ExpenseReport extends CommonObject
$this->applyOffset(); $this->applyOffset();
$this->checkRules(); $this->checkRules();
$result = $this->line->update($user); $result = $this->line->update($user);
if ($result > 0) if ($result > 0)
{ {
@ -2389,7 +2398,7 @@ class ExpenseReportLine
$this->qty = price2num($this->qty); $this->qty = price2num($this->qty);
$this->vatrate = price2num($this->vatrate); $this->vatrate = price2num($this->vatrate);
if (empty($this->fk_c_exp_tax_cat)) $this->fk_c_exp_tax_cat = 0; if (empty($this->fk_c_exp_tax_cat)) $this->fk_c_exp_tax_cat = 0;
$this->db->begin(); $this->db->begin();
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det';
@ -2428,7 +2437,7 @@ class ExpenseReportLine
$error++; $error++;
$this->error = $tmpparent->error; $this->error = $tmpparent->error;
$this->errors = $tmpparent->errors; $this->errors = $tmpparent->errors;
} }
} }
} }
else else
@ -2449,10 +2458,10 @@ class ExpenseReportLine
return -2; return -2;
} }
} }
/** /**
* Function to get total amount in expense reports for a same rule * Function to get total amount in expense reports for a same rule
* *
* @param ExpenseReportRule $rule object rule to check * @param ExpenseReportRule $rule object rule to check
* @param int $fk_user user author id * @param int $fk_user user author id
* @param string $mode day|EX_DAY / month|EX_MON / year|EX_YEA to get amount * @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') public function getExpAmount(ExpenseReportRule $rule, $fk_user, $mode='day')
{ {
$amount = 0; $amount = 0;
$sql = 'SELECT SUM(d.total_ttc) as total_amount'; $sql = 'SELECT SUM(d.total_ttc) as total_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)'; $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').'\''; 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 == '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').'\''; 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); dol_syslog('ExpenseReportLine::getExpAmountByDay sql='.$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2488,11 +2497,11 @@ class ExpenseReportLine
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
return $amount + $this->total_ttc; return $amount + $this->total_ttc;
} }
/** /**
* update * update
* *

View File

@ -52,6 +52,8 @@ if (! $object->fetch($id, $ref) > 0)
* View * View
*/ */
$form = new Form($db);
llxHeader('',$langs->trans("Intervention")); llxHeader('',$langs->trans("Intervention"));
$object->fetch_thirdparty(); $object->fetch_thirdparty();

View File

@ -46,6 +46,8 @@ $object = new FactureFournisseur($db);
* View * View
*/ */
$form = new Form($db);
$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Info'); $title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Info');
$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
llxHeader('', $title, $helpurl); llxHeader('', $title, $helpurl);

View File

@ -43,6 +43,8 @@ $result = restrictedArea($user, 'loan', $id, '','');
* View * View
*/ */
$form = new Form($db);
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Info"); $title = $langs->trans("Loan") . ' - ' . $langs->trans("Info");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt'; $help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$title,$help_url); llxHeader("",$title,$help_url);

View File

@ -43,6 +43,8 @@ $result = restrictedArea($user, 'supplier_proposal', $id);
* View * View
*/ */
$form = new Form($db);
llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'); llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$object = new SupplierProposal($db); $object = new SupplierProposal($db);
@ -57,8 +59,8 @@ dol_fiche_head($head, 'info', $langs->trans('CommRequest'), -1, 'supplier_propos
// Supplier proposal card // Supplier proposal card
$linkback = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref supplier // Ref supplier
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); //$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>'; $morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';

View File

@ -93,10 +93,10 @@ print '<br>'.$langs->trans("ForDocumentationSeeWiki",$urlwiki,$urlwiki);
print '<br>'; print '<br>';
$urlforum='https://www.dolibarr.org/forum/'; $urlforum='https://www.dolibarr.org/forum/';
$urlforumlocal='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('/fr/i',$langs->defaultlang)) $urlforumlocal='https://www.dolibarr.fr/forum/';
if (preg_match('/es/i',$langs->defaultlang)) $urlforumlocal='http://www.dolibarr.es/index.php/foro/'; 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('/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>'; print '<br>'.$langs->trans("ForAnswersSeeForum",$urlforumlocal,$urlforumlocal).'<br>';
if ($urlforumlocal != $urlforum) print '<b><a href="'.$urlforum.'">'.$urlforum.'</a></b>'; if ($urlforumlocal != $urlforum) print '<b><a href="'.$urlforum.'">'.$urlforum.'</a></b>';
print '</td></tr></table>'; print '</td></tr></table>';