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

Conflicts:
	htdocs/expensereport/class/expensereport.class.php
This commit is contained in:
Laurent Destailleur 2017-02-27 01:19:03 +01:00
commit 4f24613de0
5 changed files with 34 additions and 18 deletions

View File

@ -146,9 +146,10 @@ class Utils
* @param string $type 'mysql', 'postgresql', ...
* @param int $usedefault 1=Use default backup profile (Set this to 1 when used as cron)
* @param string $file 'auto' or filename to build
* @param int $keeplastnfiles Keep only last n files (not used yet)
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
*/
function dumpDatabase($compression='none', $type='auto', $usedefault=1, $file='auto')
function dumpDatabase($compression='none', $type='auto', $usedefault=1, $file='auto', $keeplastnfiles=0)
{
global $db, $conf, $langs, $dolibarr_main_data_root;
global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass;

View File

@ -102,7 +102,7 @@ class modCron extends DolibarrModules
// Cronjobs
$this->cronjobs = array(
0=>array('label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>10, 'status'=>1, 'test'=>true),
1=>array('label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>20, 'status'=>0, 'test'=>in_array($db->type, array('mysql','mysqli'))),
1=>array('label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>20, 'status'=>0, 'test'=>in_array($db->type, array('mysql','mysqli'))),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
);

View File

@ -1033,7 +1033,6 @@ if (empty($reshook))
// if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
if (empty($vatrate)) $vatrate = "0.000";
$object_ligne->vatrate = price2num($vatrate);
$object_ligne->fk_projet = $fk_projet;
@ -1162,6 +1161,10 @@ if (empty($reshook))
$qty = GETPOST('qty');
$value_unit = GETPOST('value_unit');
$vatrate = GETPOST('vatrate');
// 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);
if (! GETPOST('fk_c_type_fees') > 0)
{
@ -1169,7 +1172,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$action='';
}
if (GETPOST('vatrate') < 0 || GETPOST('vatrate') == '')
if ((int) $vatrate < 0 || $vatrate == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors');
@ -2176,7 +2179,7 @@ if ($action != 'create' && $action != 'edit')
*/
if ($user->rights->expensereport->creer && $object->fk_statut==0)
{
if (in_array($object->fk_user_author, $user->getAllChildIds(1)))
if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance))
{
// Modify
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a></div>';

View File

@ -60,7 +60,7 @@ class ExpenseReport extends CommonObject
// Create
var $date_create;
var $fk_user_author; // the user the expense report is for (not really the author)
var $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
// Update
var $date_modif;
@ -126,9 +126,10 @@ class ExpenseReport extends CommonObject
global $conf;
$now = dol_now();
$error = 0;
$error = 0;
$fuserid = $this->fk_user_author;
$fuserid = $this->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
if (empty($fuserid)) $fuserid = $user->id;
$this->db->begin();
@ -276,7 +277,7 @@ class ExpenseReport extends CommonObject
$this->statut=0;
// Clear fields
$this->fk_user_author = $user->id;
$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_valid = '';
$this->date_create = '';
$this->date_creation = '';
@ -323,10 +324,18 @@ class ExpenseReport extends CommonObject
* update
*
* @param User $user User making change
<<<<<<< HEAD
* @param int $notrigger Disable triggers
=======
* @param User $newuser New user we want to have the expense report on.
>>>>>>> branch '5.0' of git@github.com:Dolibarr/dolibarr.git
* @return int <0 if KO, >0 if OK
*/
<<<<<<< HEAD
function update($user, $notrigger = 0)
=======
function update($user, $userofexpensereport=null)
>>>>>>> branch '5.0' of git@github.com:Dolibarr/dolibarr.git
{
global $langs;
@ -339,10 +348,13 @@ class ExpenseReport extends CommonObject
$sql.= " , total_tva = ".$this->total_tva;
$sql.= " , date_debut = '".$this->db->idate($this->date_debut)."'";
$sql.= " , date_fin = '".$this->db->idate($this->date_fin)."'";
$sql.= " , fk_user_author = ".($user->id > 0 ? "'".$user->id."'":"null");
if ($userofexpensereport && is_object($userofexpensereport))
{
$sql.= " , fk_user_author = ".($userofexpensereport->id > 0 ? "'".$userofexpensereport->id."'":"null"); // Note fk_user_author is not the 'author' but the guy the expense report is for.
}
$sql.= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null");
$sql.= " , fk_user_valid = ".($this->fk_user_valid > 0 ? $this->fk_user_valid:"null");
$sql.= " , fk_user_modif = ".($this->fk_user_modif > 0 ? $this->fk_user_modif:"null");
$sql.= " , fk_user_modif = ".$user->id;
$sql.= " , fk_statut = ".($this->fk_statut >= 0 ? $this->fk_statut:'0');
$sql.= " , fk_c_paiement = ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null");
$sql.= " , note_public = ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"''");
@ -436,7 +448,7 @@ class ExpenseReport extends CommonObject
$this->date_refuse = $this->db->jdate($obj->date_refuse);
$this->date_cancel = $this->db->jdate($obj->date_cancel);
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_author = $obj->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
$this->fk_user_modif = $obj->fk_user_modif;
$this->fk_user_validator = $obj->fk_user_validator;
$this->fk_user_valid = $obj->fk_user_valid;
@ -1036,7 +1048,7 @@ class ExpenseReport extends CommonObject
{
$prefix="ER";
if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX;
$this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d');
$this->ref = str_replace(' ','_', $this->user_author_infos).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d');
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// We rename directory in order to avoid losing the attachments

View File

@ -58,11 +58,11 @@ CronStatusInactiveBtn=Disable
CronTaskInactive=This job is disabled
CronId=Id
CronClassFile=Classes (filename.class.php)
CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value of module is <i>product</i>
CronClassFileHelp=The file name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/<u>product.class.php</u>, the value of class file name is <i>product.class.php</i>
CronObjectHelp=The object name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is <i>Product</i>
CronMethodHelp=The object method to launch. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of method is is <i>fecth</i>
CronArgsHelp=The method arguments. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of paramters can be <i>0, ProductRef</i>
CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value of module is <i>product</i>
CronClassFileHelp=The file name to load. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/<u>product.class.php</u>, the value of class file name is <i>product.class.php</i>
CronObjectHelp=The object name to load. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is <i>Product</i>
CronMethodHelp=The object method to launch. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of method is is <i>fecth</i>
CronArgsHelp=The method arguments. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of paramters can be <i>0, ProductRef</i>
CronCommandHelp=The system command line to execute.
CronCreateJob=Create new Scheduled Job
CronFrom=From