Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2019-12-18 14:20:36 +00:00
parent 2de16c3c66
commit 455178ff73
34 changed files with 2615 additions and 2615 deletions

View File

@ -37,13 +37,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='bank_account'; //Must be the $element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -65,7 +65,7 @@ $textobject = $langs->transnoentitiesnoconv("Bank");
llxHeader('', $langs->trans("BankSetupModule"), $help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup');
@ -101,7 +101,7 @@ if ($action == 'create')
/*
* Edition of an optional field
*/
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -67,21 +67,21 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_input_method as t";
$sql.= " WHERE t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -453,21 +453,21 @@ class Setup extends DolibarrApi
{
$list = array();
$sql = "SELECT t.rowid, t.code, t.libelle, t.description, t.tracking";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql.= " WHERE t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -1104,22 +1104,22 @@ class Setup extends DolibarrApi
$list = array();
//TODO link with multicurrency module
$sql = "SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_socialnetworks as t";
$sql.= " WHERE t.entity IN (".getEntity('c_socialnetworks').")";
$sql.= " AND t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_socialnetworks as t";
$sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")";
$sql .= " AND t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -1474,7 +1474,7 @@ class Setup extends DolibarrApi
// Defined qualified files (must be same than into generate_filelist_xml.php)
$regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
$regextoexclude = '('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
// Fill file_list with files in signature, new files, modified files

View File

@ -36,89 +36,89 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (! empty($conf->projet->enabled)) {
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
$filter = GETPOST("search_filter", 'alpha', 3)?GETPOST("search_filter", 'alpha', 3):GETPOST("filter", 'alpha', 3);
$filtert = GETPOST("search_filtert", "int", 3)?GETPOST("search_filtert", "int", 3):GETPOST("filtert", "int", 3);
$usergroup = GETPOST("search_usergroup", "int", 3)?GETPOST("search_usergroup", "int", 3):GETPOST("usergroup", "int", 3);
$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday", "int"):1;
$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
$showbirthday = empty($conf->use_javascript_ajax) ?GETPOST("showbirthday", "int") : 1;
// If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user.
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
{
$filtert=$user->id;
$filtert = $user->id;
}
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", "int");
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="a.datec";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "a.datec";
// Security check
$socid = GETPOST("search_socid", "int")?GETPOST("search_socid", "int"):GETPOST("socid", "int");
if ($user->socid) $socid=$user->socid;
$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($socid < 0) $socid='';
if ($socid < 0) $socid = '';
$canedit=1;
if (! $user->rights->agenda->myactions->read) accessforbidden();
if (! $user->rights->agenda->allactions->read) $canedit=0;
if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
$canedit = 1;
if (!$user->rights->agenda->myactions->read) accessforbidden();
if (!$user->rights->agenda->allactions->read) $canedit = 0;
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me
{
$filtert=$user->id;
$filtert = $user->id;
}
$action=GETPOST('action', 'alpha');
$resourceid=GETPOST("search_resourceid", "int");
$year=GETPOST("year", "int")?GETPOST("year", "int"):date("Y");
$month=GETPOST("month", "int")?GETPOST("month", "int"):date("m");
$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W");
$day=GETPOST("day", "int")?GETPOST("day", "int"):date("d");
$pid=GETPOST("search_projectid", "int", 3)?GETPOST("search_projectid", "int", 3):GETPOST("projectid", "int", 3);
$status=GETPOST("search_status", 'aZ09')?GETPOST("search_status", 'aZ09'):GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo'
$type=GETPOST("search_type", 'aZ09')?GETPOST("search_type", 'aZ09'):GETPOST("type", 'aZ09');
$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$action = GETPOST('action', 'alpha');
$resourceid = GETPOST("search_resourceid", "int");
$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
$status = GETPOST("search_status", 'aZ09') ?GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo'
$type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09');
$maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('search_actioncode', 'array'))
{
$actioncode=GETPOST('search_actioncode', 'array', 3);
if (! count($actioncode)) $actioncode='0';
$actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
}
else
{
$actioncode=GETPOST("search_actioncode", "alpha", 3)?GETPOST("search_actioncode", "alpha", 3):(GETPOST("search_actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
}
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($status == '' && ! GETPOSTISSET('search_status')) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if ($status == '' && !GETPOSTISSET('search_status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
$defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
$defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
if (empty($action) && ! GETPOSTISSET('action')) $action=$defaultview;
if (empty($action) && !GETPOSTISSET('action')) $action = $defaultview;
if ($action == 'default') // When action is default, we want a calendar view and not the list
{
$action = (($defaultview != 'show_list') ? $defaultview : 'show_month');
}
if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') {
$action='show_month'; $day='';
$action = 'show_month'; $day = '';
} // View by month
if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') {
$action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d"));
$action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
} // View by week
if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') {
$action='show_day'; $day=($day?$day:date("d"));
$action = 'show_day'; $day = ($day ? $day : date("d"));
} // View by day
// Load translation files required by the page
@ -1482,7 +1482,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
//var_dump($event->userassigned);
//var_dump($event->transparency);
print '<table class="centpercent cal_event';
print (empty($event->transparency)?' cal_event_notbusy':' cal_event_busy');
print (empty($event->transparency) ? ' cal_event_notbusy' : ' cal_event_busy');
//if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium'; // Not busy
print '" style="'.$h;
$colortouse = $color;
@ -1664,12 +1664,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
else
{
print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action='.$action.'&maxprint=0&month='.$monthshown.'&year='.$year;
print ($status?'&status='.$status:'').($filter?'&filter='.$filter:'');
print ($filtert?'&search_filtert='.$filtert:'');
print ($usergroup?'&search_usergroup='.$usergroup:'');
print ($actioncode!=''?'&search_actioncode='.$actioncode:'');
print ($status ? '&status='.$status : '').($filter ? '&filter='.$filter : '');
print ($filtert ? '&search_filtert='.$filtert : '');
print ($usergroup ? '&search_usergroup='.$usergroup : '');
print ($actioncode != '' ? '&search_actioncode='.$actioncode : '');
print '">'.img_picto("all", "1downarrow_selected.png").' ...';
print ' +'.(count($eventarray[$daykey])-$maxprint);
print ' +'.(count($eventarray[$daykey]) - $maxprint);
print '</a>';
break;
//$ok=false; // To avoid to show twice the link

View File

@ -51,93 +51,93 @@ $showbirthday = 0;
// If not choice done on calendar owner, we filter on user.
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
{
$filtert=$user->id;
$filtert = $user->id;
}
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", "int");
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="a.datec";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "a.datec";
// Security check
$socid = GETPOST("search_socid", "int")?GETPOST("search_socid", "int"):GETPOST("socid", "int");
if ($user->socid) $socid=$user->socid;
$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($socid < 0) $socid='';
if ($socid < 0) $socid = '';
$canedit=1;
if (! $user->rights->agenda->myactions->read) accessforbidden();
if (! $user->rights->agenda->allactions->read) $canedit=0;
if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
$canedit = 1;
if (!$user->rights->agenda->myactions->read) accessforbidden();
if (!$user->rights->agenda->allactions->read) $canedit = 0;
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me
{
$filtert=$user->id;
$filtert = $user->id;
}
//$action=GETPOST('action','alpha');
$action='show_peruser'; //We use 'show_week' mode
$resourceid=GETPOST("search_resourceid", "int")?GETPOST("search_resourceid", "int"):GETPOST("resourceid", "int");
$year=GETPOST("year", "int")?GETPOST("year", "int"):date("Y");
$month=GETPOST("month", "int")?GETPOST("month", "int"):date("m");
$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W");
$day=GETPOST("day", "int")?GETPOST("day", "int"):date("d");
$pid=GETPOST("search_projectid", "int", 3)?GETPOST("search_projectid", "int", 3):GETPOST("projectid", "int", 3);
$status=GETPOST("search_status", 'alpha')?GETPOST("search_status", 'alpha'):GETPOST("status", 'alpha');
$type=GETPOST("search_type", 'alpha')?GETPOST("search_type", 'alpha'):GETPOST("type", 'alpha');
$maxprint=((GETPOST("maxprint", 'int')!='')?GETPOST("maxprint", 'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$action = 'show_peruser'; //We use 'show_week' mode
$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y");
$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m");
$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d");
$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha');
$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('search_actioncode', 'array'))
{
$actioncode=GETPOST('search_actioncode', 'array', 3);
if (! count($actioncode)) $actioncode='0';
$actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
}
else
{
$actioncode=GETPOST("search_actioncode", "alpha", 3)?GETPOST("search_actioncode", "alpha", 3):(GETPOST("search_actioncode", "alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
}
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
if ($dateselect > 0)
{
$day=GETPOST('dateselectday', 'int');
$month=GETPOST('dateselectmonth', 'int');
$year=GETPOST('dateselectyear', 'int');
$day = GETPOST('dateselectday', 'int');
$month = GETPOST('dateselectmonth', 'int');
$year = GETPOST('dateselectyear', 'int');
}
$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS;
$tmp=str_replace(' ', '', $tmp); // FIX 7533
$tmparray=explode('-', $tmp);
$begin_h = GETPOST('begin_h', 'int')!=''?GETPOST('begin_h', 'int'):($tmparray[0] != '' ? $tmparray[0] : 9);
$end_h = GETPOST('end_h', 'int')?GETPOST('end_h', 'int'):($tmparray[1] != '' ? $tmparray[1] : 18);
$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS;
$tmp = str_replace(' ', '', $tmp); // FIX 7533
$tmparray = explode('-', $tmp);
$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9);
$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18);
if ($begin_h < 0 || $begin_h > 23) $begin_h = 9;
if ($end_h < 1 || $end_h > 24) $end_h = 18;
if ($end_h <= $begin_h) $end_h = $begin_h + 1;
$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS;
$tmp=str_replace(' ', '', $tmp); // FIX 7533
$tmparray=explode('-', $tmp);
$begin_d = GETPOST('begin_d', 'int')?GETPOST('begin_d', 'int'):($tmparray[0] != '' ? $tmparray[0] : 1);
$end_d = GETPOST('end_d', 'int')?GETPOST('end_d', 'int'):($tmparray[1] != '' ? $tmparray[1] : 5);
$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
$tmp = str_replace(' ', '', $tmp); // FIX 7533
$tmparray = explode('-', $tmp);
$begin_d = GETPOST('begin_d', 'int') ?GETPOST('begin_d', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 1);
$end_d = GETPOST('end_d', 'int') ?GETPOST('end_d', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 5);
if ($begin_d < 1 || $begin_d > 7) $begin_d = 1;
if ($end_d < 1 || $end_d > 7) $end_d = 7;
if ($end_d < $begin_d) $end_d = $begin_d + 1;
if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
$action='show_month'; $day='';
$action = 'show_month'; $day = '';
} // View by month
if (GETPOST('viewweek', 'alpha') || $action == 'show_week') {
$action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d"));
$action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
} // View by week
if (GETPOST('viewday', 'alpha') || $action == 'show_day') {
$action='show_day'; $day=($day?$day:date("d"));
$action = 'show_day'; $day = ($day ? $day : date("d"));
} // View by day
// Load translation files required by the page
@ -385,189 +385,189 @@ if ($conf->use_javascript_ajax)
}
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
{
$tmpforcreatebutton=dol_getdate(dol_now(), true);
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
//$param='month='.$monthshown.'&year='.$year;
$hourminsec='100000';
$newcardbutton.= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')));
$hourminsec = '100000';
$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
}
$link='';
$link = '';
print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
// Get event in an array
$eventarray=array();
$eventarray = array();
$sql = 'SELECT';
if ($usergroup > 0) $sql.=" DISTINCT";
$sql.= ' a.id, a.label,';
$sql.= ' a.datep,';
$sql.= ' a.datep2,';
$sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
$sql.= ' ca.code, ca.color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if ($usergroup > 0) $sql .= " DISTINCT";
$sql .= ' a.id, a.label,';
$sql .= ' a.datep,';
$sql .= ' a.datep2,';
$sql .= ' a.percent,';
$sql .= ' a.fk_user_author,a.fk_user_action,';
$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
$sql .= ' ca.code, ca.color';
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
// We must filter on resource table
if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql .= ' WHERE a.fk_action = ca.id';
$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode
if (! empty($actioncode))
if (!empty($actioncode))
{
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'";
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
else
{
if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'";
if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'";
if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
}
}
else
{
if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'";
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
else
{
if (is_array($actioncode))
{
$sql.=" AND ca.code IN ('".implode("','", $actioncode)."')";
$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
}
else
{
$sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
}
}
}
}
if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid;
if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid;
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($action == 'show_day')
{
$sql.= " AND (";
$sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql.= " OR ";
$sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql.= " OR ";
$sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql.= ')';
$sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql .= " OR ";
$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql .= " OR ";
$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
$sql .= ')';
}
else
{
// To limit array
$sql.= " AND (";
$sql.= " (a.datep BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; // Start 2 day before $firstdaytoshow
$sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; // End 2 day after $lastdaytoshow
$sql.= " OR ";
$sql.= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'";
$sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')";
$sql.= " OR ";
$sql.= " (a.datep < '".$db->idate($firstdaytoshow-(60*60*24*2))."'";
$sql.= " AND a.datep2 > '".$db->idate($lastdaytoshow+(60*60*24*2))."')";
$sql.= ')';
$sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow
$sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow
$sql .= " OR ";
$sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
$sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
$sql .= " OR ";
$sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'";
$sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')";
$sql .= ')';
}
if ($type) $sql.= " AND ca.id = ".$type;
if ($status == '0') { $sql.= " AND a.percent = 0"; }
if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100)"; }
if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; }
if ($type) $sql .= " AND ca.id = ".$type;
if ($status == '0') { $sql .= " AND a.percent = 0"; }
if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; }
if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0)
{
$sql.= " AND (";
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
$sql.= ")";
$sql .= " AND (";
if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
$sql .= ")";
}
// Sort on date
$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action
$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
dol_syslog("comm/action/peruser.php", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i=0;
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
// Discard auto action if option is on
if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO')
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO')
{
$i++;
continue;
}
$datep=$db->jdate($obj->datep);
$datep2=$db->jdate($obj->datep2);
$datep = $db->jdate($obj->datep);
$datep2 = $db->jdate($obj->datep2);
// Create a new object action
$event=new ActionComm($db);
$event->id=$obj->id;
$event->datep=$datep; // datep and datef are GMT date
$event->datef=$datep2;
$event->type_code=$obj->code;
$event->type_color=$obj->color;
$event->label=$obj->label;
$event->percentage=$obj->percent;
$event->authorid=$obj->fk_user_author; // user id of creator
$event->userownerid=$obj->fk_user_action; // user id of owner
$event->priority=$obj->priority;
$event->fulldayevent=$obj->fulldayevent;
$event->location=$obj->location;
$event->transparency=$obj->transparency;
$event = new ActionComm($db);
$event->id = $obj->id;
$event->datep = $datep; // datep and datef are GMT date
$event->datef = $datep2;
$event->type_code = $obj->code;
$event->type_color = $obj->color;
$event->label = $obj->label;
$event->percentage = $obj->percent;
$event->authorid = $obj->fk_user_author; // user id of creator
$event->userownerid = $obj->fk_user_action; // user id of owner
$event->priority = $obj->priority;
$event->fulldayevent = $obj->fulldayevent;
$event->location = $obj->location;
$event->transparency = $obj->transparency;
$event->fk_project=$obj->fk_project;
$event->fk_project = $obj->fk_project;
$event->socid=$obj->fk_soc;
$event->contactid=$obj->fk_contact;
$event->socid = $obj->fk_soc;
$event->contactid = $obj->fk_contact;
$event->fk_element=$obj->fk_element;
$event->elementtype=$obj->elementtype;
$event->fk_element = $obj->fk_element;
$event->elementtype = $obj->elementtype;
// Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside calendar view.
if ($event->percentage <= 0)
{
$event->date_start_in_calendar=$datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
else $event->date_end_in_calendar=$datep;
$event->date_start_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
else $event->date_end_in_calendar = $datep;
}
else
{
$event->date_start_in_calendar=$datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2;
else $event->date_end_in_calendar=$datep;
$event->date_start_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
else $event->date_end_in_calendar = $datep;
}
// Define ponctual property
if ($event->date_start_in_calendar == $event->date_end_in_calendar)
{
$event->ponctuel=1;
$event->ponctuel = 1;
}
// Check values
@ -655,12 +655,12 @@ echo '<input type="hidden" name="newdate" id="newdate">';
$currentdaytoshow = $firstdaytoshow;
echo '<div class="div-table-responsive">';
while($currentdaytoshow<$lastdaytoshow) {
while ($currentdaytoshow < $lastdaytoshow) {
echo '<table width="100%" class="noborder nocellnopadd cal_month">';
echo '<tr class="liste_titre">';
echo '<td></td>';
$i=0; // 0 = sunday,
$i = 0; // 0 = sunday,
while ($i < 7)
{
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
@ -712,10 +712,10 @@ while($currentdaytoshow<$lastdaytoshow) {
foreach ($eventarray[$daykey] as $index => $event)
{
$event->fetch_userassigned();
$listofuserid=$event->userassigned;
foreach($listofuserid as $userid => $tmp)
$listofuserid = $event->userassigned;
foreach ($listofuserid as $userid => $tmp)
{
if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid;
if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid;
}
}
}
@ -775,26 +775,26 @@ while($currentdaytoshow<$lastdaytoshow) {
}*/
// Load array of colors by type
$colorsbytype=array();
$labelbytype=array();
$sql="SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
$resql=$db->query($sql);
$colorsbytype = array();
$labelbytype = array();
$sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
$resql = $db->query($sql);
while ($obj = $db->fetch_object($resql))
{
$colorsbytype[$obj->code]=$obj->color;
$labelbytype[$obj->code]=$obj->label;
$colorsbytype[$obj->code] = $obj->color;
$labelbytype[$obj->code] = $obj->label;
}
// Loop on each user to show calendar
$todayarray=dol_getdate($now, 'fast');
$todayarray = dol_getdate($now, 'fast');
$sav = $tmpday;
$showheader = true;
$var = false;
foreach ($usernames as $username)
{
$var = ! $var;
$var = !$var;
echo "<tr>";
echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">';
echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">';
print $username->getNomUrl(-1, '', 0, 0, 20, 1, '');
print '</td>';
$tmpday = $sav;
@ -1059,117 +1059,117 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
{
$a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, 0);
$b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, 0);
$c = dol_mktime((int) $h+1, 0, 0, $month, $day, $year, false, 0);
$c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, 0);
$dateendtouse=$event->date_end_in_calendar;
if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++;
$dateendtouse = $event->date_end_in_calendar;
if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++;
//print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
if ($event->date_start_in_calendar < $b && $dateendtouse > $a)
{
$busy=$event->transparency;
$cases1[$h][$event->id]['busy']=$busy;
$cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar, 'dayhour');
$busy = $event->transparency;
$cases1[$h][$event->id]['busy'] = $busy;
$cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour');
if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
{
$tmpa=dol_getdate($event->date_start_in_calendar, true);
$tmpb=dol_getdate($event->date_end_in_calendar, true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'hour');
else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'dayhour');
$tmpa = dol_getdate($event->date_start_in_calendar, true);
$tmpb = dol_getdate($event->date_end_in_calendar, true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour');
else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour');
}
if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label;
$cases1[$h][$event->id]['typecode']=$event->type_code;
$cases1[$h][$event->id]['color']=$color;
if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label;
$cases1[$h][$event->id]['typecode'] = $event->type_code;
$cases1[$h][$event->id]['color'] = $color;
if ($event->fk_project > 0)
{
if (empty($cacheprojects[$event->fk_project]))
{
$tmpproj=new Project($db);
$tmpproj = new Project($db);
$tmpproj->fetch($event->fk_project);
$cacheprojects[$event->fk_project]=$tmpproj;
$cacheprojects[$event->fk_project] = $tmpproj;
}
$cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
$cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cachethirdparties[$event->socid]))
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty = new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cachethirdparties[$event->socid]=$tmpthirdparty;
$cachethirdparties[$event->socid] = $tmpthirdparty;
}
$cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name;
$cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
}
if ($event->contactid > 0)
{
if (empty($cachecontacts[$event->contactid]))
{
$tmpcontact=new Contact($db);
$tmpcontact = new Contact($db);
$tmpcontact->fetch($event->contactid);
$cachecontacts[$event->contactid]=$tmpcontact;
$cachecontacts[$event->contactid] = $tmpcontact;
}
$cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs);
$cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs);
}
}
if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
{
$busy=$event->transparency;
$cases2[$h][$event->id]['busy']=$busy;
$cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar, 'dayhour');
$busy = $event->transparency;
$cases2[$h][$event->id]['busy'] = $busy;
$cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour');
if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
{
$tmpa=dol_getdate($event->date_start_in_calendar, true);
$tmpb=dol_getdate($event->date_end_in_calendar, true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'hour');
else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'dayhour');
$tmpa = dol_getdate($event->date_start_in_calendar, true);
$tmpb = dol_getdate($event->date_end_in_calendar, true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour');
else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour');
}
if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label;
$cases2[$h][$event->id]['typecode']=$event->type_code;
$cases2[$h][$event->id]['color']=$color;
if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label;
$cases2[$h][$event->id]['typecode'] = $event->type_code;
$cases2[$h][$event->id]['color'] = $color;
if ($event->fk_project > 0)
{
if (empty($cacheprojects[$event->fk_project]))
{
$tmpproj=new Project($db);
$tmpproj = new Project($db);
$tmpproj->fetch($event->fk_project);
$cacheprojects[$event->fk_project]=$tmpproj;
$cacheprojects[$event->fk_project] = $tmpproj;
}
$cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
$cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cachethirdparties[$event->socid]))
{
$tmpthirdparty=new Societe($db);
$tmpthirdparty = new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cachethirdparties[$event->socid]=$tmpthirdparty;
$cachethirdparties[$event->socid] = $tmpthirdparty;
}
$cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name;
$cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
}
if ($event->contactid > 0)
{
if (empty($cachecontacts[$event->contactid]))
{
$tmpcontact=new Contact($db);
$tmpcontact = new Contact($db);
$tmpcontact->fetch($event->contactid);
$cachecontacts[$event->contactid]=$tmpcontact;
$cachecontacts[$event->contactid] = $tmpcontact;
}
$cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs);
$cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs);
}
}
}
else
{
$busy=$event->transparency;
$cases1[$h][$event->id]['busy']=$busy;
$cases2[$h][$event->id]['busy']=$busy;
$cases1[$h][$event->id]['string']=$event->label;
$cases2[$h][$event->id]['string']=$event->label;
$cases1[$h][$event->id]['typecode']=$event->type_code;
$cases2[$h][$event->id]['typecode']=$event->type_code;
$cases1[$h][$event->id]['color']=$color;
$cases2[$h][$event->id]['color']=$color;
$busy = $event->transparency;
$cases1[$h][$event->id]['busy'] = $busy;
$cases2[$h][$event->id]['busy'] = $busy;
$cases1[$h][$event->id]['string'] = $event->label;
$cases2[$h][$event->id]['string'] = $event->label;
$cases1[$h][$event->id]['typecode'] = $event->type_code;
$cases2[$h][$event->id]['typecode'] = $event->type_code;
$cases1[$h][$event->id]['color'] = $color;
$cases2[$h][$event->id]['color'] = $color;
}
}
$i++;
@ -1182,87 +1182,87 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
// Now output $casesX
for ($h = $begin_h; $h < $end_h; $h++)
{
$color1='';$color2='';
$style1='';$style2='';
$string1='&nbsp;';$string2='&nbsp;';
$title1='';$title2='';
$color1 = ''; $color2 = '';
$style1 = ''; $style2 = '';
$string1 = '&nbsp;'; $string2 = '&nbsp;';
$title1 = ''; $title2 = '';
if (isset($cases1[$h]) && $cases1[$h] != '')
{
//$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
$string1='&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy';
else $style1='peruser_busy';
foreach($cases1[$h] as $id => $ev)
if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
$string1 = '&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy';
else $style1 = 'peruser_busy';
foreach ($cases1[$h] as $id => $ev)
{
if ($ev['busy']) $style1='peruser_busy';
if ($ev['busy']) $style1 = 'peruser_busy';
}
}
if (isset($cases2[$h]) && $cases2[$h] != '')
{
//$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
$string2='&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy';
else $style2='peruser_busy';
foreach($cases2[$h] as $id => $ev)
if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
$string2 = '&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy';
else $style2 = 'peruser_busy';
foreach ($cases2[$h] as $id => $ev)
{
if ($ev['busy']) $style2='peruser_busy';
if ($ev['busy']) $style2 = 'peruser_busy';
}
}
$ids1='';
$ids2='';
if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',', array_keys($cases1[$h]));
if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',', array_keys($cases2[$h]));
$ids1 = '';
$ids2 = '';
if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h]));
if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h]));
if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">';
else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">';
if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
if (is_array($cases1[$h]) && count($cases1[$h]) == 1) // only 1 event
{
$output = array_slice($cases1[$h], 0, 1);
$title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:'');
if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string'];
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
if ($output[0]['color']) $color1 = $output[0]['color'];
}
elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1)
{
$title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:'');
$color1='222222';
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
$color1 = '222222';
}
if (is_array($cases2[$h]) && count($cases2[$h]) == 1) // only 1 event
{
$output = array_slice($cases2[$h], 0, 1);
$title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:'');
if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string'];
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
if ($output[0]['color']) $color2 = $output[0]['color'];
}
elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1)
{
$title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:'');
$color2='222222';
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
$color2 = '222222';
}
print '<table class="nobordernopadding" width="100%">';
print '<tr><td ';
if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" ';
if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1 ? $color1 : "888").' !important" ';
elseif ($color1)
{
print ($color1?'style="background: #'.$color1.';"':'');
print ($color1 ? 'style="background: #'.$color1.';"' : '');
}
print 'class="';
print ($style1?$style1.' ':'');
print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>';
print ($style1 ? $style1.' ' : '');
print 'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>';
print $string1;
print '</td><td ';
if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" ';
if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" ';
elseif ($color2)
{
print ($color2?'style="background: #'.$color2.';"':'');
print ($color2 ? 'style="background: #'.$color2.';"' : '');
}
print 'class="';
print ($style2?$style2.' ':'');
print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>';
print ($style2 ? $style2.' ' : '');
print 'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>';
print $string2;
print '</td></tr>';
print '</table>';

View File

@ -37,29 +37,29 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (!empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'banks'));
if (! empty($conf->contrat->enabled)) $langs->load("contracts");
if (! empty($conf->commande->enabled)) $langs->load("orders");
if (! empty($conf->expedition->enabled)) $langs->load("sendings");
if (! empty($conf->facture->enabled)) $langs->load("bills");
if (! empty($conf->projet->enabled)) $langs->load("projects");
if (! empty($conf->ficheinter->enabled)) $langs->load("interventions");
if (! empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->contrat->enabled)) $langs->load("contracts");
if (!empty($conf->commande->enabled)) $langs->load("orders");
if (!empty($conf->expedition->enabled)) $langs->load("sendings");
if (!empty($conf->facture->enabled)) $langs->load("bills");
if (!empty($conf->projet->enabled)) $langs->load("projects");
if (!empty($conf->ficheinter->enabled)) $langs->load("interventions");
if (!empty($conf->notification->enabled)) $langs->load("mails");
// Security check
$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
if ($user->socid > 0) $id=$user->socid;
if ($user->socid > 0) $id = $user->socid;
$result = restrictedArea($user, 'societe', $id, '&societe');
$action = GETPOST('action', 'aZ09');
@ -240,7 +240,7 @@ if ($object->id > 0)
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom');
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
print '<div class="fichecenter"><div class="fichehalfleft">';
@ -1293,11 +1293,11 @@ if ($object->id > 0)
$langs->load("bills");
$langs->load("orders");
if (! empty($conf->commande->enabled))
if (!empty($conf->commande->enabled))
{
if ($object->client != 0 && $object->client != 2)
{
if (! empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
if (!empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
}
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';

View File

@ -23,17 +23,17 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
$id=GETPOST('id');
$id = GETPOST('id');
// Load translation files required by the page
$langs->load("mails");
// Security check
if (! $user->rights->mailing->lire || $user->socid > 0)
if (!$user->rights->mailing->lire || $user->socid > 0)
accessforbidden();
@ -56,16 +56,16 @@ if ($object->fetch($id) >= 0)
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlright='';
$morehtmlright = '';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3)
{
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright.=' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error");
$morehtmlright.=') &nbsp; ';
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
$morehtmlright .= ') &nbsp; ';
}
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
@ -73,10 +73,10 @@ if ($object->fetch($id) >= 0)
print '<div class="underbanner clearboth"></div><br>';
//print '<table width="100%"><tr><td>';
$object->user_creation=$object->user_creat;
$object->date_creation=$object->date_creat;
$object->user_validation=$object->user_valid;
$object->date_validation=$object->date_valid;
$object->user_creation = $object->user_creat;
$object->date_creation = $object->date_creat;
$object->user_validation = $object->user_valid;
$object->date_validation = $object->date_valid;
dol_print_object_info($object, 0);
//print '</td></tr></table>';

View File

@ -1544,7 +1544,7 @@ class Propal extends CommonObject
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key = trim($this->import_key);
if (! empty($this->duree_validite)) $this->fin_validite=$this->date + ($this->duree_validite * 24 * 3600);
if (!empty($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
// Check parameters
// Put here code to add control on parameters values
@ -1557,7 +1557,7 @@ class Propal extends CommonObject
$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
$sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").",";
$sql .= " datep=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').",";
if (! empty($this->fin_validite)) $sql .= " fin_validite=".(strval($this->fin_validite)!='' ? "'".$this->db->idate($this->fin_validite)."'" : 'null').",";
if (!empty($this->fin_validite)) $sql .= " fin_validite=".(strval($this->fin_validite) != '' ? "'".$this->db->idate($this->fin_validite)."'" : 'null').",";
$sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').",";
$sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").",";
$sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").",";
@ -3228,24 +3228,24 @@ class Propal extends CommonObject
{
global $langs;
$langs->load("propal");
$this->labelStatus[0]=$langs->trans("PropalStatusDraft");
$this->labelStatus[1]=$langs->trans("PropalStatusValidated");
$this->labelStatus[2]=$langs->trans("PropalStatusSigned");
$this->labelStatus[3]=$langs->trans("PropalStatusNotSigned");
$this->labelStatus[4]=$langs->trans("PropalStatusBilled");
$this->labelStatusShort[0]=$langs->trans("PropalStatusDraftShort");
$this->labelStatusShort[1]=$langs->trans("PropalStatusValidatedShort");
$this->labelStatusShort[2]=$langs->trans("PropalStatusSignedShort");
$this->labelStatusShort[3]=$langs->trans("PropalStatusNotSignedShort");
$this->labelStatusShort[4]=$langs->trans("PropalStatusBilledShort");
$this->labelStatus[0] = $langs->trans("PropalStatusDraft");
$this->labelStatus[1] = $langs->trans("PropalStatusValidated");
$this->labelStatus[2] = $langs->trans("PropalStatusSigned");
$this->labelStatus[3] = $langs->trans("PropalStatusNotSigned");
$this->labelStatus[4] = $langs->trans("PropalStatusBilled");
$this->labelStatusShort[0] = $langs->trans("PropalStatusDraftShort");
$this->labelStatusShort[1] = $langs->trans("PropalStatusValidatedShort");
$this->labelStatusShort[2] = $langs->trans("PropalStatusSignedShort");
$this->labelStatusShort[3] = $langs->trans("PropalStatusNotSignedShort");
$this->labelStatusShort[4] = $langs->trans("PropalStatusBilledShort");
}
$statusType='';
if ($status==self::STATUS_DRAFT) $statusType='status0';
elseif ($status==self::STATUS_VALIDATED) $statusType='status1';
elseif ($status==self::STATUS_SIGNED) $statusType='status3';
elseif ($status==self::STATUS_NOTSIGNED) $statusType='status5';
elseif ($status==self::STATUS_BILLED) $statusType='status6';
$statusType = '';
if ($status == self::STATUS_DRAFT) $statusType = 'status0';
elseif ($status == self::STATUS_VALIDATED) $statusType = 'status1';
elseif ($status == self::STATUS_SIGNED) $statusType = 'status3';
elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status5';
elseif ($status == self::STATUS_BILLED) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@ -3267,42 +3267,42 @@ class Propal extends CommonObject
$clause = " WHERE";
$sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin, p.total_ht";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id;
$clause = " AND";
}
$sql.= $clause." p.entity IN (".getEntity('propal').")";
if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED;
if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED;
if ($user->socid) $sql.= " AND p.fk_soc = ".$user->socid;
$sql .= $clause." p.entity IN (".getEntity('propal').")";
if ($mode == 'opened') $sql .= " AND p.fk_statut = ".self::STATUS_VALIDATED;
if ($mode == 'signed') $sql .= " AND p.fk_statut = ".self::STATUS_SIGNED;
if ($user->socid) $sql .= " AND p.fk_soc = ".$user->socid;
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$langs->load("propal");
$now=dol_now();
$now = dol_now();
$delay_warning = 0;
$status = 0;
$label = $labelShort = '';
if ($mode == 'opened') {
$delay_warning=$conf->propal->cloture->warning_delay;
$delay_warning = $conf->propal->cloture->warning_delay;
$status = self::STATUS_VALIDATED;
$label = $langs->trans("PropalsToClose");
$labelShort = $langs->trans("ToAcceptRefuse");
}
if ($mode == 'signed') {
$delay_warning=$conf->propal->facturation->warning_delay;
$delay_warning = $conf->propal->facturation->warning_delay;
$status = self::STATUS_SIGNED;
$label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered
$labelShort = $langs->trans("ToBill");
}
$response = new WorkboardResponse();
$response->warning_delay = $delay_warning/60/60/24;
$response->warning_delay = $delay_warning / 60 / 60 / 24;
$response->label = $label;
$response->labelShort = $labelShort;
$response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$status.'&mainmenu=commercial&leftmenu=propals';
@ -3441,27 +3441,27 @@ class Propal extends CommonObject
// phpcs:enable
global $user;
$this->nb=array();
$this->nb = array();
$clause = "WHERE";
$sql = "SELECT count(p.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
}
$sql.= " ".$clause." p.entity IN (".getEntity('propal').")";
$sql .= " ".$clause." p.entity IN (".getEntity('propal').")";
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
while ($obj = $this->db->fetch_object($resql))
{
$this->nb["proposals"]=$obj->nb;
$this->nb["proposals"] = $obj->nb;
}
$this->db->free($resql);
return 1;

View File

@ -36,13 +36,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='facture'; //Must be the $table_element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'facture'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -59,11 +59,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
$textobject = strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
llxHeader('', $langs->trans("BillsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
@ -104,7 +104,7 @@ if ($action == 'create')
* Edition of an optional field
*
*/
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
$langs->load("members");

View File

@ -37,13 +37,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='facture_rec'; //Must be the $table_element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'facture_rec'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -60,11 +60,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
$textobject = strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
llxHeader('', $langs->trans("BillsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
@ -105,7 +105,7 @@ if ($action == 'create')
* Edition of an optional field
*
*/
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
$langs->load("members");

View File

@ -37,13 +37,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='facturedet'; //Must be the $table_element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'facturedet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -60,11 +60,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
$textobject = strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
llxHeader('', $langs->trans("BillsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
@ -105,7 +105,7 @@ if ($action == 'create')
* Edition d'un champ optionnel
*
*/
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -37,13 +37,13 @@ $extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='facturedet_rec'; //Must be the $table_element of the class that manage extrafield
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'facturedet_rec'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
@ -60,11 +60,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
$textobject = strtolower($langs->transnoentitiesnoconv("BillsCustomers"));
llxHeader('', $langs->trans("BillsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
@ -105,7 +105,7 @@ if ($action == 'create')
* Edition d'un champ optionnel
*
*/
if ($action == 'edit' && ! empty($attrname))
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -1989,7 +1989,7 @@ if (empty($reshook))
if (empty($price2num_remise_percent)) $price2num_remise_percent = 0;
if (empty($price2num_price_min)) $price2num_price_min = 0;
if ($usercanproductignorepricemin && (! empty($price_min) && ($price2num_pu_ht * (1 - $price2num_remise_percent / 100) < $price2num_price_min))) {
if ($usercanproductignorepricemin && (!empty($price_min) && ($price2num_pu_ht * (1 - $price2num_remise_percent / 100) < $price2num_price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessages($mesg, null, 'errors');
} else {

View File

@ -30,21 +30,21 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('bills','banks','companies'));
$langs->loadLangs(array('bills', 'banks', 'companies'));
$id=GETPOST('id', 'int');
$ref=GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$backtopage=GETPOST('backtopage', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
// Security check
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
@ -64,7 +64,7 @@ if ($action == 'setnote' && $user->rights->facture->paiement)
if ($result > 0)
{
$db->commit();
$action='';
$action = '';
}
else
{
@ -112,14 +112,14 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->
$db->commit();
// Loop on each invoice linked to this payment to rebuild PDF
$factures=array();
foreach($factures as $id)
$factures = array();
foreach ($factures as $id)
{
$fac = new Facture($db);
$fac->fetch($id);
$outputlangs = $langs;
if (! empty($_REQUEST['lang_id']))
if (!empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
@ -140,7 +140,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->
}
}
if ($action == 'setnum_paiement' && ! empty($_POST['num_paiement']))
if ($action == 'setnum_paiement' && !empty($_POST['num_paiement']))
{
$object->fetch($id);
$res = $object->update_num($_POST['num_paiement']);
@ -154,7 +154,7 @@ if ($action == 'setnum_paiement' && ! empty($_POST['num_paiement']))
}
}
if ($action == 'setdatep' && ! empty($_POST['datepday']))
if ($action == 'setdatep' && !empty($_POST['datepday']))
{
$object->fetch($id);
$datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int'));
@ -176,9 +176,9 @@ if ($action == 'setdatep' && ! empty($_POST['datepday']))
llxHeader('', $langs->trans("Payment"));
$thirdpartystatic=new Societe($db);
$thirdpartystatic = new Societe($db);
$result=$object->fetch($id, $ref);
$result = $object->fetch($id, $ref);
if ($result <= 0)
{
dol_print_error($db, 'Payement '.$id.' not found in database');
@ -204,7 +204,7 @@ if ($action == 'valide')
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2);
}
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/paiement/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '');
@ -220,9 +220,9 @@ print $form->editfieldval("Date", 'datep', $object->date, $object, $user->rights
print '</td></tr>';
// Payment type (VIR, LIQ, ...)
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_label;
$labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label;
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'.$labeltype;
print $object->num_paiement?' - '.$object->num_paiement:'';
print $object->num_paiement ? ' - '.$object->num_paiement : '';
print '</td></tr>';
// Amount
@ -230,9 +230,9 @@ print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, '',
$disable_delete = 0;
// Bank account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
$bankline=new AccountLine($db);
$bankline = new AccountLine($db);
if ($object->fk_account > 0)
{
@ -246,7 +246,7 @@ if (! empty($conf->banque->enabled))
print '<tr>';
print '<td>'.$langs->trans('BankAccount').'</td>';
print '<td>';
$accountstatic=new Account($db);
$accountstatic = new Account($db);
$accountstatic->fetch($bankline->fk_account);
print $accountstatic->getNomUrl(1);
print '</td>';
@ -275,7 +275,7 @@ print '</td></tr>';
*/
// Bank account
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
if ($object->fk_account > 0)
{
@ -319,12 +319,12 @@ dol_fiche_end();
*/
$sql = 'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
$sql.= ' WHERE pf.fk_facture = f.rowid';
$sql.= ' AND f.fk_soc = s.rowid';
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
$sql.= ' AND pf.fk_paiement = '.$object->id;
$resql=$db->query($sql);
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facture = f.rowid';
$sql .= ' AND f.fk_soc = s.rowid';
$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
$sql .= ' AND pf.fk_paiement = '.$object->id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -332,7 +332,7 @@ if ($resql)
$i = 0;
$total = 0;
$moreforfilter='';
$moreforfilter = '';
print '<br>';
@ -342,7 +342,7 @@ if ($resql)
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Bill').'</td>';
print '<td>'.$langs->trans('Company').'</td>';
if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED )print '<td>'.$langs->trans('Entity').'</td>';
if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)print '<td>'.$langs->trans('Entity').'</td>';
print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
print '<td class="right">'.$langs->trans('RemainderToPay').'</td>';
@ -357,14 +357,14 @@ if ($resql)
$thirdpartystatic->fetch($objp->socid);
$invoice=new Facture($db);
$invoice = new Facture($db);
$invoice->fetch($objp->facid);
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
$creditnotes = $invoice->getSumCreditNotesUsed();
$deposits = $invoice->getSumDepositsUsed();
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
print '<tr class="oddeven">';
@ -379,7 +379,7 @@ if ($resql)
print '</td>';
// Expected to pay
if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){
if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) {
print '<td>';
$mc->getInfo($objp->entity);
print $mc->label;
@ -427,7 +427,7 @@ else
print '<div class="tabsAction">';
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{
if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
{
@ -442,7 +442,7 @@ if ($user->socid == 0 && $action == '')
{
if ($user->rights->facture->paiement)
{
if (! $disable_delete)
if (!$disable_delete)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}

View File

@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('bills', 'companies'));
$id=GETPOST('id');
$ref=GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$id = GETPOST('id');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
/*
* Actions
@ -58,7 +58,7 @@ $head = payment_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("PaymentCustomerInvoice"), -1, 'payment');
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/paiement/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '');

File diff suppressed because it is too large Load Diff

View File

@ -29,19 +29,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('compta','bills','donation','salaries'));
$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries'));
$date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday');
$date_startyear=GETPOST('date_startyear');
$date_endmonth=GETPOST('date_endmonth');
$date_endday=GETPOST('date_endday');
$date_endyear=GETPOST('date_endyear');
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
$nbofyear=4;
$nbofyear = 4;
// Date range
$year=GETPOST('year', 'int');
$year = GETPOST('year', 'int');
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
@ -52,55 +52,55 @@ if (empty($year))
$month_current = strftime("%m", dol_now());
$year_start = $year - ($nbofyear - 1);
}
$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
// We define date_start and date_end
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q")?GETPOST("q"):0;
if ($q==0)
$q = GETPOST("q") ?GETPOST("q") : 0;
if ($q == 0)
{
// We define date_start and date_end
$year_end=$year_start + ($nbofyear - 1);
$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
if (! GETPOST('month'))
$year_end = $year_start + ($nbofyear - 1);
$month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (!GETPOST('month'))
{
if (! GETPOST("year") && $month_start > $month_current)
if (!GETPOST("year") && $month_start > $month_current)
{
$year_start--;
$year_end--;
}
$month_end=$month_start-1;
if ($month_end < 1) $month_end=12;
$month_end = $month_start - 1;
if ($month_end < 1) $month_end = 12;
}
else $month_end=$month_start;
$date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false);
else $month_end = $month_start;
$date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
}
if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); }
if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); }
if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); }
if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); }
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
$userid=GETPOST('userid', 'int');
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
$tmps=dol_getdate($date_start);
$tmps = dol_getdate($date_start);
$year_start = $tmps['year'];
$tmpe=dol_getdate($date_end);
$tmpe = dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $year_start) + 1;
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
$modecompta = $conf->global->ACCOUNTING_MODE;
if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING';
if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta", 'alpha');
if (!empty($conf->accounting->enabled)) $modecompta = 'BOOKKEEPING';
if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta", 'alpha');
// Security check
if ($user->socid > 0) $socid = $user->socid;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport');
if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
@ -111,54 +111,54 @@ if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounti
llxHeader();
$form=new Form($db);
$form = new Form($db);
// Affiche en-tete du rapport
if ($modecompta=="CREANCES-DETTES")
if ($modecompta == "CREANCES-DETTES")
{
$name=$langs->trans("Turnover");
$calcmode=$langs->trans("CalcModeDebt");
$name = $langs->trans("Turnover");
$calcmode = $langs->trans("CalcModeDebt");
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">', '</a>').')';
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
$calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">', '</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesCADue");
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded");
else $description .= $langs->trans("DepositsAreIncluded");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta=="RECETTES-DEPENSES")
elseif ($modecompta == "RECETTES-DEPENSES")
{
$name=$langs->trans("TurnoverCollected");
$calcmode=$langs->trans("CalcModeEngagement");
$name = $langs->trans("TurnoverCollected");
$calcmode = $langs->trans("CalcModeEngagement");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
//$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPINGCOLLECTED">','</a>').')';
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
$builddate=dol_now();
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesCAIn");
$description .= $langs->trans("DepositsAreIncluded");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta=="BOOKKEEPING")
elseif ($modecompta == "BOOKKEEPING")
{
$name=$langs->trans("Turnover");
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">', '</a>').')';
$name = $langs->trans("Turnover");
$calcmode = $langs->trans("CalcModeBookkeeping");
$calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">', '</a>').')';
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCATotalSaleJournal");
$builddate=dol_now();
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesCATotalSaleJournal");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
$moreparam=array();
if (! empty($modecompta)) $moreparam['modecompta']=$modecompta;
$moreparam = array();
if (!empty($modecompta)) $moreparam['modecompta'] = $modecompta;
report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam, $calcmode);
if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{
print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
}
@ -167,39 +167,39 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)";
$sql.= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut in (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)";
else $sql .= " AND f.type IN (0,1,2,3,5)";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
}
elseif ($modecompta=="RECETTES-DEPENSES")
elseif ($modecompta == "RECETTES-DEPENSES")
{
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
*/
$sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql.= " WHERE p.rowid = pf.fk_paiement";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql .= ", ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.rowid = pf.fk_paiement";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
}
elseif ($modecompta=="BOOKKEEPING")
elseif ($modecompta == "BOOKKEEPING")
{
$sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj";
$sql.= " WHERE b.entity = ".$conf->entity;
$sql.= " AND aj.entity = ".$conf->entity;
$sql.= " AND b.code_journal = aj.code AND aj.nature = 2" ; // @todo currently count amount in sale journal, but we need to define a category group for turnover
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj";
$sql .= " WHERE b.entity = ".$conf->entity;
$sql .= " AND aj.entity = ".$conf->entity;
$sql .= " AND b.code_journal = aj.code AND aj.nature = 2"; // @todo currently count amount in sale journal, but we need to define a category group for turnover
}
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm";
//print $sql;
$result = $db->query($sql);
@ -214,8 +214,8 @@ if ($result)
$cum[$obj->dm] = $obj->amount_ttc;
if ($obj->amount_ttc)
{
$minyearmonth=($minyearmonth?min($minyearmonth, $obj->dm):$obj->dm);
$maxyearmonth=max($maxyearmonth, $obj->dm);
$minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm);
$maxyearmonth = max($maxyearmonth, $obj->dm);
}
$i++;
}
@ -229,16 +229,16 @@ else {
if ($modecompta == 'RECETTES-DEPENSES')
{
$sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql.= " WHERE pf.rowid IS NULL";
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= ", ".MAIN_DB_PREFIX."paiement as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql .= " WHERE pf.rowid IS NULL";
$sql .= " AND p.fk_bank = b.rowid";
$sql .= " AND b.fk_account = ba.rowid";
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm";
$result = $db->query($sql);
if ($result)
@ -251,8 +251,8 @@ if ($modecompta == 'RECETTES-DEPENSES')
$cum[$obj->dm] += $obj->amount_ttc;
if ($obj->amount_ttc)
{
$minyearmonth=($minyearmonth?min($minyearmonth, $obj->dm):$obj->dm);
$maxyearmonth=max($maxyearmonth, $obj->dm);
$minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm);
$maxyearmonth = max($maxyearmonth, $obj->dm);
}
$i++;
}
@ -263,20 +263,20 @@ if ($modecompta == 'RECETTES-DEPENSES')
}
}
$moreforfilter='';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre"><td>&nbsp;</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') print '<td align="center" width="10%" colspan="3">';
else print '<td align="center" width="10%" colspan="2" class="borderrightlight">';
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee.'">';
print $annee;
if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1);
if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee + 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
print '</td>';
if ($annee != $year_end) print '<td width="15">&nbsp;</td>';
@ -284,7 +284,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
print '</tr>';
print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') print '<td class="liste_titre right">'.$langs->trans("AmountHT").'</td>';
print '<td class="liste_titre right">'.$langs->trans("AmountTTC").'</td>';
@ -293,31 +293,31 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
}
print '</tr>';
$now_show_delta=0;
$minyear=substr($minyearmonth, 0, 4);
$maxyear=substr($maxyearmonth, 0, 4);
$nowyear=strftime("%Y", dol_now());
$nowyearmonth=strftime("%Y-%m", dol_now());
$maxyearmonth=max($maxyearmonth, $nowyearmonth);
$now=dol_now();
$now_show_delta = 0;
$minyear = substr($minyearmonth, 0, 4);
$maxyear = substr($maxyearmonth, 0, 4);
$nowyear = strftime("%Y", dol_now());
$nowyearmonth = strftime("%Y-%m", dol_now());
$maxyearmonth = max($maxyearmonth, $nowyearmonth);
$now = dol_now();
$casenow = dol_print_date($now, "%Y-%m");
// Loop on each month
$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0;
for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START - 1) : 0;
for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
{
$mois_modulo = $mois;// ajout
if($mois>12){$mois_modulo = $mois-12;} // ajout
$mois_modulo = $mois; // ajout
if ($mois > 12) {$mois_modulo = $mois - 12; } // ajout
print '<tr class="oddeven">';
print "<td>".dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, 2000), "%B")."</td>";
for ($annee = $year_start -1 ; $annee <= $year_end ; $annee++) // We start one year before to have data to be able to make delta
for ($annee = $year_start - 1; $annee <= $year_end; $annee++) // We start one year before to have data to be able to make delta
{
$annee_decalage=$annee;
if ($mois>12) {$annee_decalage=$annee+1;}
$annee_decalage = $annee;
if ($mois > 12) {$annee_decalage = $annee + 1; }
$case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m");
$caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage-1), "%Y-%m");
$caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m");
if ($annee >= $year_start) // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output.
{
@ -326,8 +326,8 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
print '<td class="right">';
if ($cum_ht[$case])
{
$now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre.
print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price($cum_ht[$case], 1).'</a>';
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">'.price($cum_ht[$case], 1).'</a>';
}
else
{
@ -341,8 +341,8 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
print '<td class="right">';
if ($cum[$case])
{
$now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre.
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">';
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">';
print price($cum[$case], 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
}
@ -358,24 +358,24 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
{
if ($cum[$caseprev] && $cum[$case])
{
$percent=(round(($cum[$case]-$cum[$caseprev])/$cum[$caseprev], 4)*100);
$percent = (round(($cum[$case] - $cum[$caseprev]) / $cum[$caseprev], 4) * 100);
//print "X $cum[$case] - $cum[$caseprev] - $cum[$caseprev] - $percent X";
print '<td class="borderrightlight right">'.($percent>=0?"+$percent":"$percent").'%</td>';
print '<td class="borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
}
if ($cum[$caseprev] && ! $cum[$case])
if ($cum[$caseprev] && !$cum[$case])
{
print '<td class="borderrightlight right">-100%</td>';
}
if (! $cum[$caseprev] && $cum[$case])
if (!$cum[$caseprev] && $cum[$case])
{
//print '<td class="right">+Inf%</td>';
print '<td class="borderrightlight right">-</td>';
}
if (isset($cum[$caseprev]) && ! $cum[$caseprev] && ! $cum[$case])
if (isset($cum[$caseprev]) && !$cum[$caseprev] && !$cum[$case])
{
print '<td class="borderrightlight right">+0%</td>';
}
if (! isset($cum[$caseprev]) && ! $cum[$case])
if (!isset($cum[$caseprev]) && !$cum[$case])
{
print '<td class="borderrightlight right">-</td>';
}
@ -391,7 +391,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print '<td width="15">&nbsp;</td>';
}
$total_ht[$annee] += ((! empty($cum_ht[$case])) ? $cum_ht[$case] : 0);
$total_ht[$annee] += ((!empty($cum_ht[$case])) ? $cum_ht[$case] : 0);
$total[$annee] += $cum[$case];
}
@ -465,13 +465,13 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
// Affiche total
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') {
// Montant total HT
if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear)))
{
print '<td class="nowrap right">'.($total_ht[$annee]?price($total_ht[$annee]):"0")."</td>";
print '<td class="nowrap right">'.($total_ht[$annee] ?price($total_ht[$annee]) : "0")."</td>";
}
else
{
@ -482,7 +482,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
// Montant total
if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear)))
{
print '<td class="nowrap right">'.($total[$annee]?price($total[$annee]):"0")."</td>";
print '<td class="nowrap right">'.($total[$annee] ?price($total[$annee]) : "0")."</td>";
}
else
{
@ -492,19 +492,19 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
// Pourcentage total
if ($annee > $minyear && $annee <= max($nowyear, $maxyear))
{
if ($total[$annee-1] && $total[$annee]) {
$percent=(round(($total[$annee]-$total[$annee-1])/$total[$annee-1], 4)*100);
print '<td class="nowrap borderrightlight right">'.($percent>=0?"+$percent":"$percent").'%</td>';
if ($total[$annee - 1] && $total[$annee]) {
$percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100);
print '<td class="nowrap borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
}
if ($total[$annee-1] && ! $total[$annee])
if ($total[$annee - 1] && !$total[$annee])
{
print '<td class="borderrightlight right">-100%</td>';
}
if (! $total[$annee-1] && $total[$annee])
if (!$total[$annee - 1] && $total[$annee])
{
print '<td class="borderrightlight right">+'.$langs->trans('Inf').'%</td>';
}
if (! $total[$annee-1] && ! $total[$annee])
if (!$total[$annee - 1] && !$total[$annee])
{
print '<td class="borderrightlight right">+0%</td>';
}

View File

@ -40,30 +40,30 @@ if (GETPOST('addfile', 'alpha'))
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$vardir = $conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
dol_add_file_process($upload_dir_tmp, 1, 0, 'addedfile', '', null, $trackid, 0);
$action='presend';
$action = 'presend';
}
/*
* Remove file in email form
*/
if (! empty($_POST['removedfile']) && empty($_POST['removAll']))
if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
{
$trackid = GETPOST('trackid', 'aZ09');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Set tmp user directory
$vardir=$conf->user->dir_output."/".$user->id;
$vardir = $conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
// TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
// GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
dol_remove_file_process(GETPOST('removedfile', 'alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
$action='presend';
$action = 'presend';
}
/*
@ -73,19 +73,19 @@ if (GETPOST('removAll', 'alpha'))
{
$trackid = GETPOST('trackid', 'aZ09');
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
$keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->trackid = $trackid;
foreach($listofpaths as $key => $value)
foreach ($listofpaths as $key => $value)
{
$pathtodelete = $value;
$filetodelete = $listofnames[$key];
@ -101,84 +101,84 @@ if (GETPOST('removAll', 'alpha'))
/*
* Send mail
*/
if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
{
if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
$subject='';$actionmsg='';$actionmsg2='';
$subject = ''; $actionmsg = ''; $actionmsg2 = '';
$langs->load('mails');
if (is_object($object))
{
$result=$object->fetch($id);
$result = $object->fetch($id);
$sendtosocid=0; // Id of related thirdparty
if (method_exists($object, "fetch_thirdparty") && ! in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact')))
$sendtosocid = 0; // Id of related thirdparty
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact')))
{
$result=$object->fetch_thirdparty();
if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok
$thirdparty=$object->thirdparty;
$sendtosocid=$thirdparty->id;
$result = $object->fetch_thirdparty();
if ($object->element == 'user' && $result == 0) $result = 1; // Even if not found, we consider ok
$thirdparty = $object->thirdparty;
$sendtosocid = $thirdparty->id;
}
elseif ($object->element == 'member' || $object->element == 'user')
{
$thirdparty=$object;
if ($object->socid > 0) $sendtosocid=$object->socid;
$thirdparty = $object;
if ($object->socid > 0) $sendtosocid = $object->socid;
}
elseif ($object->element == 'expensereport')
{
$tmpuser=new User($db);
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$thirdparty=$tmpuser;
if ($object->socid > 0) $sendtosocid=$object->socid;
$thirdparty = $tmpuser;
if ($object->socid > 0) $sendtosocid = $object->socid;
}
elseif ($object->element == 'societe')
{
$thirdparty=$object;
if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
$thirdparty = $object;
if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id;
}
elseif ($object->element == 'contact')
{
$contact=$object;
if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id;
$contact = $object;
if ($contact->id > 0) $sendtosocid = $contact->fetch_thirdparty()->id;
}
else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
if (is_object($hookmanager))
{
$parameters=array();
$reshook=$hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
}
}
else $thirdparty = $mysoc;
if ($result > 0)
{
$sendto='';
$sendtocc='';
$sendtobcc='';
$sendto = '';
$sendtocc = '';
$sendtobcc = '';
$sendtoid = array();
$sendtouserid=array();
$sendtoccuserid=array();
$sendtouserid = array();
$sendtoccuserid = array();
// Define $sendto
$receiver=$_POST['receiver'];
if (! is_array($receiver))
$receiver = $_POST['receiver'];
if (!is_array($receiver))
{
if ($receiver == '-1') $receiver=array();
else $receiver=array($receiver);
if ($receiver == '-1') $receiver = array();
else $receiver = array($receiver);
}
$tmparray=array();
$tmparray = array();
if (trim($_POST['sendto']))
{
// Recipients are provided into free text
$tmparray[] = trim($_POST['sendto']);
}
if (count($receiver)>0)
if (count($receiver) > 0)
{
foreach($receiver as $key=>$val)
foreach ($receiver as $key=>$val)
{
// Recipient was provided from combo list
if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too)
@ -200,11 +200,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{
$receiveruser=$_POST['receiveruser'];
if (is_array($receiveruser) && count($receiveruser)>0)
$receiveruser = $_POST['receiveruser'];
if (is_array($receiveruser) && count($receiveruser) > 0)
{
$fuserdest = new User($db);
foreach($receiveruser as $key=>$val)
foreach ($receiveruser as $key=>$val)
{
$tmparray[] = $fuserdest->user_get_property($val, 'email');
$sendtouserid[] = $val;
@ -212,23 +212,23 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
$sendto=implode(',', $tmparray);
$sendto = implode(',', $tmparray);
// Define $sendtocc
$receivercc=$_POST['receivercc'];
if (! is_array($receivercc))
$receivercc = $_POST['receivercc'];
if (!is_array($receivercc))
{
if ($receivercc == '-1') $receivercc=array();
else $receivercc=array($receivercc);
if ($receivercc == '-1') $receivercc = array();
else $receivercc = array($receivercc);
}
$tmparray=array();
$tmparray = array();
if (trim($_POST['sendtocc']))
{
$tmparray[] = trim($_POST['sendtocc']);
}
if (count($receivercc) > 0)
{
foreach($receivercc as $key=>$val)
foreach ($receivercc as $key=>$val)
{
// Recipient was provided from combo list
if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too)
@ -248,25 +248,25 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$receiverccuser=$_POST['receiverccuser'];
$receiverccuser = $_POST['receiverccuser'];
if (is_array($receiverccuser) && count($receiverccuser)>0)
if (is_array($receiverccuser) && count($receiverccuser) > 0)
{
$fuserdest = new User($db);
foreach($receiverccuser as $key=>$val)
foreach ($receiverccuser as $key=>$val)
{
$tmparray[] = $fuserdest->user_get_property($val, 'email');
$sendtoccuserid[] = $val;
}
}
}
$sendtocc=implode(',', $tmparray);
$sendtocc = implode(',', $tmparray);
if (dol_strlen($sendto))
{
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
@ -275,24 +275,24 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$fromtype = GETPOST('fromtype', 'alpha');
if ($fromtype === 'robot') {
$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
}
elseif ($fromtype === 'user') {
$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
}
elseif ($fromtype === 'company') {
$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
}
elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
$tmp=explode(',', $user->email_aliases);
$tmp = explode(',', $user->email_aliases);
$from = trim($tmp[($reg[1] - 1)]);
}
elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
$tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
$tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
$from = trim($tmp[($reg[1] - 1)]);
}
elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
@ -301,10 +301,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
}
else {
$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")).' <'.$_POST['frommail'].'>';
}
$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>';
$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")).' <'.$_POST['replytomail'].'>';
$message = GETPOST('message', 'none');
$subject = GETPOST('subject', 'none');
@ -312,28 +312,28 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
// become
// <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
$message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
$message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
$sendtobcc= GETPOST('sendtoccc');
$sendtobcc = GETPOST('sendtoccc');
// Autocomplete the $sendtobcc
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
if (! empty($autocopy))
if (!empty($autocopy))
{
$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
}
$deliveryreceipt = $_POST['deliveryreceipt'];
if ($action == 'send' || $action == 'relance')
{
$actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
if ($message)
{
$actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
}
@ -343,7 +343,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$formmail = new FormMail($db);
$formmail->trackid = $trackid; // $trackid must be defined
$attachedfiles=$formmail->get_attached_files();
$attachedfiles = $formmail->get_attached_files();
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
@ -393,15 +393,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
*/
// Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$parameters=array('mode'=>'formemail');
$parameters = array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
$subject=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray);
$subject = make_substitutions($subject, $substitutionarray);
$message = make_substitutions($message, $substitutionarray);
if (method_exists($object, 'makeSubstitution'))
{
@ -416,17 +416,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($mailfile->error)
{
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action='presend';
$action = 'presend';
}
else
{
$result=$mailfile->sendfile();
$result = $mailfile->sendfile();
if ($result)
{
// Initialisation of datas of object to call trigger
if (is_object($object))
{
if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$object->socid = $sendtosocid; // To link to a company
$object->sendtoid = $sendtoid; // To link to contact addresses. This is an array.
@ -437,10 +437,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
if (is_array($attachedfiles) && count($attachedfiles)>0) {
if (is_array($attachedfiles) && count($attachedfiles) > 0) {
$object->attachedfiles = $attachedfiles;
}
if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
if (is_array($sendtouserid) && count($sendtouserid) > 0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$object->sendtouserid = $sendtouserid;
}
@ -454,11 +454,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$object->email_msgid = $mailfile->msgid;
// Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprcated)
if (! empty($triggersendname) || ! empty($trigger_name))
if (!empty($triggersendname) || !empty($trigger_name))
{
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers(empty($triggersendname)?$trigger_name:$triggersendname, $object, $user, $langs, $conf);
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
$interface = new Interfaces($db);
$result = $interface->run_triggers(empty($triggersendname) ? $trigger_name : $triggersendname, $object, $user, $langs, $conf);
if ($result < 0) {
setEventMessages($interface->error, $interface->errors, 'errors');
}
@ -467,28 +467,28 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Redirect here
// This avoid sending mail twice if going out and then back to page
$mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
setEventMessages($mesg, null, 'mesgs');
$moreparam='';
if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
$moreparam = '';
if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
exit;
}
else
{
$langs->load("other");
$mesg='<div class="error">';
$mesg = '<div class="error">';
if ($mailfile->error)
{
$mesg.=$langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
$mesg.='<br>'.$mailfile->error;
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
$mesg .= '<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
$mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
$mesg .= '</div>';
setEventMessages($mesg, null, 'warnings');
$action = 'presend';

View File

@ -62,22 +62,22 @@ class Utils
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$filesarray=array();
if (empty($choice)) $choice='tempfilesold';
$filesarray = array();
if (empty($choice)) $choice = 'tempfilesold';
dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG);
if ($choice=='tempfiles' || $choice=='tempfilesold')
if ($choice == 'tempfiles' || $choice == 'tempfilesold')
{
// Delete temporary files
if ($dolibarr_main_data_root)
{
$filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks
$filesarray = dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks
if ($choice == 'tempfilesold')
{
$now = dol_now();
foreach($filesarray as $key => $val)
foreach ($filesarray as $key => $val)
{
if ($val['date'] > ($now - ($nbsecondsold))) unset($filesarray[$key]); // Discard temp dir not older than $nbsecondsold
}
@ -85,61 +85,61 @@ class Utils
}
}
if ($choice=='allfiles')
if ($choice == 'allfiles')
{
// Delete all files (except install.lock, do not follow symbolic links)
if ($dolibarr_main_data_root)
{
$filesarray=dol_dir_list($dolibarr_main_data_root, "all", 0, '', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1);
$filesarray = dol_dir_list($dolibarr_main_data_root, "all", 0, '', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1);
}
}
if ($choice=='logfile')
if ($choice == 'logfile')
{
// Define files log
if ($dolibarr_main_data_root)
{
$filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*(\.gz)?$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1);
$filesarray = dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*(\.gz)?$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1);
}
$filelog='';
if (! empty($conf->syslog->enabled))
$filelog = '';
if (!empty($conf->syslog->enabled))
{
$filelog=$conf->global->SYSLOG_FILE;
$filelog=preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog);
$filelog = $conf->global->SYSLOG_FILE;
$filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog);
$alreadyincluded=false;
$alreadyincluded = false;
foreach ($filesarray as $tmpcursor)
{
if ($tmpcursor['fullname'] == $filelog) { $alreadyincluded=true; }
if ($tmpcursor['fullname'] == $filelog) { $alreadyincluded = true; }
}
if (! $alreadyincluded) $filesarray[]=array('fullname'=>$filelog,'type'=>'file');
if (!$alreadyincluded) $filesarray[] = array('fullname'=>$filelog, 'type'=>'file');
}
}
$count=0;
$countdeleted=0;
$counterror=0;
$count = 0;
$countdeleted = 0;
$counterror = 0;
if (count($filesarray))
{
foreach($filesarray as $key => $value)
foreach ($filesarray as $key => $value)
{
//print "x ".$filesarray[$key]['fullname']."-".$filesarray[$key]['type']."<br>\n";
if ($filesarray[$key]['type'] == 'dir')
{
$startcount=0;
$tmpcountdeleted=0;
$startcount = 0;
$tmpcountdeleted = 0;
$result=dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted);
$count+=$result;
$countdeleted+=$tmpcountdeleted;
$result = dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted);
$count += $result;
$countdeleted += $tmpcountdeleted;
}
elseif ($filesarray[$key]['type'] == 'file')
{
// If (file that is not logfile) or (if mode is logfile)
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
if ($filesarray[$key]['fullname'] != $filelog || $choice == 'logfile')
{
$result=dol_delete_file($filesarray[$key]['fullname'], 1, 1);
$result = dol_delete_file($filesarray[$key]['fullname'], 1, 1);
if ($result)
{
$count++;
@ -154,7 +154,7 @@ class Utils
}
// Update cachenbofdoc
if (! empty($conf->ecm->enabled) && $choice=='allfiles')
if (!empty($conf->ecm->enabled) && $choice == 'allfiles')
{
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
$ecmdirstatic = new EcmDirectory($this->db);
@ -164,13 +164,13 @@ class Utils
if ($count > 0)
{
$this->output=$langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
if ($count > $countdeleted) $this->output.='<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
$this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
if ($count > $countdeleted) $this->output .= '<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
}
else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':'');
else $this->output = $langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)' : '');
// Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them
if (! empty($conf->api->enabled))
if (!empty($conf->api->enabled))
{
dol_mkdir($conf->api->dir_temp);
}
@ -204,114 +204,114 @@ class Utils
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Check compression parameter
if (! in_array($compression, array('none', 'gz', 'bz', 'zip')))
if (!in_array($compression, array('none', 'gz', 'bz', 'zip')))
{
$langs->load("errors");
$this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $compression, "Compression");
$this->error = $langs->transnoentitiesnoconv("ErrorBadValueForParameter", $compression, "Compression");
return -1;
}
// Check type parameter
if ($type == 'auto') $type = $db->type;
if (! in_array($type, array('postgresql', 'pgsql', 'mysql', 'mysqli', 'mysqlnobin')))
if (!in_array($type, array('postgresql', 'pgsql', 'mysql', 'mysqli', 'mysqlnobin')))
{
$langs->load("errors");
$this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $type, "Basetype");
$this->error = $langs->transnoentitiesnoconv("ErrorBadValueForParameter", $type, "Basetype");
return -1;
}
// Check file parameter
if ($file == 'auto')
{
$prefix='dump';
$ext='sql';
if (in_array($type, array('mysql', 'mysqli'))) { $prefix='mysqldump'; $ext='sql'; }
$prefix = 'dump';
$ext = 'sql';
if (in_array($type, array('mysql', 'mysqli'))) { $prefix = 'mysqldump'; $ext = 'sql'; }
//if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; }
if (in_array($type, array('pgsql'))) { $prefix='pg_dump'; $ext='sql'; }
$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
if (in_array($type, array('pgsql'))) { $prefix = 'pg_dump'; $ext = 'sql'; }
$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
}
$outputdir = $conf->admin->dir_output.'/backup';
$result=dol_mkdir($outputdir);
$result = dol_mkdir($outputdir);
// MYSQL
if ($type == 'mysql' || $type == 'mysqli')
{
$cmddump=$conf->global->SYSTEMTOOLS_MYSQLDUMP;
$cmddump = $conf->global->SYSTEMTOOLS_MYSQLDUMP;
$outputfile = $outputdir.'/'.$file;
// for compression format, we add extension
$compression=$compression ? $compression : 'none';
if ($compression == 'gz') $outputfile.='.gz';
if ($compression == 'bz') $outputfile.='.bz2';
$compression = $compression ? $compression : 'none';
if ($compression == 'gz') $outputfile .= '.gz';
if ($compression == 'bz') $outputfile .= '.bz2';
$outputerror = $outputfile.'.err';
dol_mkdir($conf->admin->dir_output.'/backup');
// Parameteres execution
$command = $cmddump;
$command = preg_replace('/(\$|%)/', '', $command); // We removed chars that can be used to inject vars that contains space inside path of command without seeing there is a space to bypass the escapeshellarg.
if (preg_match("/\s/", $command)) $command=escapeshellarg($command); // If there is spaces, we add quotes on command to be sure $command is only a program and not a program+parameters
if (preg_match("/\s/", $command)) $command = escapeshellarg($command); // If there is spaces, we add quotes on command to be sure $command is only a program and not a program+parameters
//$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
$param=$dolibarr_main_db_name." -h ".$dolibarr_main_db_host;
$param.=" -u ".$dolibarr_main_db_user;
if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port;
if (! GETPOST("use_transaction", "alpha")) $param.=" -l --single-transaction";
if (GETPOST("disable_fk", "alpha") || $usedefault) $param.=" -K";
if (GETPOST("sql_compat", "alpha") && GETPOST("sql_compat", "alpha") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat", "alpha"));
if (GETPOST("drop_database", "alpha")) $param.=" --add-drop-database";
if (GETPOST("use_mysql_quick_param", "alpha"))$param.=" --quick";
$param = $dolibarr_main_db_name." -h ".$dolibarr_main_db_host;
$param .= " -u ".$dolibarr_main_db_user;
if (!empty($dolibarr_main_db_port)) $param .= " -P ".$dolibarr_main_db_port;
if (!GETPOST("use_transaction", "alpha")) $param .= " -l --single-transaction";
if (GETPOST("disable_fk", "alpha") || $usedefault) $param .= " -K";
if (GETPOST("sql_compat", "alpha") && GETPOST("sql_compat", "alpha") != 'NONE') $param .= " --compatible=".escapeshellarg(GETPOST("sql_compat", "alpha"));
if (GETPOST("drop_database", "alpha")) $param .= " --add-drop-database";
if (GETPOST("use_mysql_quick_param", "alpha"))$param .= " --quick";
if (GETPOST("sql_structure", "alpha") || $usedefault)
{
if (GETPOST("drop", "alpha") || $usedefault) $param.=" --add-drop-table=TRUE";
else $param.=" --add-drop-table=FALSE";
if (GETPOST("drop", "alpha") || $usedefault) $param .= " --add-drop-table=TRUE";
else $param .= " --add-drop-table=FALSE";
}
else
{
$param.=" -t";
$param .= " -t";
}
if (GETPOST("disable-add-locks", "alpha")) $param.=" --add-locks=FALSE";
if (GETPOST("disable-add-locks", "alpha")) $param .= " --add-locks=FALSE";
if (GETPOST("sql_data", "alpha") || $usedefault)
{
$param.=" --tables";
if (GETPOST("showcolumns", "alpha") || $usedefault) $param.=" -c";
if (GETPOST("extended_ins", "alpha") || $usedefault) $param.=" -e";
else $param.=" --skip-extended-insert";
if (GETPOST("delayed", "alpha")) $param.=" --delayed-insert";
if (GETPOST("sql_ignore", "alpha")) $param.=" --insert-ignore";
if (GETPOST("hexforbinary", "alpha") || $usedefault) $param.=" --hex-blob";
$param .= " --tables";
if (GETPOST("showcolumns", "alpha") || $usedefault) $param .= " -c";
if (GETPOST("extended_ins", "alpha") || $usedefault) $param .= " -e";
else $param .= " --skip-extended-insert";
if (GETPOST("delayed", "alpha")) $param .= " --delayed-insert";
if (GETPOST("sql_ignore", "alpha")) $param .= " --insert-ignore";
if (GETPOST("hexforbinary", "alpha") || $usedefault) $param .= " --hex-blob";
}
else
{
$param.=" -d"; // No row information (no data)
$param .= " -d"; // No row information (no data)
}
$param.=" --default-character-set=utf8"; // We always save output into utf8 charset
$paramcrypted=$param;
$paramclear=$param;
if (! empty($dolibarr_main_db_pass))
$param .= " --default-character-set=utf8"; // We always save output into utf8 charset
$paramcrypted = $param;
$paramclear = $param;
if (!empty($dolibarr_main_db_pass))
{
$paramcrypted.=' -p"'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'"';
$paramclear.=' -p"'.str_replace(array('"','`'), array('\"','\`'), $dolibarr_main_db_pass).'"';
$paramcrypted .= ' -p"'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'"';
$paramclear .= ' -p"'.str_replace(array('"', '`'), array('\"', '\`'), $dolibarr_main_db_pass).'"';
}
$errormsg='';
$errormsg = '';
$handle = '';
// Start call method to execute dump
$fullcommandcrypted=$command." ".$paramcrypted." 2>&1";
$fullcommandclear=$command." ".$paramclear." 2>&1";
$fullcommandcrypted = $command." ".$paramcrypted." 2>&1";
$fullcommandclear = $command." ".$paramclear." 2>&1";
if ($compression == 'none') $handle = fopen($outputfile, 'w');
if ($compression == 'gz') $handle = gzopen($outputfile, 'w');
if ($compression == 'bz') $handle = bzopen($outputfile, 'w');
if ($handle)
{
if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod=$conf->global->MAIN_EXEC_USE_POPEN;
if (empty($execmethod)) $execmethod=1;
if (!empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod = $conf->global->MAIN_EXEC_USE_POPEN;
if (empty($execmethod)) $execmethod = 1;
$ok=0;
$ok = 0;
dol_syslog("Utils::dumpDatabase execmethod=".$execmethod." command:".$fullcommandcrypted, LOG_DEBUG);
// TODO Replace with executeCLI function
@ -325,20 +325,20 @@ class Utils
$langs->load("errors");
dol_syslog("Datadump retval after exec=".$retval, LOG_ERR);
$errormsg = 'Error '.$retval;
$ok=0;
$ok = 0;
}
else
{
$i=0;
$i = 0;
if (!empty($output_arr))
{
foreach($output_arr as $key => $read)
foreach ($output_arr as $key => $read)
{
$i++; // output line number
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue;
fwrite($handle, $read.($execmethod == 2 ? '' : "\n"));
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok=1;
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok=1;
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok = 1;
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok = 1;
}
}
}
@ -346,7 +346,7 @@ class Utils
if ($execmethod == 2) // With this method, there is no way to get the return code, only output
{
$handlein = popen($fullcommandclear, 'r');
$i=0;
$i = 0;
while (!feof($handlein))
{
$i++; // output line number
@ -354,8 +354,8 @@ class Utils
// Exclude warning line we don't want
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue;
fwrite($handle, $read);
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok=1;
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok=1;
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) $ok = 1;
elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) $ok = 1;
}
pclose($handlein);
}
@ -365,14 +365,14 @@ class Utils
if ($compression == 'gz') gzclose($handle);
if ($compression == 'bz') bzclose($handle);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
else
{
$langs->load("errors");
dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
$errormsg=$langs->trans("ErrorFailedToWriteInDir");
$errormsg = $langs->trans("ErrorFailedToWriteInDir");
}
// Get errorstring
@ -387,7 +387,7 @@ class Utils
if ($compression == 'none') fclose($handle);
if ($compression == 'gz') gzclose($handle);
if ($compression == 'bz') bzclose($handle);
if ($ok && preg_match('/^-- MySql/i', $errormsg)) $errormsg=''; // Pas erreur
if ($ok && preg_match('/^-- MySql/i', $errormsg)) $errormsg = ''; // Pas erreur
else
{
// Renommer fichier sortie en fichier erreur
@ -395,10 +395,10 @@ class Utils
@dol_delete_file($outputerror, 1, 0, 0, null, false, 0);
@rename($outputfile, $outputerror);
// Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide
if (! $errormsg)
if (!$errormsg)
{
$langs->load("errors");
$errormsg=$langs->trans("ErrorFailedToRunExternalCommand");
$errormsg = $langs->trans("ErrorFailedToRunExternalCommand");
}
}
}
@ -416,9 +416,9 @@ class Utils
$outputfile = $outputdir.'/'.$file;
$outputfiletemp = $outputfile.'-TMP.sql';
// for compression format, we add extension
$compression=$compression ? $compression : 'none';
if ($compression == 'gz') $outputfile.='.gz';
if ($compression == 'bz') $outputfile.='.bz2';
$compression = $compression ? $compression : 'none';
if ($compression == 'gz') $outputfile .= '.gz';
if ($compression == 'bz') $outputfile .= '.bz2';
$outputerror = $outputfile.'.err';
dol_mkdir($conf->admin->dir_output.'/backup');
@ -440,52 +440,52 @@ class Utils
// POSTGRESQL
if ($type == 'postgresql' || $type == 'pgsql')
{
$cmddump=$conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
$cmddump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
$outputfile = $outputdir.'/'.$file;
// for compression format, we add extension
$compression=$compression ? $compression : 'none';
if ($compression == 'gz') $outputfile.='.gz';
if ($compression == 'bz') $outputfile.='.bz2';
$compression = $compression ? $compression : 'none';
if ($compression == 'gz') $outputfile .= '.gz';
if ($compression == 'bz') $outputfile .= '.bz2';
$outputerror = $outputfile.'.err';
dol_mkdir($conf->admin->dir_output.'/backup');
// Parameteres execution
$command = $cmddump;
$command = preg_replace('/(\$|%)/', '', $command); // We removed chars that can be used to inject vars that contains space inside path of command without seeing there is a space to bypass the escapeshellarg.
if (preg_match("/\s/", $command)) $command=escapeshellarg($command); // If there is spaces, we add quotes on command to be sure $command is only a program and not a program+parameters
if (preg_match("/\s/", $command)) $command = escapeshellarg($command); // If there is spaces, we add quotes on command to be sure $command is only a program and not a program+parameters
//$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
//$param="-F c";
$param="-F p";
$param.=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host;
$param.=" -U ".$dolibarr_main_db_user;
if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port;
if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param.=" --disable-dollar-quoting";
if (GETPOST("drop_database")) $param.=" -c -C";
$param = "-F p";
$param .= " --no-tablespaces --inserts -h ".$dolibarr_main_db_host;
$param .= " -U ".$dolibarr_main_db_user;
if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port;
if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param .= " --disable-dollar-quoting";
if (GETPOST("drop_database")) $param .= " -c -C";
if (GETPOST("sql_structure"))
{
if (GETPOST("drop")) $param.=" --add-drop-table";
if (! GETPOST("sql_data")) $param.=" -s";
if (GETPOST("drop")) $param .= " --add-drop-table";
if (!GETPOST("sql_data")) $param .= " -s";
}
if (GETPOST("sql_data"))
{
if (! GETPOST("sql_structure")) $param.=" -a";
if (GETPOST("showcolumns")) $param.=" -c";
if (!GETPOST("sql_structure")) $param .= " -a";
if (GETPOST("showcolumns")) $param .= " -c";
}
$param.=' -f "'.$outputfile.'"';
$param .= ' -f "'.$outputfile.'"';
//if ($compression == 'none')
if ($compression == 'gz') $param.=' -Z 9';
if ($compression == 'gz') $param .= ' -Z 9';
//if ($compression == 'bz')
$paramcrypted=$param;
$paramclear=$param;
$paramcrypted = $param;
$paramclear = $param;
/*if (! empty($dolibarr_main_db_pass))
{
$paramcrypted.=" -W".preg_replace('/./i','*',$dolibarr_main_db_pass);
$paramclear.=" -W".$dolibarr_main_db_pass;
}*/
$paramcrypted.=" -w ".$dolibarr_main_db_name;
$paramclear.=" -w ".$dolibarr_main_db_name;
$paramcrypted .= " -w ".$dolibarr_main_db_name;
$paramclear .= " -w ".$dolibarr_main_db_name;
$this->output = "";
$this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => $command." ".$paramcrypted);
@ -495,8 +495,8 @@ class Utils
if ($keeplastnfiles > 0)
{
$tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC);
$i=0;
foreach($tmpfiles as $key => $val)
$i = 0;
foreach ($tmpfiles as $key => $val)
{
$i++;
if ($i <= $keeplastnfiles) continue;
@ -525,15 +525,15 @@ class Utils
$output = '';
$error = '';
$command=escapeshellcmd($command);
$command.=" 2>&1";
$command = escapeshellcmd($command);
$command .= " 2>&1";
if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod=$conf->global->MAIN_EXEC_USE_POPEN;
if (empty($execmethod)) $execmethod=1;
if (!empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod = $conf->global->MAIN_EXEC_USE_POPEN;
if (empty($execmethod)) $execmethod = 1;
//$execmethod=1;
dol_syslog("Utils::executeCLI execmethod=".$execmethod." system:".$command, LOG_DEBUG);
$output_arr=array();
$output_arr = array();
if ($execmethod == 1)
{
@ -558,20 +558,20 @@ class Utils
{
$read = fgets($handlein);
fwrite($handle, $read);
$output_arr[]=$read;
$output_arr[] = $read;
}
pclose($handlein);
fclose($handle);
}
if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
if (!empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
// Update with result
if (is_array($output_arr) && count($output_arr)>0)
if (is_array($output_arr) && count($output_arr) > 0)
{
foreach($output_arr as $val)
foreach ($output_arr as $val)
{
$output.=$val.($execmethod == 2 ? '' : "\n");
$output .= $val.($execmethod == 2 ? '' : "\n");
}
}
@ -593,24 +593,24 @@ class Utils
$error = 0;
$modulelowercase=strtolower($module);
$now=dol_now();
$modulelowercase = strtolower($module);
$now = dol_now();
// Dir for module
$dir = $dirins.'/'.$modulelowercase;
// Zip file to build
$FILENAMEDOC='';
$FILENAMEDOC = '';
// Load module
dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
$class='mod'.$module;
$class = 'mod'.$module;
if (class_exists($class))
{
try {
$moduleobj = new $class($this->db);
}
catch(Exception $e)
catch (Exception $e)
{
$error++;
dol_print_error($e->getMessage());
@ -624,12 +624,12 @@ class Utils
exit;
}
$arrayversion=explode('.', $moduleobj->version, 3);
$arrayversion = explode('.', $moduleobj->version, 3);
if (count($arrayversion))
{
$FILENAMEASCII=strtolower($module).'.asciidoc';
$FILENAMEDOC=strtolower($module).'.html';
$FILENAMEDOCPDF=strtolower($module).'.pdf';
$FILENAMEASCII = strtolower($module).'.asciidoc';
$FILENAMEDOC = strtolower($module).'.html';
$FILENAMEDOCPDF = strtolower($module).'.pdf';
$dirofmodule = dol_buildpath(strtolower($module), 0);
$dirofmoduledoc = dol_buildpath(strtolower($module), 0).'/doc';
@ -637,9 +637,9 @@ class Utils
$outputfiledoc = $dirofmoduledoc.'/'.$FILENAMEDOC;
if ($dirofmoduledoc)
{
if (! dol_is_dir($dirofmoduledoc)) dol_mkdir($dirofmoduledoc);
if (! dol_is_dir($dirofmoduletmp)) dol_mkdir($dirofmoduletmp);
if (! is_writable($dirofmoduletmp))
if (!dol_is_dir($dirofmoduledoc)) dol_mkdir($dirofmoduledoc);
if (!dol_is_dir($dirofmoduletmp)) dol_mkdir($dirofmoduletmp);
if (!is_writable($dirofmoduletmp))
{
$this->error = 'Dir '.$dirofmoduletmp.' does not exists or is not writable';
return -1;
@ -656,20 +656,20 @@ class Utils
dol_copy($dirofmodule.'/ChangeLog.md', $dirofmoduletmp.'/ChangeLog.md', 0, 1);
// Replace into README.md and ChangeLog.md (in case they are included into documentation with tag __README__ or __CHANGELOG__)
$arrayreplacement=array();
$arrayreplacement['/^#\s.*/m']=''; // Remove first level of title into .md files
$arrayreplacement['/^#/m']='##'; // Add on # to increase level
$arrayreplacement = array();
$arrayreplacement['/^#\s.*/m'] = ''; // Remove first level of title into .md files
$arrayreplacement['/^#/m'] = '##'; // Add on # to increase level
dolReplaceInFile($dirofmoduletmp.'/README.md', $arrayreplacement, '', 0, 0, 1);
dolReplaceInFile($dirofmoduletmp.'/ChangeLog.md', $arrayreplacement, '', 0, 0, 1);
$destfile=$dirofmoduletmp.'/'.$FILENAMEASCII;
$destfile = $dirofmoduletmp.'/'.$FILENAMEASCII;
$fhandle = fopen($destfile, 'w+');
if ($fhandle)
{
$specs=dol_dir_list(dol_buildpath(strtolower($module).'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/'));
$specs = dol_dir_list(dol_buildpath(strtolower($module).'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/'));
$i = 0;
foreach ($specs as $spec)
@ -679,8 +679,8 @@ class Utils
if (preg_match('/disabled/', $spec['relativename'])) continue; // Discard file
$pathtofile = strtolower($module).'/doc/'.$spec['relativename'];
$format='asciidoc';
if (preg_match('/\.md$/i', $spec['name'])) $format='markdown';
$format = 'asciidoc';
if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown';
$filecursor = @file_get_contents($spec['fullname']);
if ($filecursor)
@ -698,13 +698,13 @@ class Utils
fclose($fhandle);
$contentreadme=file_get_contents($dirofmoduletmp.'/README.md');
$contentchangelog=file_get_contents($dirofmoduletmp.'/ChangeLog.md');
$contentreadme = file_get_contents($dirofmoduletmp.'/README.md');
$contentchangelog = file_get_contents($dirofmoduletmp.'/ChangeLog.md');
include DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
//var_dump($phpfileval['fullname']);
$arrayreplacement=array(
$arrayreplacement = array(
'mymodule'=>strtolower($module),
'MyModule'=>$module,
'MYMODULE'=>strtoupper($module),
@ -718,7 +718,7 @@ class Utils
'__USER_FULLNAME__'=>$user->getFullName($langs),
'__USER_EMAIL__'=>$user->email,
'__YYYY-MM-DD__'=>dol_print_date($now, 'dayrfc'),
'---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':''),
'---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : ''),
'__DATA_SPECIFICATION__'=>'Not yet available',
'__README__'=>dolMd2Asciidoc($contentreadme),
'__CHANGELOG__'=>dolMd2Asciidoc($contentchangelog),
@ -735,8 +735,8 @@ class Utils
$utils = new Utils($this->db);
// Build HTML doc
$command=$conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC;
$outfile=$dirofmoduletmp.'/out.tmp';
$command = $conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOC;
$outfile = $dirofmoduletmp.'/out.tmp';
$resarray = $utils->executeCLI($command, $outfile);
if ($resarray['result'] != '0')
@ -746,8 +746,8 @@ class Utils
$result = ($resarray['result'] == 0) ? 1 : 0;
// Build PDF doc
$command=$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOCPDF;
$outfile=$dirofmoduletmp.'/outpdf.tmp';
$command = $conf->global->MODULEBUILDER_ASCIIDOCTORPDF.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOCPDF;
$outfile = $dirofmoduletmp.'/outpdf.tmp';
$resarray = $utils->executeCLI($command, $outfile);
if ($resarray['result'] != '0')
{
@ -794,11 +794,11 @@ class Utils
{
global $conf;
if(empty($conf->loghandlers['mod_syslog_file'])) { // File Syslog disabled
if (empty($conf->loghandlers['mod_syslog_file'])) { // File Syslog disabled
return 0;
}
if(! function_exists('gzopen')) {
if (!function_exists('gzopen')) {
$this->error = 'Support for gzopen not available in this PHP';
return -1;
}
@ -819,7 +819,7 @@ class Utils
$tabfiles = dol_dir_list(DOL_DATA_ROOT, 'files', 0, '^(dolibarr_.+|odt2pdf)\.log$'); // Also handle other log files like dolibarr_install.log
$tabfiles[] = array('name' => $mainlog, 'path' => $mainlogdir);
foreach($tabfiles as $file) {
foreach ($tabfiles as $file) {
$logname = $file['name'];
$logpath = $file['path'];
@ -832,7 +832,7 @@ class Utils
$gzfilestmp = dol_dir_list($logpath, 'files', 0, $filter);
$gzfiles = array();
foreach($gzfilestmp as $gzfile) {
foreach ($gzfilestmp as $gzfile) {
$tabmatches = array();
preg_match('/'.$filter.'/i', $gzfile['name'], $tabmatches);
@ -843,15 +843,15 @@ class Utils
krsort($gzfiles, SORT_NUMERIC);
foreach($gzfiles as $numsave => $dummy) {
if (dol_is_file($logpath.'/'.$logname.'.'.($numsave+1).'.gz')) {
foreach ($gzfiles as $numsave => $dummy) {
if (dol_is_file($logpath.'/'.$logname.'.'.($numsave + 1).'.gz')) {
return -2;
}
if($numsave >= $nbSaves) {
if ($numsave >= $nbSaves) {
dol_delete_file($logpath.'/'.$logname.'.'.$numsave.'.gz', 0, 0, 0, null, false, 0);
} else {
dol_move($logpath.'/'.$logname.'.'.$numsave.'.gz', $logpath.'/'.$logname.'.'.($numsave+1).'.gz', 0, 1, 0, 0);
dol_move($logpath.'/'.$logname.'.'.$numsave.'.gz', $logpath.'/'.$logname.'.'.($numsave + 1).'.gz', 0, 1, 0, 0);
}
}
@ -872,14 +872,14 @@ class Utils
return -4;
}
while(! feof($sourcehandle)) {
while (!feof($sourcehandle)) {
gzwrite($gzfilehandle, fread($sourcehandle, 512 * 1024)); // Read 512 kB at a time
}
fclose($sourcehandle);
gzclose($gzfilehandle);
@chmod($logpath.'/'.$logname.'.1.gz', octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK));
@chmod($logpath.'/'.$logname.'.1.gz', octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK));
}
dol_delete_file($logpath.'/'.$logname, 0, 0, 0, null, false, 0);
@ -889,7 +889,7 @@ class Utils
fclose($newlog);
//var_dump($logpath.'/'.$logname." - ".octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK));
@chmod($logpath.'/'.$logname, octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK));
@chmod($logpath.'/'.$logname, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK));
}
}
@ -927,7 +927,7 @@ class Utils
{
$tables = array();
$result = $db->query('SHOW FULL TABLES WHERE Table_type = \'BASE TABLE\'');
while($row = $db->fetch_row($result))
while ($row = $db->fetch_row($result))
{
$tables[] = $row[0];
}
@ -943,7 +943,7 @@ class Utils
{
$langs->load("errors");
dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
$errormsg=$langs->trans("ErrorFailedToWriteInDir");
$errormsg = $langs->trans("ErrorFailedToWriteInDir");
return -1;
}
@ -980,7 +980,7 @@ class Utils
if (GETPOST("nobin_delayed")) $delayed = 'DELAYED ';
// Process each table and print their definition + their datas
foreach($tables as $table)
foreach ($tables as $table)
{
// Saving the table structure
fwrite($handle, "\n--\n-- Table structure for table `".$table."`\n--\n");
@ -988,7 +988,7 @@ class Utils
if (GETPOST("nobin_drop")) fwrite($handle, "DROP TABLE IF EXISTS `".$table."`;\n"); // Dropping table if exists prior to re create it
fwrite($handle, "/*!40101 SET @saved_cs_client = @@character_set_client */;\n");
fwrite($handle, "/*!40101 SET character_set_client = utf8 */;\n");
$resqldrop=$db->query('SHOW CREATE TABLE '.$table);
$resqldrop = $db->query('SHOW CREATE TABLE '.$table);
$row2 = $db->fetch_row($resqldrop);
if (empty($row2[1]))
{
@ -1005,22 +1005,22 @@ class Utils
if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n");
else fwrite($handle, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n");
$sql='SELECT * FROM '.$table; // Here SELECT * is allowed because we don't have definition of columns to take
$sql = 'SELECT * FROM '.$table; // Here SELECT * is allowed because we don't have definition of columns to take
$result = $db->query($sql);
while($row = $db->fetch_row($result))
while ($row = $db->fetch_row($result))
{
// For each row of data we print a line of INSERT
fwrite($handle, 'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES (');
$columns = count($row);
for($j=0; $j<$columns; $j++) {
for ($j = 0; $j < $columns; $j++) {
// Processing each columns of the row to ensure that we correctly save the value (eg: add quotes for string - in fact we add quotes for everything, it's easier)
if ($row[$j] == null && !is_string($row[$j])) {
// IMPORTANT: if the field is NULL we set it NULL
$row[$j] = 'NULL';
} elseif(is_string($row[$j]) && $row[$j] == '') {
} elseif (is_string($row[$j]) && $row[$j] == '') {
// if it's an empty string, we set it as an empty string
$row[$j] = "''";
} elseif(is_numeric($row[$j]) && !strcmp($row[$j], $row[$j]+0) ) { // test if it's a numeric type and the numeric version ($nb+0) == string version (eg: if we have 01, it's probably not a number but rather a string, else it would not have any leading 0)
} elseif (is_numeric($row[$j]) && !strcmp($row[$j], $row[$j] + 0)) { // test if it's a numeric type and the numeric version ($nb+0) == string version (eg: if we have 01, it's probably not a number but rather a string, else it would not have any leading 0)
// if it's a number, we return it as-is
// $row[$j] = $row[$j];
} else { // else for all other cases we escape the value and put quotes around
@ -1057,10 +1057,10 @@ class Utils
/* Backup Procedure structure*/
// Write the footer (restore the previous database settings)
$sqlfooter="\n\n";
$sqlfooter = "\n\n";
if (GETPOST("nobin_use_transaction")) $sqlfooter .= "COMMIT;\n";
if (GETPOST("nobin_disable_fk")) $sqlfooter .= "SET FOREIGN_KEY_CHECKS=1;\n";
$sqlfooter.="\n\n-- Dump completed on ".date('Y-m-d G-i-s');
$sqlfooter .= "\n\n-- Dump completed on ".date('Y-m-d G-i-s');
fwrite($handle, $sqlfooter);
fclose($handle);

View File

@ -76,15 +76,15 @@ class ExportExcel2007new extends ModeleExports
global $conf, $langs;
$this->db = $db;
$this->id='excel2007new'; // Same value then xxx in file name export_xxx.modules.php
$this->label='Excel 2007'; // Label of driver
$this->id = 'excel2007new'; // Same value then xxx in file name export_xxx.modules.php
$this->label = 'Excel 2007'; // Label of driver
$this->desc = $langs->trans('Excel2007FormatDesc');
$this->extension='xlsx'; // Extension for generated file by this driver
$this->picto='mime/xls'; // Picto
$this->version='1.30'; // Driver version
$this->phpmin = array(5,6); // Minimum version of PHP required by module
$this->extension = 'xlsx'; // Extension for generated file by this driver
$this->picto = 'mime/xls'; // Picto
$this->version = '1.30'; // Driver version
$this->phpmin = array(5, 6); // Minimum version of PHP required by module
$this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
$this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)
if (empty($this->disabled))
{
@ -92,11 +92,11 @@ class ExportExcel2007new extends ModeleExports
//require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
//$this->label_lib='PhpExcel';
require_once PHPEXCELNEW_PATH.'Spreadsheet.php';
$this->label_lib='PhpSpreadSheet';
$this->version_lib='1.6.0'; // No way to get info from library
$this->label_lib = 'PhpSpreadSheet';
$this->version_lib = '1.6.0'; // No way to get info from library
}
$this->row=0;
$this->row = 0;
}
/**
@ -181,17 +181,17 @@ class ExportExcel2007new extends ModeleExports
public function open_file($file, $outputlangs)
{
// phpcs:enable
global $user,$conf,$langs;
global $user, $conf, $langs;
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
$outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
}
dol_syslog(get_class($this)."::open_file file=".$file);
$this->file=$file;
$this->file = $file;
$ret=1;
$ret = 1;
$outputlangs->load("exports");
@ -203,10 +203,10 @@ class ExportExcel2007new extends ModeleExports
if ($this->id == 'excel2007new')
{
if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
if (!class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
{
$langs->load("errors");
$this->error=$langs->trans('ErrorPHPNeedModule', 'zip');
$this->error = $langs->trans('ErrorPHPNeedModule', 'zip');
return -1;
}
}
@ -261,23 +261,23 @@ class ExportExcel2007new extends ModeleExports
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT);
$this->col=1;
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$this->col=0;
$this->col = 1;
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$this->col = 0;
}
foreach($array_selected_sorted as $code => $value)
foreach ($array_selected_sorted as $code => $value)
{
$alias=$array_export_fields_label[$code];
$alias = $array_export_fields_label[$code];
//print "dd".$alias;
if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
}
else
{
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
if (! empty($array_types[$code]) && in_array($array_types[$code], array('Date','Numeric','TextAuto'))) // Set autowidth for some types
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $outputlangs->transnoentities($alias));
if (!empty($array_types[$code]) && in_array($array_types[$code], array('Date', 'Numeric', 'TextAuto'))) // Set autowidth for some types
{
$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
}
@ -304,22 +304,22 @@ class ExportExcel2007new extends ModeleExports
global $conf;
// Define first row
$this->col=1;
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$this->col=0;
$this->col = 1;
if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
$this->col = 0;
}
$reg=array();
$reg = array();
foreach($array_selected_sorted as $code => $value)
foreach ($array_selected_sorted as $code => $value)
{
if (strpos($code, ' as ') == 0) $alias=str_replace(array('.','-','(',')'), '_', $code);
else $alias=substr($code, strpos($code, ' as ') + 4);
if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
else $alias = substr($code, strpos($code, ' as ') + 4);
if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
$newvalue=$objp->$alias;
$newvalue = $objp->$alias;
$newvalue=$this->excel_clean($newvalue);
$typefield=isset($array_types[$code])?$array_types[$code]:'';
$newvalue = $this->excel_clean($newvalue);
$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
{
@ -331,25 +331,25 @@ class ExportExcel2007new extends ModeleExports
// Traduction newvalue
if (preg_match('/^\((.*)\)$/i', $newvalue, $reg))
{
$newvalue=$outputlangs->transnoentities($reg[1]);
$newvalue = $outputlangs->transnoentities($reg[1]);
}
else
{
$newvalue=$outputlangs->convToOutputCharset($newvalue);
$newvalue = $outputlangs->convToOutputCharset($newvalue);
}
if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue))
{
$newvalue=dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue));
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
$newvalue = dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue));
$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
}
elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue))
{
$newvalue=dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue));
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
$newvalue = dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue));
$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
}
else
@ -357,14 +357,14 @@ class ExportExcel2007new extends ModeleExports
if ($typefield == 'Text' || $typefield == 'TextAuto')
{
//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, (string) $newvalue);
$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT);
}
else
{
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $newvalue);
}
}
$this->col++;
@ -419,7 +419,7 @@ class ExportExcel2007new extends ModeleExports
{
// phpcs:enable
// Rule Dolibarr: No HTML
$newvalue=dol_string_nohtmltag($newvalue);
$newvalue = dol_string_nohtmltag($newvalue);
return $newvalue;
}
@ -440,7 +440,7 @@ class ExportExcel2007new extends ModeleExports
while ($c != 0) {
$p = ($c - 1) % 26;
$c = intval(($c - $p) / 26);
$letter = chr(65 + $p) . $letter;
$letter = chr(65 + $p).$letter;
}
return $letter;

View File

@ -25,7 +25,7 @@
* \ingroup fiche intervention
* \brief File with Arctic numbering module for interventions
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/fichinter/modules_fichinter.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
/**
* Class to manage numbering of intervention cards with rule Artic.
@ -48,12 +48,12 @@ class mod_arctic extends ModeleNumRefFicheinter
* @deprecated
* @see name
*/
public $nom='arctic';
public $nom = 'arctic';
/**
* @var string model name
*/
public $name='arctic';
public $name = 'arctic';
/**
@ -70,28 +70,28 @@ class mod_arctic extends ModeleNumRefFicheinter
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconst" value="FICHINTER_ARTIC_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconst" value="FICHINTER_ARTIC_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
$tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard"));
$tooltip .= $langs->trans("GenericMaskCodes5");
// Setting the prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->FICHINTER_ARTIC_MASK.'">', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="'.$conf->global->FICHINTER_ARTIC_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -103,14 +103,14 @@ class mod_arctic extends ModeleNumRefFicheinter
*/
public function getExample()
{
global $conf,$langs,$mysoc;
global $conf, $langs, $mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$old_code_client = $mysoc->code_client;
$mysoc->code_client = 'CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc, '');
$mysoc->code_client=$old_code_client;
$mysoc->code_client = $old_code_client;
if (! $numExample)
if (!$numExample)
{
$numExample = $langs->trans('NotConfigured');
}
@ -126,20 +126,20 @@ class mod_arctic extends ModeleNumRefFicheinter
*/
public function getNextValue($objsoc = 0, $object = '')
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// We define the search criteria of the counter
$mask=$conf->global->FICHINTER_ARTIC_MASK;
$mask = $conf->global->FICHINTER_ARTIC_MASK;
if (! $mask)
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return 0;
}
$numFinal=get_next_value($db, $mask, 'fichinter', 'ref', '', $objsoc, $object->datec);
$numFinal = get_next_value($db, $mask, 'fichinter', 'ref', '', $objsoc, $object->datec);
return $numFinal;
}

View File

@ -23,7 +23,7 @@
* \ingroup emailcollector
* \brief Description and activation file for module emailcollector
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
@ -38,7 +38,7 @@ class modEmailCollector extends DolibarrModules
*/
public function __construct($db)
{
global $langs,$conf;
global $langs, $conf;
$this->db = $db;
@ -70,7 +70,7 @@ class modEmailCollector extends DolibarrModules
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto='email';
$this->picto = 'email';
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable)
@ -91,8 +91,8 @@ class modEmailCollector extends DolibarrModules
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("admin");
$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module
$this->phpmin = array(5, 4); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
@ -108,10 +108,10 @@ class modEmailCollector extends DolibarrModules
);
if (! isset($conf->emailcollector) || ! isset($conf->emailcollector->enabled))
if (!isset($conf->emailcollector) || !isset($conf->emailcollector->enabled))
{
$conf->emailcollector=new stdClass();
$conf->emailcollector->enabled=0;
$conf->emailcollector = new stdClass();
$conf->emailcollector->enabled = 0;
}
@ -145,7 +145,7 @@ class modEmailCollector extends DolibarrModules
// Dictionaries
$this->dictionaries=array();
$this->dictionaries = array();
/* Example:
$this->dictionaries=array(
'langs'=>'mylangfile@dav',
@ -206,7 +206,7 @@ class modEmailCollector extends DolibarrModules
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
$r = 0;
// Add here entries to declare new menus

View File

@ -45,7 +45,7 @@ class InterfaceNotification extends DolibarrTriggers
public $picto = 'email';
// @todo Defined also into notify.class.php)
public $listofmanagedevents=array(
public $listofmanagedevents = array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
@ -78,10 +78,10 @@ class InterfaceNotification extends DolibarrTriggers
{
if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
$notify = new Notify($this->db);
if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
if (!in_array($action, $notify->arrayofnotifsupported)) return 0;
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -100,42 +100,42 @@ class InterfaceNotification extends DolibarrTriggers
{
global $conf;
$ret=array();
$ret = array();
$sql = "SELECT rowid, code, label, description, elementtype";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
$sql.= $this->db->order("rang, elementtype, code");
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
$sql .= $this->db->order("rang, elementtype, code");
dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
$qualified=0;
$qualified = 0;
// Check is this event is supported by notification module
if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1;
if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1;
// Check if module for this event is active
if ($qualified)
{
//print 'xx'.$obj->code;
$element=$obj->elementtype;
$element = $obj->elementtype;
// Exclude events if related module is disabled
if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
elseif (! in_array($element, array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0;
elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0;
elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified = 0;
elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified = 0;
elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified = 0;
elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member', 'expensereport')) && empty($conf->$element->enabled)) $qualified = 0;
}
if ($qualified)
{
$ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
$ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype);
}
$i++;

View File

@ -26,11 +26,11 @@
* \brief Page to setup the donation module
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'donations', 'accountancy', 'other'));
@ -42,7 +42,7 @@ $value = GETPOST('value');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type='donation';
$type = 'donation';
/*
@ -51,13 +51,13 @@ $type='donation';
if ($action == 'specimen')
{
$modele=GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$don = new Don($db);
$don->initAsSpecimen();
// Search template files
$dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/";
$dir = DOL_DOCUMENT_ROOT."/core/modules/dons/";
$file = $modele.".modules.php";
if (file_exists($dir.$file))
{
@ -124,9 +124,9 @@ if ($action == 'set_DONATION_ACCOUNTINGACCOUNT')
$res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT", $account, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -142,9 +142,9 @@ if ($action == 'set_DONATION_MESSAGE')
$res = dolibarr_set_const($db, "DONATION_MESSAGE", $freemessage, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -159,7 +159,7 @@ if ($action == 'set_DONATION_MESSAGE')
*/
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
$code=$reg[1];
$code = $reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
@ -173,7 +173,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
{
$code=$reg[1];
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
@ -190,11 +190,11 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
*/
$dir = "../../core/modules/dons/";
$form=new Form($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
$form = new Form($db);
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
llxHeader('', $langs->trans("DonationsSetup"), 'DonConfiguration');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("DonationsSetup"), $linkback, 'title_setup');
$head = donation_admin_prepare_head();
@ -206,16 +206,16 @@ dol_fiche_head($head, 'general', $langs->trans("Donations"), -1, 'payment');
print load_fiche_titre($langs->trans("DonationsModels"), '', '');
// Defined the template definition table
$type='donation';
$type = 'donation';
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -240,19 +240,19 @@ print "</tr>\n";
clearstatcache();
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (preg_match('/\.modules\.php$/i', $file))
{
$name = substr($file, 0, dol_strlen($file) -12);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 0, dol_strlen($file) - 12);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module=new $classname($db);
$module = new $classname($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
@ -306,14 +306,14 @@ if (is_resource($handle))
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, -1, 0);
print '</td>';
@ -365,15 +365,15 @@ print "</tr>\n";
print '<tr class="oddeven">';
print '<td>';
$label = $langs->trans("AccountAccounting");
print '<label for="DONATION_ACCOUNTINGACCOUNT">' . $label . '</label></td>';
print '<label for="DONATION_ACCOUNTINGACCOUNT">'.$label.'</label></td>';
print '<td class="center">';
if (! empty($conf->accounting->enabled))
if (!empty($conf->accounting->enabled))
{
print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
}
else
{
print '<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="' . $conf->global->DONATION_ACCOUNTINGACCOUNT . '">';
print '<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="'.$conf->global->DONATION_ACCOUNTINGACCOUNT.'">';
}
print '</td><td class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
@ -409,7 +409,7 @@ if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print "</tr>\n";
print '<tr class="oddeven">';
print '<td width="80%">' . $langs->trans("DONATION_ART200") . '</td>';
print '<td width="80%">'.$langs->trans("DONATION_ART200").'</td>';
print '<td class="center">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('DONATION_ART200');
@ -420,7 +420,7 @@ if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print '</td></tr>';
print '<tr class="oddeven">';
print '<td width="80%">' . $langs->trans("DONATION_ART238") . '</td>';
print '<td width="80%">'.$langs->trans("DONATION_ART238").'</td>';
print '<td class="center">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('DONATION_ART238');
@ -431,7 +431,7 @@ if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print '</td></tr>';
print '<tr class="oddeven">';
print '<td width="80%">' . $langs->trans("DONATION_ART885") . '</td>';
print '<td width="80%">'.$langs->trans("DONATION_ART885").'</td>';
print '<td class="center">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('DONATION_ART885');

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ $langs->loadLangs(array('companies', 'bills', 'products', 'margins'));
$mesg = '';
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -43,16 +43,16 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield)
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield)
{
if ($agentid > 0)
$sortfield="s.nom";
$sortfield = "s.nom";
else
$sortfield="u.lastname";
$sortfield = "u.lastname";
}
$startdate=$enddate='';
$startdate = $enddate = '';
$startdateday = GETPOST('startdateday', 'int');
$startdatemonth = GETPOST('startdatemonth', 'int');
@ -72,7 +72,7 @@ if ($user->rights->margins->read->all) {
} else {
$agentid = $user->id;
}
$result=restrictedArea($user, 'margins');
$result = restrictedArea($user, 'margins');
/*
@ -89,19 +89,19 @@ $result=restrictedArea($user, 'margins');
$userstatic = new User($db);
$companystatic = new Societe($db);
$invoicestatic=new Facture($db);
$invoicestatic = new Facture($db);
$form = new Form($db);
llxHeader('', $langs->trans("Margins").' - '.$langs->trans("Agents"));
$text=$langs->trans("Margins");
$text = $langs->trans("Margins");
//print load_fiche_titre($text);
// Show tabs
$head=marges_prepare_head($user);
$titre=$langs->trans("Margins");
$picto='margin';
$head = marges_prepare_head($user);
$titre = $langs->trans("Margins");
$picto = 'margin';
print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
@ -135,45 +135,45 @@ print '</form>';
$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
$sql = "SELECT";
$sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
$sql.= " u.rowid as agent, u.login, u.lastname, u.firstname,";
$sql.= " sum(d.total_ht) as selling_price,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
$sql .= " u.rowid as agent, u.login, u.lastname, u.firstname,";
$sql .= " sum(d.total_ht) as selling_price,";
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
$sql.= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
$sql.= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge" ;
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE);
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
$sql.= " AND sc.fk_soc = f.fk_soc";
$sql.= " AND (d.product_type = 0 OR d.product_type = 1)";
if (! empty($conf->global->AGENT_CONTACT_TYPE))
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
$sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
$sql .= " sum(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE) ?-1 : $conf->global->AGENT_CONTACT_TYPE);
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ", ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
$sql .= " AND sc.fk_soc = f.fk_soc";
$sql .= " AND (d.product_type = 0 OR d.product_type = 1)";
if (!empty($conf->global->AGENT_CONTACT_TYPE))
$sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
else
$sql .= " AND sc.fk_user = u.rowid";
$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
$sql.= ' AND s.entity IN ('.getEntity('societe').')';
$sql.= " AND d.fk_facture = f.rowid";
$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
$sql .= ' AND s.entity IN ('.getEntity('societe').')';
$sql .= " AND d.fk_facture = f.rowid";
if ($agentid > 0) {
if (! empty($conf->global->AGENT_CONTACT_TYPE))
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
if (!empty($conf->global->AGENT_CONTACT_TYPE))
$sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
else
$sql .= " AND sc.fk_user = ".$agentid;
}
if (!empty($startdate))
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
$sql .= " AND f.datef >= '".$db->idate($startdate)."'";
if (!empty($enddate))
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND d.buy_price_ht IS NOT NULL";
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0";
//if ($agentid > 0) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
//else $sql.= " GROUP BY u.rowid, u.login, u.lastname, u.firstname";
$sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
$sql.=$db->order($sortfield, $sortorder);
$sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
$sql .= $db->order($sortfield, $sortorder);
// TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
@ -181,7 +181,7 @@ $sql.=$db->order($sortfield, $sortorder);
print '<br>';
print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").'<br>';
$param='';
$param = '';
if (!empty($agentid)) $param .= "&amp;agentid=".urlencode($agentid);
if (!empty($startdateday)) $param .= "&amp;startdateday=".urlencode($startdateday);
if (!empty($startdatemonth)) $param .= "&amp;startdatemonth=".urlencode($startdatemonth);
@ -201,9 +201,9 @@ if ($result)
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
if ($conf->global->MARGIN_TYPE == "1")
$labelcostprice='BuyingPrice';
$labelcostprice = 'BuyingPrice';
else // value is 'costprice' or 'pmp'
$labelcostprice='CostPrice';
$labelcostprice = 'CostPrice';
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
@ -217,9 +217,9 @@ if ($result)
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($conf->global->DISPLAY_MARK_RATES))
if (!empty($conf->global->DISPLAY_MARK_RATES))
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
print "</tr>\n";
@ -252,8 +252,8 @@ if ($result)
if ($objp->socid > 0) {
// sql nb sellers
$sql_seller = "SELECT COUNT(sc.rowid) as nb";
$sql_seller .= " FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
$sql_seller .= " WHERE sc.fk_soc = " . $objp->socid;
$sql_seller .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql_seller .= " WHERE sc.fk_soc = ".$objp->socid;
$sql_seller .= " LIMIT 1";
$resql_seller = $db->query($sql_seller);
@ -284,18 +284,18 @@ if ($result)
$pv = $group_array['selling_price'];
$marge = $group_array['marge'];
$marginRate = ($pa != 0)?(100 * $marge / $pa):'';
$markRate = ($pv != 0)?(100 * $marge / $pv):'';
$marginRate = ($pa != 0) ? (100 * $marge / $pa) : '';
$markRate = ($pv != 0) ? (100 * $marge / $pv) : '';
print '<tr class="oddeven">';
print "<td>".$group_array['htmlname']."</td>\n";
print "<td class=\"right\">".price(price2num($pv, 'MT'))."</td>\n";
print "<td class=\"right\">".price(price2num($pa, 'MT'))."</td>\n";
print "<td class=\"right\">".price(price2num($marge, 'MT'))."</td>\n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '')?'n/a':price(price2num($marginRate, 'MT'))."%")."</td>\n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '')?'n/a':price(price2num($markRate, 'MT'))."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n";
print "</tr>\n";
}
}

View File

@ -373,12 +373,12 @@ else
// Warehouse card
$linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref.='</div>';
$morehtmlref = '<div class="refidno">';
$morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref .= '</div>';
$shownav = 1;
if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref);
@ -390,7 +390,7 @@ else
// Parent entrepot
$parentwarehouse = new Entrepot($db);
if(!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
if (!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) {
print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>';
print $parentwarehouse->getNomUrl(3);
print '</td></tr>';
@ -430,8 +430,8 @@ else
// Last movement
if (!empty($user->rights->stock->mouvement->lire)) {
$sql = "SELECT max(m.datem) as datem";
$sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m";
$sql .= " WHERE m.fk_entrepot = '" . $object->id . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
$sql .= " WHERE m.fk_entrepot = '".$object->id."'";
$resqlbis = $db->query($sql);
if ($resqlbis) {
$obj = $db->fetch_object($resqlbis);
@ -439,10 +439,10 @@ else
} else {
dol_print_error($db);
}
print '<tr><td>' . $langs->trans("LastMovement") . '</td><td>';
print '<tr><td>'.$langs->trans("LastMovement").'</td><td>';
if ($lastmovementdate) {
print dol_print_date($lastmovementdate, 'dayhour') . ' ';
print '(<a href="' . DOL_URL_ROOT . '/product/stock/movement_list.php?id=' . $object->id . '">' . $langs->trans("FullList") . '</a>)';
print dol_print_date($lastmovementdate, 'dayhour').' ';
print '(<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id.'">'.$langs->trans("FullList").'</a>)';
} else {
print $langs->trans("None");
}

View File

@ -34,14 +34,14 @@ $ref = GETPOST('ref', 'alpha');
// Security check
//$result=restrictedArea($user,'stock', $id, 'entrepot&stock');
$result=restrictedArea($user, 'stock');
$result = restrictedArea($user, 'stock');
/*
* View
*/
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
llxHeader("", $langs->trans("Stocks"), $help_url);
$object = new Entrepot($db);
@ -55,12 +55,12 @@ dol_fiche_head($head, 'info', $langs->trans("Warehouse"), -1, 'stock');
$linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref.='</div>';
$morehtmlref = '<div class="refidno">';
$morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref .= '</div>';
$shownav = 1;
if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref);

View File

@ -195,14 +195,14 @@ if ($action == "correct_stock")
if ($product->hasbatch())
{
$batch=GETPOST('batch_number');
$batch = GETPOST('batch_number');
//$eatby=GETPOST('eatby');
//$sellby=GETPOST('sellby');
$eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
$sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
$eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
$sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
$result=$product->correct_stock_batch(
$result = $product->correct_stock_batch(
$user,
$id,
GETPOST("nbpiece", 'int'),
@ -217,7 +217,7 @@ if ($action == "correct_stock")
}
else
{
$result=$product->correct_stock(
$result = $product->correct_stock(
$user,
$id,
GETPOST("nbpiece", 'int'),
@ -414,63 +414,63 @@ if ($action == "transfert_stock" && !$cancel)
* View
*/
$productlot=new ProductLot($db);
$productstatic=new Product($db);
$warehousestatic=new Entrepot($db);
$movement=new MouvementStock($db);
$userstatic=new User($db);
$form=new Form($db);
$formother=new FormOther($db);
$formproduct=new FormProduct($db);
if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db);
$productlot = new ProductLot($db);
$productstatic = new Product($db);
$warehousestatic = new Entrepot($db);
$movement = new MouvementStock($db);
$userstatic = new User($db);
$form = new Form($db);
$formother = new FormOther($db);
$formproduct = new FormProduct($db);
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
$sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,";
$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
$sql.= " m.batch, m.price,";
$sql.= " m.type_mouvement,";
$sql.= " m.fk_projet as fk_project,";
$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
$sql.= " u.login, u.photo, u.lastname, u.firstname";
$sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,";
$sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
$sql .= " m.batch, m.price,";
$sql .= " m.type_mouvement,";
$sql .= " m.fk_projet as fk_project,";
$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
$sql .= " u.login, u.photo, u.lastname, u.firstname";
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql.= " ".MAIN_DB_PREFIX."product as p,";
$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
$sql.= " WHERE m.fk_product = p.rowid";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql .= " ".MAIN_DB_PREFIX."product as p,";
$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
$sql .= " WHERE m.fk_product = p.rowid";
if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
$sql.= " AND m.fk_entrepot = e.rowid";
$sql.= " AND e.entity IN (".getEntity('stock').")";
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
$sql.= dolSqlDateFilter('m.datem', 0, $month, $year);
if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1);
if (! empty($search_movement)) $sql.= natural_search('m.label', $search_movement);
if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode);
if (! empty($search_product_ref)) $sql.= natural_search('p.ref', $search_product_ref);
if (! empty($search_product)) $sql.= natural_search('p.label', $search_product);
if ($search_warehouse != '' && $search_warehouse != '-1') $sql.= natural_search('e.rowid', $search_warehouse, 2);
if (! empty($search_user)) $sql.= natural_search('u.login', $search_user);
if (! empty($search_batch)) $sql.= natural_search('m.batch', $search_batch);
if ($search_qty != '') $sql.= natural_search('m.value', $search_qty, 1);
if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natural_search('m.type_mouvement', $search_type_mouvement, 2);
$sql .= " AND m.fk_entrepot = e.rowid";
$sql .= " AND e.entity IN (".getEntity('stock').")";
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
if ($id > 0) $sql .= " AND e.rowid ='".$id."'";
$sql .= dolSqlDateFilter('m.datem', 0, $month, $year);
if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'";
if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1);
if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement);
if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref);
if (!empty($search_product)) $sql .= natural_search('p.label', $search_product);
if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2);
if (!empty($search_user)) $sql .= natural_search('u.login', $search_user);
if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch);
if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1);
if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= $db->order($sortfield, $sortorder);
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@ -544,12 +544,12 @@ if ($resql)
$linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref.='</div>';
$morehtmlref = '<div class="refidno">';
$morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref .= '</div>';
$shownav = 1;
if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref);
@ -947,53 +947,53 @@ if ($resql)
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['m.datec']['checked'])) {
if (!empty($arrayfields['m.datec']['checked'])) {
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (! empty($arrayfields['m.tms']['checked'])) {
if (!empty($arrayfields['m.tms']['checked'])) {
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$arrayofuniqueproduct=array();
$arrayofuniqueproduct = array();
while ($i < min($num, $limit))
{
$objp = $db->fetch_object($resql);
$userstatic->id=$objp->fk_user_author;
$userstatic->login=$objp->login;
$userstatic->lastname=$objp->lastname;
$userstatic->firstname=$objp->firstname;
$userstatic->photo=$objp->photo;
$userstatic->id = $objp->fk_user_author;
$userstatic->login = $objp->login;
$userstatic->lastname = $objp->lastname;
$userstatic->firstname = $objp->firstname;
$userstatic->photo = $objp->photo;
$productstatic->id=$objp->rowid;
$productstatic->ref=$objp->product_ref;
$productstatic->label=$objp->produit;
$productstatic->type=$objp->type;
$productstatic->entity=$objp->entity;
$productstatic->status_batch=$objp->tobatch;
$productstatic->id = $objp->rowid;
$productstatic->ref = $objp->product_ref;
$productstatic->label = $objp->produit;
$productstatic->type = $objp->type;
$productstatic->entity = $objp->entity;
$productstatic->status_batch = $objp->tobatch;
$productlot->id = $objp->lotid;
$productlot->batch= $objp->batch;
$productlot->eatby= $objp->eatby;
$productlot->sellby= $objp->sellby;
$productlot->batch = $objp->batch;
$productlot->eatby = $objp->eatby;
$productlot->sellby = $objp->sellby;
$warehousestatic->id=$objp->entrepot_id;
$warehousestatic->ref=$objp->warehouse_ref;
$warehousestatic->libelle=$objp->warehouse_ref; // deprecated
$warehousestatic->label=$objp->warehouse_ref;
$warehousestatic->lieu=$objp->lieu;
$warehousestatic->id = $objp->entrepot_id;
$warehousestatic->ref = $objp->warehouse_ref;
$warehousestatic->libelle = $objp->warehouse_ref; // deprecated
$warehousestatic->label = $objp->warehouse_ref;
$warehousestatic->lieu = $objp->lieu;
$warehousestatic->fk_parent = $objp->fk_parent;
$warehousestatic->statut = $objp->statut;
$arrayofuniqueproduct[$objp->rowid]=$objp->produit;
if(!empty($objp->fk_origin)) {
$arrayofuniqueproduct[$objp->rowid] = $objp->produit;
if (!empty($objp->fk_origin)) {
$origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
} else {
$origin = '';

View File

@ -42,17 +42,17 @@ $langs->load('stocks');
$langs->load('other');
$langs->load('propal');
$id=(GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('facid', 'int')); // For backward compatibility
$ref=GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
$socid='';
if ($user->socid) $socid=$user->socid;
$result=restrictedArea($user, $origin, $origin_id);
$socid = '';
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, $origin, $origin_id);
$object = new Reception($db);
if ($id > 0 || ! empty($ref))
if ($id > 0 || !empty($ref))
{
$object->fetch($id, $ref);
$object->fetch_thirdparty();
@ -95,48 +95,48 @@ llxHeader('', 'Reception');
$form = new Form($db);
if ($id > 0 || ! empty($ref))
if ($id > 0 || !empty($ref))
{
$head=reception_prepare_head($object);
$head = reception_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'sending');
// Reception card
$linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref = '<div class="refidno">';
// Ref customer reception
$morehtmlref.=$form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1);
$morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled)) {
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if (0) { // Do not change on reception
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
}
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
// We don't have project on reception, so we will use the project or source object instead
// TODO Add project on reception
$morehtmlref .= ' : ';
if (! empty($objectsrc->fk_project)) {
if (!empty($objectsrc->fk_project)) {
$proj = new Project($db);
$proj->fetch($objectsrc->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objectsrc->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {

View File

@ -673,7 +673,7 @@ class Societe extends CommonObject
if (empty($this->status)) $this->status = 0;
$this->name = $this->name ?trim($this->name) : trim($this->nom);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name=strtoupper($this->name);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = strtoupper($this->name);
$this->nom = $this->name; // For backward compatibility
if (empty($this->client)) $this->client = 0;
if (empty($this->fournisseur)) $this->fournisseur = 0;
@ -990,7 +990,7 @@ class Societe extends CommonObject
$now = dol_now();
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name);
if (! empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name=strtoupper($this->name);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = strtoupper($this->name);
// Clean parameters
$this->id = $id;
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);

View File

@ -278,76 +278,76 @@ class User extends CommonObject
global $conf, $user;
// Clean parameters
$login=trim($login);
$login = trim($login);
// Get user
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.personal_email, u.job,";
$sql.= " u.socialnetworks,";
$sql.= " u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,";
$sql.= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,";
$sql.= " u.admin, u.login, u.note as note_private, u.note_public,";
$sql.= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,";
$sql.= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid, u.fk_user_expense_validator, u.fk_user_holiday_validator,";
$sql.= " u.statut, u.lang, u.entity,";
$sql.= " u.datec as datec,";
$sql.= " u.tms as datem,";
$sql.= " u.datelastlogin as datel,";
$sql.= " u.datepreviouslogin as datep,";
$sql.= " u.photo as photo,";
$sql.= " u.openid as openid,";
$sql.= " u.accountancy_code,";
$sql.= " u.thm,";
$sql.= " u.tjm,";
$sql.= " u.salary,";
$sql.= " u.salaryextra,";
$sql.= " u.weeklyhours,";
$sql.= " u.color,";
$sql.= " u.dateemployment, u.dateemploymentend,";
$sql.= " u.fk_warehouse,";
$sql.= " u.ref_int, u.ref_ext,";
$sql.= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode
$sql.= " c.code as country_code, c.label as country,";
$sql.= " d.code_departement as state_code, d.nom as state";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON u.fk_state = d.rowid";
$sql .= " u.socialnetworks,";
$sql .= " u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,";
$sql .= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,";
$sql .= " u.admin, u.login, u.note as note_private, u.note_public,";
$sql .= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,";
$sql .= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid, u.fk_user_expense_validator, u.fk_user_holiday_validator,";
$sql .= " u.statut, u.lang, u.entity,";
$sql .= " u.datec as datec,";
$sql .= " u.tms as datem,";
$sql .= " u.datelastlogin as datel,";
$sql .= " u.datepreviouslogin as datep,";
$sql .= " u.photo as photo,";
$sql .= " u.openid as openid,";
$sql .= " u.accountancy_code,";
$sql .= " u.thm,";
$sql .= " u.tjm,";
$sql .= " u.salary,";
$sql .= " u.salaryextra,";
$sql .= " u.weeklyhours,";
$sql .= " u.color,";
$sql .= " u.dateemployment, u.dateemploymentend,";
$sql .= " u.fk_warehouse,";
$sql .= " u.ref_int, u.ref_ext,";
$sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode
$sql .= " c.code as country_code, c.label as country,";
$sql .= " d.code_departement as state_code, d.nom as state";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON u.fk_state = d.rowid";
if ($entity < 0)
{
if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (! empty($user->entity)))
if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (!empty($user->entity)))
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql .= " WHERE u.entity IN (0,".$conf->entity.")";
}
else
{
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
}
}
else // The fetch was forced on an entity
{
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
else
$sql.= " WHERE u.entity IN (0, ".(($entity!='' && $entity >= 0)?$entity:$conf->entity).")"; // search in entity provided in parameter
$sql .= " WHERE u.entity IN (0, ".(($entity != '' && $entity >= 0) ? $entity : $conf->entity).")"; // search in entity provided in parameter
}
if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba
{
$sql.= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1";
$sql .= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1";
}
elseif ($login)
{
$sql.= " AND u.login = '".$this->db->escape($login)."'";
$sql .= " AND u.login = '".$this->db->escape($login)."'";
}
elseif ($email)
{
$sql.= " AND u.email = '".$this->db->escape($email)."'";
$sql .= " AND u.email = '".$this->db->escape($email)."'";
}
else
{
$sql.= " AND u.rowid = ".$id;
$sql .= " AND u.rowid = ".$id;
}
$sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
$sql .= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
$result = $this->db->query($sql);
if ($result)
@ -1177,9 +1177,9 @@ class User extends CommonObject
// Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname=strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname);
$this->login = trim($this->login);
if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value
@ -1334,28 +1334,28 @@ class User extends CommonObject
$this->country_id = $contact->country_id;
$this->employee = 0;
if (empty($login)) $login=strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4));
if (empty($login)) $login = strtolower(substr($contact->firstname, 0, 4)).strtolower(substr($contact->lastname, 0, 4));
$this->login = $login;
$this->db->begin();
// Create user and set $this->id. Trigger is disabled because executed later.
$result=$this->create($user, 1);
$result = $this->create($user, 1);
if ($result > 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET fk_socpeople=".$contact->id;
if ($contact->socid) $sql.=", fk_soc=".$contact->socid;
$sql.= " WHERE rowid=".$this->id;
$resql=$this->db->query($sql);
$sql .= " SET fk_socpeople=".$contact->id;
if ($contact->socid) $sql .= ", fk_soc=".$contact->socid;
$sql .= " WHERE rowid=".$this->id;
$resql = $this->db->query($sql);
dol_syslog(get_class($this)."::create_from_contact", LOG_DEBUG);
if ($resql)
{
$this->context['createfromcontact']='createfromcontact';
$this->context['createfromcontact'] = 'createfromcontact';
// Call trigger
$result=$this->call_trigger('USER_CREATE', $user);
$result = $this->call_trigger('USER_CREATE', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
@ -1520,9 +1520,9 @@ class User extends CommonObject
// Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname=strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname);
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname);
$this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname);
@ -1548,19 +1548,19 @@ class User extends CommonObject
$this->signature = trim($this->signature);
$this->note_public = trim($this->note_public);
$this->note_private = trim($this->note_private);
$this->openid = trim(empty($this->openid)?'':$this->openid); // Avoid warning
$this->admin = $this->admin?$this->admin:0;
$this->address = empty($this->address)?'':$this->address;
$this->zip = empty($this->zip)?'':$this->zip;
$this->town = empty($this->town)?'':$this->town;
$this->openid = trim(empty($this->openid) ? '' : $this->openid); // Avoid warning
$this->admin = $this->admin ? $this->admin : 0;
$this->address = empty($this->address) ? '' : $this->address;
$this->zip = empty($this->zip) ? '' : $this->zip;
$this->town = empty($this->town) ? '' : $this->town;
$this->accountancy_code = trim($this->accountancy_code);
$this->color = empty($this->color)?'':$this->color;
$this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment;
$this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend;
$this->fk_warehouse = trim(empty($this->fk_warehouse)?'':$this->fk_warehouse);
$this->color = empty($this->color) ? '' : $this->color;
$this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment;
$this->dateemploymentend = empty($this->dateemploymentend) ? '' : $this->dateemploymentend;
$this->fk_warehouse = trim(empty($this->fk_warehouse) ? '' : $this->fk_warehouse);
// Check parameters
if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email))
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email))
{
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
@ -1577,56 +1577,56 @@ class User extends CommonObject
// Update datas
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
$sql.= " lastname = '".$this->db->escape($this->lastname)."'";
$sql.= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql.= ", employee = ".(int) $this->employee;
$sql.= ", login = '".$this->db->escape($this->login)."'";
$sql.= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");
$sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
$sql.= ", birth=".(strval($this->birth)!='' ? "'".$this->db->idate($this->birth)."'" : 'null');
if (! empty($user->admin)) $sql.= ", admin = ".(int) $this->admin; // admin flag can be set/unset only by an admin user
$sql.= ", address = '".$this->db->escape($this->address)."'";
$sql.= ", zip = '".$this->db->escape($this->zip)."'";
$sql.= ", town = '".$this->db->escape($this->town)."'";
$sql.= ", fk_state = ".((! empty($this->state_id) && $this->state_id > 0)?"'".$this->db->escape($this->state_id)."'":"null");
$sql.= ", fk_country = ".((! empty($this->country_id) && $this->country_id > 0)?"'".$this->db->escape($this->country_id)."'":"null");
$sql.= ", office_phone = '".$this->db->escape($this->office_phone)."'";
$sql.= ", office_fax = '".$this->db->escape($this->office_fax)."'";
$sql.= ", user_mobile = '".$this->db->escape($this->user_mobile)."'";
$sql.= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'";
$sql.= ", email = '".$this->db->escape($this->email)."'";
$sql.= ", personal_email = '".$this->db->escape($this->personal_email)."'";
$sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'";
$sql.= ", job = '".$this->db->escape($this->job)."'";
$sql.= ", signature = '".$this->db->escape($this->signature)."'";
$sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'";
$sql.= ", color = '".$this->db->escape($this->color)."'";
$sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null');
$sql.= ", dateemploymentend=".(strval($this->dateemploymentend)!='' ? "'".$this->db->idate($this->dateemploymentend)."'" : 'null');
$sql.= ", note = '".$this->db->escape($this->note_private)."'";
$sql.= ", note_public = '".$this->db->escape($this->note_public)."'";
$sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
$sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null");
$sql.= ", fk_user = ".($this->fk_user > 0?"'".$this->db->escape($this->fk_user)."'":"null");
$sql.= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0?"'".$this->db->escape($this->fk_user_expense_validator)."'":"null");
$sql.= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0?"'".$this->db->escape($this->fk_user_holiday_validator)."'":"null");
if (isset($this->thm) || $this->thm != '') $sql.= ", thm= ".($this->thm != ''?"'".$this->db->escape($this->thm)."'":"null");
if (isset($this->tjm) || $this->tjm != '') $sql.= ", tjm= ".($this->tjm != ''?"'".$this->db->escape($this->tjm)."'":"null");
if (isset($this->salary) || $this->salary != '') $sql.= ", salary= ".($this->salary != ''?"'".$this->db->escape($this->salary)."'":"null");
if (isset($this->salaryextra) || $this->salaryextra != '') $sql.= ", salaryextra= ".($this->salaryextra != ''?"'".$this->db->escape($this->salaryextra)."'":"null");
$sql.= ", weeklyhours= ".($this->weeklyhours != ''?"'".$this->db->escape($this->weeklyhours)."'":"null");
$sql.= ", entity = '".$this->db->escape($this->entity)."'";
$sql.= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null');
$sql.= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
$sql.= ", fk_warehouse = ".($this->fk_warehouse?"'".$this->db->escape($this->fk_warehouse)."'":"null");
$sql .= " lastname = '".$this->db->escape($this->lastname)."'";
$sql .= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql .= ", employee = ".(int) $this->employee;
$sql .= ", login = '".$this->db->escape($this->login)."'";
$sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");
$sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
$sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth)."'" : 'null');
if (!empty($user->admin)) $sql .= ", admin = ".(int) $this->admin; // admin flag can be set/unset only by an admin user
$sql .= ", address = '".$this->db->escape($this->address)."'";
$sql .= ", zip = '".$this->db->escape($this->zip)."'";
$sql .= ", town = '".$this->db->escape($this->town)."'";
$sql .= ", fk_state = ".((!empty($this->state_id) && $this->state_id > 0) ? "'".$this->db->escape($this->state_id)."'" : "null");
$sql .= ", fk_country = ".((!empty($this->country_id) && $this->country_id > 0) ? "'".$this->db->escape($this->country_id)."'" : "null");
$sql .= ", office_phone = '".$this->db->escape($this->office_phone)."'";
$sql .= ", office_fax = '".$this->db->escape($this->office_fax)."'";
$sql .= ", user_mobile = '".$this->db->escape($this->user_mobile)."'";
$sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'";
$sql .= ", email = '".$this->db->escape($this->email)."'";
$sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'";
$sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'";
$sql .= ", job = '".$this->db->escape($this->job)."'";
$sql .= ", signature = '".$this->db->escape($this->signature)."'";
$sql .= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'";
$sql .= ", color = '".$this->db->escape($this->color)."'";
$sql .= ", dateemployment=".(strval($this->dateemployment) != '' ? "'".$this->db->idate($this->dateemployment)."'" : 'null');
$sql .= ", dateemploymentend=".(strval($this->dateemploymentend) != '' ? "'".$this->db->idate($this->dateemploymentend)."'" : 'null');
$sql .= ", note = '".$this->db->escape($this->note_private)."'";
$sql .= ", note_public = '".$this->db->escape($this->note_public)."'";
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
$sql .= ", openid = ".($this->openid ? "'".$this->db->escape($this->openid)."'" : "null");
$sql .= ", fk_user = ".($this->fk_user > 0 ? "'".$this->db->escape($this->fk_user)."'" : "null");
$sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null");
$sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null");
if (isset($this->thm) || $this->thm != '') $sql .= ", thm= ".($this->thm != '' ? "'".$this->db->escape($this->thm)."'" : "null");
if (isset($this->tjm) || $this->tjm != '') $sql .= ", tjm= ".($this->tjm != '' ? "'".$this->db->escape($this->tjm)."'" : "null");
if (isset($this->salary) || $this->salary != '') $sql .= ", salary= ".($this->salary != '' ? "'".$this->db->escape($this->salary)."'" : "null");
if (isset($this->salaryextra) || $this->salaryextra != '') $sql .= ", salaryextra= ".($this->salaryextra != '' ? "'".$this->db->escape($this->salaryextra)."'" : "null");
$sql .= ", weeklyhours= ".($this->weeklyhours != '' ? "'".$this->db->escape($this->weeklyhours)."'" : "null");
$sql .= ", entity = '".$this->db->escape($this->entity)."'";
$sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null');
$sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
$sql .= ", fk_warehouse = ".($this->fk_warehouse ? "'".$this->db->escape($this->fk_warehouse)."'" : "null");
$sql.= " WHERE rowid = ".$this->id;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$nbrowsaffected+=$this->db->affected_rows($resql);
$nbrowsaffected += $this->db->affected_rows($resql);
// Update password
if (!empty($this->pass))
@ -1663,55 +1663,55 @@ class User extends CommonObject
// This user is linked with a member, so we also update member information
// if this is an update.
$adh=new Adherent($this->db);
$result=$adh->fetch($this->fk_member);
$adh = new Adherent($this->db);
$result = $adh->fetch($this->fk_member);
if ($result > 0)
{
$adh->firstname=$this->firstname;
$adh->lastname=$this->lastname;
$adh->login=$this->login;
$adh->gender=$this->gender;
$adh->birth=$this->birth;
$adh->firstname = $this->firstname;
$adh->lastname = $this->lastname;
$adh->login = $this->login;
$adh->gender = $this->gender;
$adh->birth = $this->birth;
$adh->pass=$this->pass;
$adh->pass = $this->pass;
$adh->societe=(empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
$adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
$adh->address=$this->address;
$adh->town=$this->town;
$adh->zip=$this->zip;
$adh->state_id=$this->state_id;
$adh->country_id=$this->country_id;
$adh->address = $this->address;
$adh->town = $this->town;
$adh->zip = $this->zip;
$adh->state_id = $this->state_id;
$adh->country_id = $this->country_id;
$adh->email=$this->email;
$adh->email = $this->email;
$adh->socialnetworks=$this->socialnetworks;
$adh->socialnetworks = $this->socialnetworks;
$adh->phone=$this->office_phone;
$adh->phone_mobile=$this->user_mobile;
$adh->phone = $this->office_phone;
$adh->phone_mobile = $this->user_mobile;
$adh->user_id=$this->id;
$adh->user_login=$this->login;
$adh->user_id = $this->id;
$adh->user_login = $this->login;
$result=$adh->update($user, 0, 1, 0);
$result = $adh->update($user, 0, 1, 0);
if ($result < 0)
{
$this->error=$adh->error;
$this->errors=$adh->errors;
$this->error = $adh->error;
$this->errors = $adh->errors;
dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
$error++;
}
}
elseif ($result < 0)
{
$this->error=$adh->error;
$this->errors=$adh->errors;
$this->error = $adh->error;
$this->errors = $adh->errors;
$error++;
}
}
if ($this->contact_id > 0 && ! $nosynccontact)
if ($this->contact_id > 0 && !$nosynccontact)
{
dol_syslog(get_class($this)."::update user is linked with a contact. We try to update contact too.", LOG_DEBUG);
@ -1719,77 +1719,77 @@ class User extends CommonObject
// This user is linked with a contact, so we also update contact information
// if this is an update.
$tmpobj=new Contact($this->db);
$result=$tmpobj->fetch($this->contact_id);
$tmpobj = new Contact($this->db);
$result = $tmpobj->fetch($this->contact_id);
if ($result >= 0)
{
$tmpobj->firstname=$this->firstname;
$tmpobj->lastname=$this->lastname;
$tmpobj->login=$this->login;
$tmpobj->gender=$this->gender;
$tmpobj->birth=$this->birth;
$tmpobj->firstname = $this->firstname;
$tmpobj->lastname = $this->lastname;
$tmpobj->login = $this->login;
$tmpobj->gender = $this->gender;
$tmpobj->birth = $this->birth;
//$tmpobj->pass=$this->pass;
//$tmpobj->societe=(empty($tmpobj->societe) && $this->societe_id ? $this->societe_id : $tmpobj->societe);
$tmpobj->email=$this->email;
$tmpobj->email = $this->email;
$tmpobj->socialnetworks=$this->socialnetworks;
$tmpobj->socialnetworks = $this->socialnetworks;
$tmpobj->phone_pro=$this->office_phone;
$tmpobj->phone_mobile=$this->user_mobile;
$tmpobj->fax=$this->office_fax;
$tmpobj->phone_pro = $this->office_phone;
$tmpobj->phone_mobile = $this->user_mobile;
$tmpobj->fax = $this->office_fax;
$tmpobj->address=$this->address;
$tmpobj->town=$this->town;
$tmpobj->zip=$this->zip;
$tmpobj->state_id=$this->state_id;
$tmpobj->country_id=$this->country_id;
$tmpobj->address = $this->address;
$tmpobj->town = $this->town;
$tmpobj->zip = $this->zip;
$tmpobj->state_id = $this->state_id;
$tmpobj->country_id = $this->country_id;
$tmpobj->user_id=$this->id;
$tmpobj->user_login=$this->login;
$tmpobj->user_id = $this->id;
$tmpobj->user_login = $this->login;
$result=$tmpobj->update($tmpobj->id, $user, 0, 'update', 1);
$result = $tmpobj->update($tmpobj->id, $user, 0, 'update', 1);
if ($result < 0)
{
$this->error=$tmpobj->error;
$this->errors=$tmpobj->errors;
$this->error = $tmpobj->error;
$this->errors = $tmpobj->errors;
dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
$error++;
}
}
else
{
$this->error=$tmpobj->error;
$this->errors=$tmpobj->errors;
$this->error = $tmpobj->error;
$this->errors = $tmpobj->errors;
$error++;
}
}
}
$action='update';
$action = 'update';
// Actions on extra fields
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
if (!$error && !$notrigger)
{
// Call trigger
$result=$this->call_trigger('USER_MODIFY', $user);
$result = $this->call_trigger('USER_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return $nbrowsaffected;
@ -2332,60 +2332,60 @@ class User extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if(!$user->rights->user->user->lire && $user->id !=$this->id) $option='nolink';
if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0;
$result=''; $label='';
$result = ''; $label = '';
if (! empty($this->photo))
if (!empty($this->photo))
{
$label.= '<div class="photointooltip">';
$label.= Form::showphoto('userphoto', $this, 0, 60, 0, 'photowithmargin photologintooltip', 'small', 0, 1); // Force height to 60 so we total height of tooltip can be calculated and collision can be managed
$label.= '</div><div style="clear: both;"></div>';
$label .= '<div class="photointooltip">';
$label .= Form::showphoto('userphoto', $this, 0, 60, 0, 'photowithmargin photologintooltip', 'small', 0, 1); // Force height to 60 so we total height of tooltip can be calculated and collision can be managed
$label .= '</div><div style="clear: both;"></div>';
}
// Info Login
$label.= '<div class="centpercent">';
$label.= '<u>' . $langs->trans("User") . '</u><br>';
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs, '');
if (! empty($this->login)) $label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
if (! empty($this->job)) $label.= '<br><b>' . $langs->trans("Job").':</b> '.$this->job;
$label.= '<br><b>' . $langs->trans("Email").':</b> '.$this->email;
if (! empty($this->phone)) $label.= '<br><b>' . $langs->trans("Phone").':</b> '.$this->phone;
if (! empty($this->admin))
$label.= '<br><b>' . $langs->trans("Administrator").'</b>: '.yn($this->admin);
if (! empty($this->socid) ) // Add thirdparty for external users
$label .= '<div class="centpercent">';
$label .= '<u>'.$langs->trans("User").'</u><br>';
$label .= '<b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs, '');
if (!empty($this->login)) $label .= '<br><b>'.$langs->trans('Login').':</b> '.$this->login;
if (!empty($this->job)) $label .= '<br><b>'.$langs->trans("Job").':</b> '.$this->job;
$label .= '<br><b>'.$langs->trans("Email").':</b> '.$this->email;
if (!empty($this->phone)) $label .= '<br><b>'.$langs->trans("Phone").':</b> '.$this->phone;
if (!empty($this->admin))
$label .= '<br><b>'.$langs->trans("Administrator").'</b>: '.yn($this->admin);
if (!empty($this->socid)) // Add thirdparty for external users
{
$thirdpartystatic = new Societe($db);
$thirdpartystatic->fetch($this->socid);
if (empty($hidethirdpartylogo)) $companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink')?'nolink':'')); // picto only of company
$company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
if (empty($hidethirdpartylogo)) $companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
$company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
}
$type=($this->socid?$langs->trans("External").$company:$langs->trans("Internal"));
$label.= '<br><b>' . $langs->trans("Type") . ':</b> ' . $type;
$label.= '<br><b>' . $langs->trans("Status").'</b>: '.$this->getLibStatut(0);
$label.='</div>';
$type = ($this->socid ? $langs->trans("External").$company : $langs->trans("Internal"));
$label .= '<br><b>'.$langs->trans("Type").':</b> '.$type;
$label .= '<br><b>'.$langs->trans("Status").'</b>: '.$this->getLibStatut(0);
$label .= '</div>';
if ($infologin > 0)
{
$label.= '<br>';
$label.= '<br><u>'.$langs->trans("Session").'</u>';
$label.= '<br><b>'.$langs->trans("IPAddress").'</b>: '.$_SERVER["REMOTE_ADDR"];
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $label.= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (user entity '.$this->entity.')';
$label.= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)');
$label.= '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
$label.= '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
$label.= '<br><b>'.$langs->trans("CurrentTheme").':</b> '.$conf->theme;
$label.= '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.$menumanager->name;
$s=picto_from_langcode($langs->getDefaultLang());
$label.= '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.($s?$s.' ':'').$langs->getDefaultLang();
$label.= '<br><b>'.$langs->trans("Browser").':</b> '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')';
$label.= '<br><b>'.$langs->trans("Layout").':</b> '.$conf->browser->layout;
$label.= '<br><b>'.$langs->trans("Screen").':</b> '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
if ($conf->browser->layout == 'phone') $label.= '<br><b>'.$langs->trans("Phone").':</b> '.$langs->trans("Yes");
if (! empty($_SESSION["disablemodules"])) $label.= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.join(', ', explode(',', $_SESSION["disablemodules"]));
$label .= '<br>';
$label .= '<br><u>'.$langs->trans("Session").'</u>';
$label .= '<br><b>'.$langs->trans("IPAddress").'</b>: '.$_SERVER["REMOTE_ADDR"];
if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $label .= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (user entity '.$this->entity.')';
$label .= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)');
$label .= '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
$label .= '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
$label .= '<br><b>'.$langs->trans("CurrentTheme").':</b> '.$conf->theme;
$label .= '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.$menumanager->name;
$s = picto_from_langcode($langs->getDefaultLang());
$label .= '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.($s ? $s.' ' : '').$langs->getDefaultLang();
$label .= '<br><b>'.$langs->trans("Browser").':</b> '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')';
$label .= '<br><b>'.$langs->trans("Layout").':</b> '.$conf->browser->layout;
$label .= '<br><b>'.$langs->trans("Screen").':</b> '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
if ($conf->browser->layout == 'phone') $label .= '<br><b>'.$langs->trans("Phone").':</b> '.$langs->trans("Yes");
if (!empty($_SESSION["disablemodules"])) $label .= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.join(', ', explode(',', $_SESSION["disablemodules"]));
}
if ($infologin < 0) $label='';
if ($infologin < 0) $label = '';
$url = DOL_URL_ROOT.'/user/card.php?id='.$this->id;
if ($option == 'leave') $url = DOL_URL_ROOT.'/holiday/list.php?id='.$this->id;
@ -2703,43 +2703,43 @@ class User extends CommonObject
*/
public function initAsSpecimen()
{
global $user,$langs;
global $user, $langs;
$now=dol_now();
$now = dol_now();
// Initialise parametres
$this->id=0;
$this->id = 0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$this->specimen = 1;
$this->lastname='DOLIBARR';
$this->firstname='SPECIMEN';
$this->gender='man';
$this->note_public='This is a note public';
$this->note_private='This is a note private';
$this->email='email@specimen.com';
$this->personal_email='personalemail@specimen.com';
$this->lastname = 'DOLIBARR';
$this->firstname = 'SPECIMEN';
$this->gender = 'man';
$this->note_public = 'This is a note public';
$this->note_private = 'This is a note private';
$this->email = 'email@specimen.com';
$this->personal_email = 'personalemail@specimen.com';
$this->socialnetworks = array(
'skype' => 'skypepseudo',
'twitter' => 'twitterpseudo',
'facebook' => 'facebookpseudo',
'linkedin' => 'linkedinpseudo',
);
$this->office_phone='0999999999';
$this->office_fax='0999999998';
$this->user_mobile='0999999997';
$this->personal_mobile='0999999996';
$this->admin=0;
$this->login='dolibspec';
$this->pass='dolibspec';
$this->office_phone = '0999999999';
$this->office_fax = '0999999998';
$this->user_mobile = '0999999997';
$this->personal_mobile = '0999999996';
$this->admin = 0;
$this->login = 'dolibspec';
$this->pass = 'dolibspec';
//$this->pass_indatabase='dolibspec'; Set after a fetch
//$this->pass_indatabase_crypted='e80ca5a88c892b0aaaf7e154853bccab'; Set after a fetch
$this->datec=$now;
$this->datem=$now;
$this->datec = $now;
$this->datem = $now;
$this->datelastlogin=$now;
$this->datepreviouslogin=$now;
$this->statut=1;
$this->datelastlogin = $now;
$this->datepreviouslogin = $now;
$this->statut = 1;
//$this->societe_id = 1; For external users
//$this->contact_id = 1; For external users

View File

@ -288,23 +288,23 @@ if ($action === 'confirm_deletecombination') {
$form = new Form($db);
if (! empty($id) || ! empty($ref))
if (!empty($id) || !empty($ref))
{
llxHeader("", "", $langs->trans("CardProduct".$object->type));
$showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0;
$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product');
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'combinations', $titre, -1, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter=" fk_product_type = ".$object->type;
$object->next_prev_filter = " fk_product_type = ".$object->type;
dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', '', '', '', 0, '', '', 1);
dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1);
print '<div class="fichecenter">';
@ -494,9 +494,9 @@ if (! empty($id) || ! empty($ref))
print '<form method="post" id="combinationform" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
print '<input type="hidden" name="action" value="' . (($valueid > 0) ? "update" : "create") .'">'."\n";
print '<input type="hidden" name="action" value="'.(($valueid > 0) ? "update" : "create").'">'."\n";
if ($valueid > 0) {
print '<input type="hidden" name="valueid" value="' . $valueid .'">'."\n";
print '<input type="hidden" name="valueid" value="'.$valueid.'">'."\n";
}
dol_fiche_head();
@ -518,7 +518,7 @@ if (! empty($id) || ! empty($ref))
print '</select>';
}
$htmltext=$langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes"));
$htmltext = $langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes"));
print $form->textwithpicto('', $htmltext);
/*print ' &nbsp; &nbsp; <a href="'.DOL_URL_ROOT.'/variants/create.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=add&id='.$object->id).'">';
print $langs->trans("Create");
@ -780,9 +780,9 @@ if (! empty($id) || ! empty($ref))
print '<td class="nowrap center">';
if ($productCombinations || $massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($prodstatic->id, $arrayofselected)) $selected=1;
print '<input id="cb'.$prodstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.'"'.($selected?' checked="checked"':'').'>';
$selected = 0;
if (in_array($prodstatic->id, $arrayofselected)) $selected = 1;
print '<input id="cb'.$prodstatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$prodstatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
print '</tr>';