';
}
if ($input['type'] == 'select') {
- $more .= $this->selectarray($input['name'], $input['values'], $input['default'], $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
+ $more .= $this->selectarray($input['name'], $input['values'], !empty($input['default']) ? $input['default'] : '-1', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
} else {
$more .= $this->multiselectarray($input['name'], $input['values'], is_array($input['default']) ? $input['default'] : [$input['default']], $key_in_label, $value_as_key, $morecss, $translate, $maxlen, $moreattr);
}
@@ -8323,8 +8333,8 @@ class Form
* Show a multiselect form from an array. WARNING: Use this only for short lists.
*
* @param string $htmlname Name of select
- * @param array $array Array with key+value
- * @param array $selected Array with key+value preselected
+ * @param array $array Array(key=>value) or Array(key=>array('id'=> , 'label'=> ))
+ * @param array $selected Array of keys preselected
* @param int $key_in_label 1 to show key like in "[key] value"
* @param int $value_as_key 1 to use value as key
* @param string $morecss Add more css style
@@ -8360,14 +8370,24 @@ class Form
if (!empty($array)) {
foreach ($array as $key => $value) {
- $newval = ($translate ? $langs->trans($value) : $value);
- $newval = ($key_in_label ? $key.' - '.$newval : $newval);
+ $tmpkey = $key;
+ $tmpvalue = $value;
+ $tmpcolor = '';
+ $tmppicto = '';
+ if (is_array($value) && array_key_exists('id', $value) && array_key_exists('label', $value)) {
+ $tmpkey = $value['id'];
+ $tmpvalue = $value['label'];
+ $tmpcolor = $value['color'];
+ $tmppicto = $value['picto'];
+ }
+ $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
+ $newval = ($key_in_label ? $tmpkey.' - '.$newval : $newval);
- $out .= '
'."\n";
- //$moreforfilter .= '
'; // Should use -1 to say nothing
+ $moreforfilter .= '
'."\n";
}
if (is_array($tab_categs)) {
@@ -439,6 +438,7 @@ class FormOther
if ($categ['id'] == $selected) {
$moreforfilter .= ' selected';
}
+ $moreforfilter .= ' data-html="'.dol_escape_htmltag(img_picto('', 'category', 'class="pictofixedwidth" style="color: #'.$categ['color'].'"').dol_trunc($categ['fulllabel'], 50, 'middle')).'"';
$moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').'';
}
}
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index 4dbdd9f5be8..7d4483de6cf 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -304,7 +304,7 @@ function getDefaultDatesForTransfer()
$date_end = dol_get_last_day($year_end, $month_end);
}
} elseif ($periodbydefaultontransfer == 1) {
- $year_current = strftime("%Y", dol_now());
+ $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$pastmonth = strftime("%m", dol_now());
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
@@ -312,7 +312,7 @@ function getDefaultDatesForTransfer()
$pastmonthyear--;
}
} else {
- $year_current = strftime("%Y", dol_now());
+ $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 0ea8b49d04a..2ce3094f41b 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1724,15 +1724,13 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu
print '
';
print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0¬ification_to_list_owner=0';
print '
';
- }
- if ($const == 'ADHERENT_MAILMAN_UNSUB_URL') {
+ } elseif ($const == 'ADHERENT_MAILMAN_UNSUB_URL') {
print '. '.$langs->trans("Example").':
'.img_down().'';
print '
';
print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&send_unsub_ack_to_this_batch=0&send_unsub_notifications_to_list_owner=0';
print '
';
//print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
- }
- if ($const == 'ADHERENT_MAILMAN_LISTS') {
+ } elseif ($const == 'ADHERENT_MAILMAN_LISTS') {
print '. '.$langs->trans("Example").':
'.img_down().'';
print '
';
print 'mymailmanlist
';
@@ -1743,6 +1741,8 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu
}
print '
';
//print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
+ } elseif ($const == 'ADHERENT_MAIL_FROM') {
+ print ' '.img_help(1, $langs->trans("EMailHelpMsgSPFDKIM"));
}
print "\n";
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 70589dfb120..43264ac3d98 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -267,9 +267,23 @@ function societe_prepare_head(Societe $object)
if (!empty($user->rights->partnership->read)) {
$langs->load("partnership");
$nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
- $head[$h][0] = DOL_URL_ROOT.'/societe/partnership.php?socid='.$object->id;
- $head[$h][1] = $langs->trans("Partnership");
- $head[$h][2] = 'partnership';
+ $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?socid='.$object->id;
+ $head[$h][1] = $langs->trans("Partnerships");
+ $nbNote = 0;
+ $sql = "SELECT COUNT(n.rowid) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n";
+ $sql .= " WHERE fk_soc = ".((int) $object->id);
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ $nbNote = $obj->nb;
+ } else {
+ dol_print_error($db);
+ }
+ if ($nbNote > 0) {
+ $head[$h][1] .= '
'.$nbNote.'';
+ }
+ $head[$h][2] = 'partnerships';
if ($nbPartnership > 0) {
$head[$h][1] .= '
'.$nbPartnership.'';
}
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index c65013722d4..8ba05557220 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -58,7 +58,7 @@ function facturefourn_prepare_head($object)
if (!empty($conf->paymentbybanktransfer->enabled)) {
$nbStandingOrders = 0;
$sql = "SELECT COUNT(pfd.rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sql .= " WHERE pfd.fk_facture_fourn = ".((int) $object->id);
$sql .= " AND pfd.ext_payment_id IS NULL";
$resql = $db->query($sql);
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index bd02d7cca53..0d14b322953 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -59,7 +59,7 @@ function facture_prepare_head($object)
if (!empty($conf->prelevement->enabled)) {
$nbStandingOrders = 0;
$sql = "SELECT COUNT(pfd.rowid) as nb";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sql .= " WHERE pfd.fk_facture = ".((int) $object->id);
$sql .= " AND pfd.ext_payment_id IS NULL";
$resql = $db->query($sql);
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index 6e0dcb3b83a..71a9849dc16 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -66,9 +66,23 @@ function member_prepare_head(Adherent $object)
if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
if (!empty($user->rights->partnership->read)) {
$nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
- $head[$h][0] = DOL_URL_ROOT.'/adherents/partnership.php?rowid='.$object->id;
- $head[$h][1] = $langs->trans("Partnership");
- $head[$h][2] = 'partnership';
+ $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?rowid='.$object->id;
+ $head[$h][1] = $langs->trans("Partnerships");
+ $nbNote = 0;
+ $sql = "SELECT COUNT(n.rowid) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n";
+ $sql .= " WHERE fk_member = ".((int) $object->id);
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ $nbNote = $obj->nb;
+ } else {
+ dol_print_error($db);
+ }
+ if ($nbNote > 0) {
+ $head[$h][1] .= '
'.$nbNote.'';
+ }
+ $head[$h][2] = 'partnerships';
if ($nbPartnership > 0) {
$head[$h][1] .= '
'.$nbPartnership.'';
}
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index d427f87189a..f418fcf7de2 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -1241,13 +1241,14 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
- $modeinput = 'hours';
+ // Comment for avoid unnecessary multiple calculation
+ /*$modeinput = 'hours';
print '';
+ print '';*/
print '';
@@ -1610,7 +1611,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
// Duration
print '
';
- $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
+ $dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0;
+ if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0;
$totalforeachday[$preselectedday] += $dayWorkLoad;
$alreadyspent = '';
@@ -1628,13 +1630,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
//$tableCell.=' ';
print $tableCell;
- $modeinput = 'hours';
+ // Comment for avoid unnecessary multiple calculation
+ /*$modeinput = 'hours';
print '';
+ print '';*/
print ' | ';
@@ -1990,7 +1993,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$modeinput = 'hours';
for ($idw = 0; $idw < 7; $idw++) {
$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
-
+ if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0;
$cssonholiday = '';
if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
$cssonholiday .= 'onholidayallday ';
@@ -2001,14 +2004,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
$tmparray = dol_getdate($tmpday);
- $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
+ $dayWorkLoad = (!empty($projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id] : 0);
$totalforeachday[$tmpday] += $dayWorkLoad;
$alreadyspent = '';
if ($dayWorkLoad > 0) {
$alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
}
- $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']);
+ $alttitle = $langs->trans("AddHereTimeSpentForDay", !empty($tmparray['day']) ? $tmparray['day'] : 0, $tmparray['mon']);
global $numstartworkingday, $numendworkingday;
$cssweekend = '';
@@ -2288,7 +2291,8 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
$year = $firstdaytoshowarray['year'];
$month = $firstdaytoshowarray['mon'];
foreach ($TWeek as $weekIndex => $weekNb) {
- $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
+ $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ;
+ if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0;
$totalforeachweek[$weekNb] += $weekWorkLoad;
$alreadyspent = '';
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 0d0a0de3e0d..0ef7a568f18 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -391,6 +391,11 @@ function restrictedArea(User $user, $features, $objectid = 0, $tableandshare = '
return 1;
}
+ // To avoid access forbidden with numeric ref
+ if ($dbt_select != 'rowid' && $dbt_select != 'id') {
+ $objectid = "'".$objectid."'";
+ }
+
// Features/modules to check
$featuresarray = array($features);
if (preg_match('/&/', $features)) {
diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql
index 10c50ca99ee..d6945d26fd5 100644
--- a/htdocs/core/menus/init_menu_auguria.sql
+++ b/htdocs/core/menus/init_menu_auguria.sql
@@ -473,9 +473,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
-- HRM - Employee
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->user->user->creer', '', 0, 1, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__);
-- HRM - Holiday
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 4a6636942c4..22613a331b7 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -2251,9 +2251,9 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu =
if (isModEnabled('hrm')) {
$langs->load("hrm");
- $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"'));
+ $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write'));
- $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read'));
+ $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read'));
$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"'));
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 763973ac031..f6ee9da7d60 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1881,7 +1881,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$i = 0;
while ($i < $num) {
$obj2 = $this->db->fetch_object($resqlseladmin);
- dol_syslog(get_class($this)."::insert_permissions Add permission id '.$r_id.' to user id=".$obj2->rowid);
+ dol_syslog(get_class($this)."::insert_permissions Add permission id ".$r_id." to user id=".$obj2->rowid);
$tmpuser = new User($this->db);
$result = $tmpuser->fetch($obj2->rowid);
@@ -1968,13 +1968,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$menu->menu_handler = 'all';
//$menu->module=strtolower($this->name); TODO When right_class will be same than module name
- $menu->module = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class;
+ $menu->module = (empty($this->rights_class) ? strtolower($this->name) : $this->rights_class);
if (!$this->menu[$key]['fk_menu']) {
$menu->fk_menu = 0;
} else {
$foundparent = 0;
$fk_parent = $this->menu[$key]['fk_menu'];
+ $reg = array();
if (preg_match('/^r=/', $fk_parent)) { // old deprecated method
$fk_parent = str_replace('r=', '', $fk_parent);
if (isset($this->menu[$fk_parent]['rowid'])) {
diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php
index 5eaae25a67c..30751fc5222 100644
--- a/htdocs/core/modules/modApi.class.php
+++ b/htdocs/core/modules/modApi.class.php
@@ -152,37 +152,20 @@ class modApi extends DolibarrModules
$this->menu = array(); // List of menus to add
$r = 0;
- // Add here entries to declare new menus
- //
- // Example to declare a new Top Menu entry and its Left menu entry:
- // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
- // 'type'=>'top', // This is a Top menu entry
- // 'titre'=>'Api top menu',
- // 'mainmenu'=>'api',
- // 'leftmenu'=>'api',
- // 'url'=>'/api/pagetop.php',
- // 'langs'=>'mylangfile@api', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- // 'position'=>100,
- // 'enabled'=>'$conf->api->enabled', // Define condition to show or hide menu entry. Use '$conf->api->enabled' if entry must be visible if module is enabled.
- // 'perms'=>'1', // Use 'perms'=>'$user->rights->api->level1->level2' if you want your menu with a permission rules
- // 'target'=>'',
- // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
- // $r++;
- //
- // Example to declare a Left Menu entry into an existing Top menu entry:
- // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- // 'type'=>'left', // This is a Left menu entry
- // 'titre'=>'Api left menu',
- // 'mainmenu'=>'xxx',
- // 'leftmenu'=>'api',
- // 'url'=>'/api/pagelevel2.php',
- // 'langs'=>'mylangfile@api', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- // 'position'=>100,
- // 'enabled'=>'$conf->api->enabled', // Define condition to show or hide menu entry. Use '$conf->api->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
- // 'perms'=>'1', // Use 'perms'=>'$user->rights->api->level1->level2' if you want your menu with a permission rules
- // 'target'=>'',
- // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
- // $r++;
+ $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools',
+ 'type'=>'left',
+ 'titre'=>'ApiExplorer',
+ 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
+ 'mainmenu'=>'tools',
+ 'leftmenu'=>'devtools_api',
+ 'url'=>'/api/index.php/explorer',
+ 'langs'=>'modulebuilder',
+ 'position'=>100,
+ 'perms'=>'1',
+ //'enabled'=>'isModEnabled("api") && preg_match(\'/^(devtools)/\',$leftmenu)',
+ 'enabled'=>'isModEnabled("api")',
+ 'target'=>'_apiexplorer',
+ 'user'=>0);
// Exports
diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php
index 99c32e48bbd..2d6cafa9c2e 100644
--- a/htdocs/core/modules/modModuleBuilder.class.php
+++ b/htdocs/core/modules/modModuleBuilder.class.php
@@ -102,16 +102,18 @@ class modModuleBuilder extends DolibarrModules
//------------------
$this->menu = array();
- $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',
+ $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools',
'type'=>'left',
'titre'=>'ModuleBuilder',
- 'mainmenu'=>'home',
- 'leftmenu'=>'admintools_modulebuilder',
- 'url'=>'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools',
+ 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
+ 'mainmenu'=>'tools',
+ 'leftmenu'=>'devtools_modulebuilder',
+ 'url'=>'/modulebuilder/index.php?mainmenu=tools&leftmenu=devtools',
'langs'=>'modulebuilder',
'position'=>100,
- 'perms'=>'1',
- 'enabled'=>'$conf->modulebuilder->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu) && ($user->admin || $conf->global->MODULEBUILDER_FOREVERYONE)',
+ 'perms'=>'$user->hasRight("modulebuilder", "run")',
+ //'enabled'=>'isModEnabled("modulebuilder") && preg_match(\'/^(devtools|all)/\',$leftmenu)',
+ 'enabled'=>'isModEnabled("modulebuilder")',
'target'=>'_modulebuilder',
'user'=>0);
}
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 1ca960860d3..940c4fb2f9a 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -658,16 +658,7 @@ class modProduct extends DolibarrModules
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
- $this->import_regex_array[$r] = array(
- 'p.ref'=>'[^ ]',
- 'p.price_base_type' => 'HT|TTC',
- 'p.tosell'=>'^[0|1]$',
- 'p.tobuy'=>'^[0|1]$',
- 'p.fk_product_type'=>'^[0|1]$',
- 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
- 'p.recuperableonly' => '^[0|1]$',
- 'p.finished' => '^[0|1]$'
- );
+
// field order as per structure of table llx_product
$import_sample = array(
'p.ref' => "ref:PREF123456",
diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php
index f09d7defeb1..1e48fc4d5a0 100644
--- a/htdocs/core/tpl/massactions_pre.tpl.php
+++ b/htdocs/core/tpl/massactions_pre.tpl.php
@@ -78,6 +78,23 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
}
}
+if ($massaction == 'preupdateprice' && isModEnabled('category')) {
+ $formquestion = array();
+
+ $valuefield = '
';
+ $valuefield .= '%';
+ $valuefield .= '
';
+
+ $formquestion[] = array(
+ 'type' => 'other',
+ 'name' => 'pricerate',
+ 'label' => $langs->trans("Rate"),
+ 'value' => $valuefield
+ );
+
+ print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUpdatePrice"), $langs->trans("ConfirmUpdatePriceQuestion", count($toselect)), "updateprice", $formquestion, 1, 0, 200, 500, 1);
+}
+
if ($massaction == 'presetsupervisor') {
$formquestion = array();
@@ -96,6 +113,7 @@ if ($massaction == 'presetsupervisor') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmSetSupervisor"), $langs->trans("ConfirmSetSupervisorQuestion", count($toselect)), "setsupervisor", $formquestion, 1, 0, 200, 500, 1);
}
+
if ($massaction == 'presend') {
$langs->load("mails");
diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php
index a81c95251f4..2a0f3d654d7 100644
--- a/htdocs/core/tpl/notes.tpl.php
+++ b/htdocs/core/tpl/notes.tpl.php
@@ -29,6 +29,9 @@ $module = $object->element;
$note_public = 'note_public';
$note_private = 'note_private';
+if ($module == "product") {
+ $module = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
+}
$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : ''));
// Set $permission from the $permissionnote var defined on calling page
$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0))));
@@ -60,37 +63,39 @@ if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) {
// Special cases
if ($module == 'propal') {
- $permission = $user->rights->propal->creer;
+ $permission = $user->hasRight("propal", "creer");
} elseif ($module == 'supplier_proposal') {
- $permission = $user->rights->supplier_proposal->creer;
+ $permission = $user->hasRight("supplier_proposal", "creer");
} elseif ($module == 'fichinter') {
- $permission = $user->rights->ficheinter->creer;
+ $permission = $user->hasRight("ficheinter", "creer");
} elseif ($module == 'project') {
- $permission = $user->rights->projet->creer;
+ $permission = $user->hasRight("projet", "creer");
} elseif ($module == 'project_task') {
- $permission = $user->rights->projet->creer;
+ $permission = $user->hasRight("projet", "creer");
} elseif ($module == 'invoice_supplier') {
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
- $permission = $user->rights->fournisseur->facture->creer;
+ $permission = $user->hasRight("fournisseur", "facture", "creer");
} else {
- $permission = $user->rights->supplier_invoice->creer;
+ $permission = $user->hasRight("supplier_invoice", "creer");
}
} elseif ($module == 'order_supplier') {
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
- $permission = $user->rights->fournisseur->commande->creer;
+ $permission = $user->hasRight("fournisseur", "commande", "creer");
} else {
- $permission = $user->rights->supplier_order->creer;
+ $permission = $user->hasRight("supplier_order", "creer");
}
} elseif ($module == 'societe') {
- $permission = $user->rights->societe->creer;
+ $permission = $user->hasRight("societe", "creer");
} elseif ($module == 'contact') {
- $permission = $user->rights->societe->creer;
+ $permission = $user->hasRight("societe", "creer");
} elseif ($module == 'shipping') {
- $permission = $user->rights->expedition->creer;
+ $permission = $user->hasRight("expedition", "creer");
} elseif ($module == 'product') {
- $permission = $user->rights->produit->creer;
+ $permission = $user->hasRight("produit", "creer");
+} elseif ($module == 'service') {
+ $permission = $user->hasRight("service", "creer");
} elseif ($module == 'ecmfiles') {
- $permission = $user->rights->ecm->setup;
+ $permission = $user->hasRight("ecm", "setup");
} elseif ($module == 'user') {
$permission = $user->hasRight("user", "self", "write");
}
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 381683cf62c..1bfc9587b89 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -258,9 +258,11 @@ if ($nolinesbefore) {
}
if (empty($senderissupplier)) {
$statustoshow = 1;
+ $statuswarehouse = 'warehouseopen,warehouseinternal';
+ if (!empty($conf->global->ENTREPOT_WAREHOUSEINTERNAL_NOT_SELL)) $statuswarehouse = 'warehouseopen';
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
// hide products in closed warehouse, but show products for internal transfer
- $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
+ $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, $statuswarehouse, GETPOST('combinations', 'array'));
} else {
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
}
diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php
index 4109c30d335..e9c2b82ae22 100644
--- a/htdocs/don/stats/index.php
+++ b/htdocs/don/stats/index.php
@@ -41,7 +41,7 @@ if ($user->socid > 0) {
$socid = $user->socid;
}
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php
index 81e0adb15aa..3b06f005787 100644
--- a/htdocs/expedition/list.php
+++ b/htdocs/expedition/list.php
@@ -258,7 +258,7 @@ $helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Ex
llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
$sql = 'SELECT';
-if ($sall || $search_product_category > 0 || $search_user > 0) {
+if ($sall || $search_user > 0) {
$sql = 'SELECT DISTINCT';
}
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number, e.fk_shipping_method,";
@@ -288,13 +288,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
if (!empty($extrafields->attributes[$object->table_element]['label']) && 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 (e.rowid = ef.fk_object)";
}
-if ($sall || $search_product_category > 0) {
+if ($sall) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet as ed ON e.rowid=ed.fk_expedition';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON pd.rowid=ed.fk_origin_line';
}
-if ($search_product_category > 0) {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
-}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
@@ -326,9 +323,7 @@ $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object
$sql .= $hookmanager->resPrint;
$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
-if ($search_product_category > 0) {
- $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
-}
+
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
@@ -408,7 +403,36 @@ if ($search_categ_cus > 0) {
if ($search_categ_cus == -2) {
$sql .= " AND cc.fk_categorie IS NULL";
}
-
+// Search for tag/category ($searchCategoryProductList is an array of ID)
+$searchCategoryProductOperator = -1;
+$searchCategoryProductList = array($search_product_category);
+if (!empty($searchCategoryProductList)) {
+ $searchCategoryProductSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryProductList as $searchCategoryProduct) {
+ if (intval($searchCategoryProduct) == -2) {
+ $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_product = ck.fk_product)";
+ } elseif (intval($searchCategoryProduct) > 0) {
+ if ($searchCategoryProductOperator == 0) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ }
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryProductOperator == 1) {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
+ }
+ }
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -593,7 +617,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->right
$moreforfilter .= img_picto($tmptitle, 'category');
//$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
//$moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
- $moreforfilter .= $formother->select_categories(Categorie::TYPE_PRODUCT, $search_product_category, 'parent', 1, $tmptitle);
+ $moreforfilter .= $formother->select_categories(Categorie::TYPE_PRODUCT, $search_product_category, 'search_product_category', 1, $tmptitle);
$moreforfilter .= '
';
}
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 4bb9bf378ee..33ec1fede7b 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -418,7 +418,7 @@ if (empty($reshook)) {
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
- $emailFrom = $expediteur->email;
+ $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($emailTo && $emailFrom) {
$filename = array(); $filedir = array(); $mimetype = array();
@@ -525,7 +525,7 @@ if (empty($reshook)) {
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
- $emailFrom = $expediteur->email;
+ $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($emailFrom && $emailTo) {
$filename = array(); $filedir = array(); $mimetype = array();
@@ -641,7 +641,7 @@ if (empty($reshook)) {
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator);
- $emailFrom = $expediteur->email;
+ $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($emailFrom && $emailTo) {
$filename = array(); $filedir = array(); $mimetype = array();
@@ -749,7 +749,7 @@ if (empty($reshook)) {
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_refuse);
- $emailFrom = $expediteur->email;
+ $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($emailFrom && $emailTo) {
$filename = array(); $filedir = array(); $mimetype = array();
@@ -863,7 +863,7 @@ if (empty($reshook)) {
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_cancel);
- $emailFrom = $expediteur->email;
+ $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($emailFrom && $emailTo) {
$filename = array(); $filedir = array(); $mimetype = array();
@@ -1043,7 +1043,7 @@ if (empty($reshook)) {
// FROM
$expediteur = new User($db);
$expediteur->fetch($user->id);
- $emailFrom = $expediteur->email;
+ $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($emailFrom && $emailTo) {
$filename = array(); $filedir = array(); $mimetype = array();
diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php
index b4d11320411..e9fdd03a2be 100644
--- a/htdocs/expensereport/stats/index.php
+++ b/htdocs/expensereport/stats/index.php
@@ -54,7 +54,7 @@ if ($user->socid) {
}
$result = restrictedArea($user, 'expensereport', $id, '');
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php
index f1ab4b08fec..162afb68077 100644
--- a/htdocs/fichinter/stats/index.php
+++ b/htdocs/fichinter/stats/index.php
@@ -43,7 +43,7 @@ if ($user->socid > 0) {
$socid = $user->socid;
}
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index 54c7885e080..3a7eebbffac 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -253,7 +253,7 @@ if (empty($dolibarr_main_data_root)) {
// Define some constants
define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir (defined only for some code that want to be compatible with old versions without this parameter)
define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem data (documents)
-// Try to autodetect DOL_MAIN_URL_ROOT and DOL_URL_ROOT.
+// Try to autodetect DOL_MAIN_URL_ROOT and DOL_URL_ROOT when root is not directly the main domain.
// Note: autodetect works only in case 1, 2, 3 and 4 of phpunit test CoreTest.php. For case 5, 6, only setting value into conf.php will works.
$tmp = '';
$found = 0;
@@ -283,7 +283,8 @@ foreach ($paths as $tmppath) { // We check to find (B+start of C)=A
}
//print "found=".$found." dolibarr_main_url_root=".$dolibarr_main_url_root."\n";
if (!$found) {
- $tmp = $dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
+ // There is no subdir that compose the main url root or autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
+ $tmp = $dolibarr_main_url_root;
} else {
$tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
}
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index e0434378573..8eac9943c3a 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -752,7 +752,7 @@ if ($search_billed > 0) {
$help_url = '';
$sql = 'SELECT';
-if ($sall || $search_product_category > 0) {
+if ($sall) {
$sql = 'SELECT DISTINCT';
}
$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.email,';
@@ -782,12 +782,9 @@ $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!empty($extrafields->attributes[$object->table_element]['label']) && 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 (cf.rowid = ef.fk_object)";
}
-if ($sall || $search_product_category > 0) {
+if ($sall) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande';
}
-if ($search_product_category > 0) {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
-}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
// We'll need this table joined to the select in order to filter by sale
@@ -826,9 +823,6 @@ if ($search_request_author) {
if ($search_billed != '' && $search_billed >= 0) {
$sql .= " AND cf.billed = ".((int) $search_billed);
}
-if ($search_product_category > 0) {
- $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
-}
//Required triple check because statut=0 means draft filter
if (GETPOST('statut', 'intcomma') !== '') {
$sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")";
@@ -920,6 +914,36 @@ if ($search_multicurrency_montant_ttc != '') {
if ($search_project_ref != '') {
$sql .= natural_search("p.ref", $search_project_ref);
}
+// Search for tag/category ($searchCategoryProductList is an array of ID)
+$searchCategoryProductOperator = -1;
+$searchCategoryProductList = array($search_product_category);
+if (!empty($searchCategoryProductList)) {
+ $searchCategoryProductSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryProductList as $searchCategoryProduct) {
+ if (intval($searchCategoryProduct) == -2) {
+ $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product)";
+ } elseif (intval($searchCategoryProduct) > 0) {
+ if ($searchCategoryProductOperator == 0) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ }
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryProductOperator == 1) {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
+ }
+ }
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 1d7149cdb10..9f06c56b9e1 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -345,7 +345,7 @@ if (empty($reshook)) {
$rsql .= " , pfd.date_traite as date_traite";
$rsql .= " , pfd.amount";
$rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
- $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$rsql .= " , ".MAIN_DB_PREFIX."user as u";
$rsql .= " WHERE fk_facture_fourn = ".((int) $objecttmp->id);
$rsql .= " AND pfd.fk_user_demande = u.rowid";
@@ -405,7 +405,7 @@ $formcompany = new FormCompany($db);
$thirdparty = new Societe($db);
$sql = "SELECT";
-if ($search_all || $search_product_category > 0) {
+if ($search_all) {
$sql = 'SELECT DISTINCT';
}
$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement,";
@@ -446,7 +446,7 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
if (!$search_all) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
}
-if ($search_all || $search_product_category > 0) {
+if ($search_all) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
}
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON f.fk_user_author = u.rowid';
@@ -594,7 +594,11 @@ if (!empty($searchCategorySupplierList)) {
if (intval($searchCategorySupplier) == -2) {
$searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
} elseif (intval($searchCategorySupplier) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
+ if ($searchCategorySupplierOperator == 0) {
+ $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
+ }
}
}
if ($listofcategoryid) {
@@ -612,19 +616,23 @@ if (!empty($searchCategorySupplierList)) {
}
// Search for tag/category ($searchCategoryProductList is an array of ID)
$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
-$searchCategorySupplierOperator = 0;
+$searchCategoryProductOperator = 0;
if (!empty($searchCategoryProductList)) {
$searchCategoryProductSqlList = array();
$listofcategoryid = '';
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
- $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)";
+ $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product)";
} elseif (intval($searchCategoryProduct) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ if ($searchCategoryProductOperator == 0) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ }
}
}
if ($listofcategoryid) {
- $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
}
if ($searchCategoryProductOperator == 1) {
if (!empty($searchCategoryProductSqlList)) {
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index b421496153d..bad8d19bd28 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -718,7 +718,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$numdirectdebitopen = 0;
$totaldirectdebit = 0;
$sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sql .= " WHERE fk_facture_fourn = ".((int) $objp->facid);
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php
index 8f16676f9ce..ddbafbcbd3c 100644
--- a/htdocs/holiday/list.php
+++ b/htdocs/holiday/list.php
@@ -126,7 +126,7 @@ $arrayfields = array(
'cp.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>40),
'cp.date_fin'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>42),
'cp.date_valid'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1, 'position'=>60),
- 'cp.date_approve'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1, 'position'=>70),
+ 'cp.date_approval'=>array('label'=>$langs->trans("DateApprove"), 'checked'=>1, 'position'=>70),
'cp.date_create'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'cp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>501),
'cp.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
@@ -271,6 +271,8 @@ $sql .= " cp.statut as status,";
$sql .= " cp.fk_validator,";
$sql .= " cp.date_valid,";
$sql .= " cp.fk_user_valid,";
+$sql .= " cp.date_approval,";
+$sql .= " cp.fk_user_approve,";
$sql .= " cp.date_refuse,";
$sql .= " cp.fk_user_refuse,";
$sql .= " cp.date_cancel,";
@@ -636,12 +638,18 @@ if ($resql) {
print '';
}
- // End date
+ // Date validation
if (!empty($arrayfields['cp.date_valid']['checked'])) {
print '';
/*
* Latest modified products
*/
-if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->produit->lire || $user->rights->service->lire)) {
+if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
$max = 15;
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
$sql .= " p.entity,";
diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php
index d9ed8a37c5e..18104118068 100644
--- a/htdocs/product/inventory/list.php
+++ b/htdocs/product/inventory/list.php
@@ -270,49 +270,32 @@ foreach ($search as $key => $val) {
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
-// Search for tag/category
-$searchCategoryProductSqlList = array();
-if ($searchCategoryProductOperator == 1) {
- $existsCategoryProductList = array();
+// Search for tag/category ($searchCategoryProductList is an array of ID)
+if (!empty($searchCategoryProductList)) {
+ $searchCategoryProductSqlList = array();
+ $listofcategoryid = '';
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
- $sqlCategoryProductNotExists = " NOT EXISTS (";
- $sqlCategoryProductNotExists .= " SELECT cp.fk_product";
- $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp";
- $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product";
- $sqlCategoryProductNotExists .= " )";
- $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists;
+ $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)";
} elseif (intval($searchCategoryProduct) > 0) {
- $existsCategoryProductList[] = $db->escape($searchCategoryProduct);
+ if ($searchCategoryProductOperator == 0) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ }
}
}
- if (!empty($existsCategoryProductList)) {
- $sqlCategoryProductExists = " EXISTS (";
- $sqlCategoryProductExists .= " SELECT cp.fk_product";
- $sqlCategoryProductExists .= " FROM ".$db->prefix()."categorie_product AS cp";
- $sqlCategoryProductExists .= " WHERE cp.fk_product = t.fk_product";
- $sqlCategoryProductExists .= " AND cp.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryProductList)).")";
- $sqlCategoryProductExists .= " )";
- $searchCategoryProductSqlList[] = $sqlCategoryProductExists;
+ if ($listofcategoryid) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
}
- if (!empty($searchCategoryProductSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
- }
-} else {
- foreach ($searchCategoryProductList as $searchCategoryProduct) {
- if (intval($searchCategoryProduct) == -2) {
- $sqlCategoryProductNotExists = " NOT EXISTS (";
- $sqlCategoryProductNotExists .= " SELECT cp.fk_product";
- $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp";
- $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product";
- $sqlCategoryProductNotExists .= " )";
- $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists;
- } elseif (intval($searchCategoryProduct) > 0) {
- $searchCategoryProductSqlList[] = "t.fk_product IN (SELECT fk_product FROM ".$db->prefix()."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")";
+ if ($searchCategoryProductOperator == 1) {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
}
- }
- if (!empty($searchCategoryProductSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
}
}
// Add where from extra fields
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 26f6a3a410c..21907974a0f 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -45,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
if (isModEnabled('categorie')) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
}
// Load translation files required by the page
@@ -72,7 +73,7 @@ $search_type = GETPOST("search_type", 'int');
$search_vatrate = GETPOST("search_vatrate", 'alpha');
$searchCategoryProductOperator = 0;
if (GETPOSTISSET('formfilteraction')) {
- $searchCategoryProductOperator = GETPOST('search_category_product_operator', 'int');
+ $searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
$searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
}
@@ -310,7 +311,6 @@ if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
-
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
@@ -508,7 +508,11 @@ if (!empty($searchCategoryProductList)) {
if (intval($searchCategoryProduct) == -2) {
$searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)";
} elseif (intval($searchCategoryProduct) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ if ($searchCategoryProductOperator == 0) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ }
}
}
if ($listofcategoryid) {
@@ -554,7 +558,6 @@ if ($search_accountancy_code_buy_intra) {
if ($search_accountancy_code_buy_export) {
$sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export);
}
-
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@@ -737,11 +740,12 @@ if ($resql) {
if ($user->rights->{$rightskey}->creer) {
$arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus");
$arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus");
+ $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
}
if (isModEnabled('category') && $user->rights->{$rightskey}->creer) {
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
}
- if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields'))) {
+ if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields', 'preupdateprice'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
@@ -819,14 +823,9 @@ if ($resql) {
// Filter on categories
$moreforfilter = '';
- if (isModEnabled('categorie') && $user->rights->categorie->lire) {
- $moreforfilter .= '
';
- $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
- $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1);
- $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -';
- $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300');
- $moreforfilter .= ' ';
- $moreforfilter .= '
';
+ if (isModEnabled('categorie') && $user->hasRight('categorie', 'read')) {
+ $formcategory = new FormCategory($db);
+ $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $searchCategoryProductList, 'minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
}
//Show/hide child products. Hidden by default
@@ -1909,7 +1908,7 @@ if ($resql) {
// Status (to sell)
if (!empty($arrayfields['p.tosell']['checked'])) {
print '
';
- if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
+ if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else {
print $product_static->LibStatut($obj->tosell, 5, 0);
@@ -1922,7 +1921,7 @@ if ($resql) {
// Status (to buy)
if (!empty($arrayfields['p.tobuy']['checked'])) {
print ' | ';
- if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
+ if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else {
print $product_static->LibStatut($obj->tobuy, 5, 1);
diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php
index b4277e559b1..0e3f9367e16 100644
--- a/htdocs/product/stock/fiche-valo.php
+++ b/htdocs/product/stock/fiche-valo.php
@@ -106,7 +106,7 @@ if ($id > 0) {
/* ************************************************************************** */
print " \n";
- $year = strftime("%Y", time());
+ $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php
index af2bb49b05e..b0c33e61484 100644
--- a/htdocs/product/stock/list.php
+++ b/htdocs/product/stock/list.php
@@ -270,7 +270,11 @@ if (!empty($searchCategoryWarehouseList)) {
if (intval($searchCategoryWarehouse) == -2) {
$searchCategoryWarehouseSqlList[] = "NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse)";
} elseif (intval($searchCategoryWarehouse) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse);
+ if ($searchCategoryWarehouseOperator == 0) {
+ $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse);
+ }
}
}
if ($listofcategoryid) {
diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php
index 6bf59ebeb0e..af98ee98540 100644
--- a/htdocs/product/stock/valo.php
+++ b/htdocs/product/stock/valo.php
@@ -52,7 +52,7 @@ if ($page < 0) {
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
-$year = strftime("%Y", time());
+$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
/*
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index 0854dceee67..14b98b82581 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -709,7 +709,7 @@ if (count($tasksarray) > 0) {
// Calculate total for all tasks
$listofdistinctprojectid = array(); // List of all distinct projects
- if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
+ if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
foreach ($tasksarraywithoutfilter as $tmptask) {
$listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
}
@@ -795,12 +795,12 @@ print ' ';
print '';
-$modeinput = 'hours';
-
-if ($conf->use_javascript_ajax) {
+if (!empty($conf->use_javascript_ajax)) {
+ $modeinput = 'hours';
print "\n\n";
print '';
}
diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php
index 380b4891376..273affc3563 100644
--- a/htdocs/projet/activity/permonth.php
+++ b/htdocs/projet/activity/permonth.php
@@ -524,7 +524,7 @@ if (count($tasksarray) > 0) {
// Calculate total for all tasks
$listofdistinctprojectid = array(); // List of all distinct projects
- if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
+ if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
foreach ($tasksarraywithoutfilter as $tmptask) {
$listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
}
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index e7bc897db5a..7177f35e71c 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -747,7 +747,7 @@ if (count($tasksarray) > 0) {
// Calculate total for all tasks
$listofdistinctprojectid = array(); // List of all distinct projects
- if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
+ if (!empty($tasksarraywithoutfilter) && is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
foreach ($tasksarraywithoutfilter as $tmptask) {
$listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
}
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index c5dcf0d4bb4..e3865663bf7 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -926,7 +926,7 @@ class Project extends CommonObject
}
// Fetch tasks
- $this->getLinesArray($user);
+ $this->getLinesArray($user, 0);
// Delete tasks
$ret = $this->deleteTasks($user);
@@ -2046,7 +2046,7 @@ class Project extends CommonObject
$sql .= " AND pt.fk_projet = ".((int) $this->id);
$sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
$sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')";
- if ($task_id) {
+ if ($taskid) {
$sql .= " AND ptt.fk_task=".((int) $taskid);
}
if (is_numeric($userid)) {
@@ -2300,14 +2300,15 @@ class Project extends CommonObject
/**
* Create an array of tasks of current project
*
- * @param User $user Object user we want project allowed to
- * @return int >0 if OK, <0 if KO
+ * @param User $user Object user we want project allowed to
+ * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
+ * @return int >0 if OK, <0 if KO
*/
- public function getLinesArray($user)
+ public function getLinesArray($user, $loadRoleMode = 1)
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$taskstatic = new Task($this->db);
- $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0);
+ $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode);
}
}
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 48b0b63e31a..b751d8d1e8e 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -811,9 +811,10 @@ class Task extends CommonObjectLine
* @param int $includebilltime Calculate also the time to bill and billed
* @param array $search_array_options Array of search
* @param int $loadextras Fetch all Extrafields on each task
+ * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
* @return array Array of tasks
*/
- public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0)
+ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1)
{
global $conf, $hookmanager;
@@ -968,14 +969,16 @@ class Task extends CommonObjectLine
$obj = $this->db->fetch_object($resql);
- if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user
- if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) {
- $error++;
+ if ($loadRoleMode) {
+ if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user
+ if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) {
+ $error++;
+ }
}
- }
- if (is_object($usert)) { // If we ask a filter on a user affected to a task
- if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) {
- $error++;
+ if (is_object($usert)) { // If we ask a filter on a user affected to a task
+ if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) {
+ $error++;
+ }
}
}
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 696888a75dd..9ef64174325 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -570,7 +570,11 @@ if (!empty($searchCategoryProjectList)) {
if (intval($searchCategoryProject) == -2) {
$searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)";
} elseif (intval($searchCategoryProject) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
+ if ($searchCategoryProjectOperator == 0) {
+ $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
+ }
}
}
if ($listofcategoryid) {
diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php
index ba293dea744..32498121045 100644
--- a/htdocs/projet/stats/index.php
+++ b/htdocs/projet/stats/index.php
@@ -41,7 +41,7 @@ if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year', 'int') > 0 ? GETPOST('year', 'int') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php
index 76261480ffe..fdec5c6a958 100644
--- a/htdocs/projet/tasks/list.php
+++ b/htdocs/projet/tasks/list.php
@@ -444,7 +444,11 @@ if (!empty($searchCategoryProjectList)) {
if (intval($searchCategoryProject) == -2) {
$searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)";
} elseif (intval($searchCategoryProject) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
+ if ($searchCategoryProjectOperator == 0) {
+ $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
+ }
}
}
if ($listofcategoryid) {
diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php
index dd807b7bb93..07b0199d480 100644
--- a/htdocs/projet/tasks/stats/index.php
+++ b/htdocs/projet/tasks/stats/index.php
@@ -44,7 +44,7 @@ if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php
index 0a70c6c5204..79104817e77 100644
--- a/htdocs/public/payment/newpayment.php
+++ b/htdocs/public/payment/newpayment.php
@@ -805,6 +805,8 @@ if ($action == 'charge' && isModEnabled('stripe')) {
dol_syslog("onlinetoken=".$_SESSION["onlinetoken"]." FinalPaymentAmt=".$_SESSION["FinalPaymentAmt"]." currencyCodeType=".$_SESSION["currencyCodeType"]." payerID=".$_SESSION['payerID']." TRANSACTIONID=".$_SESSION['TRANSACTIONID'], LOG_DEBUG, 0, '_payment');
dol_syslog("FULLTAG=".$FULLTAG, LOG_DEBUG, 0, '_payment');
dol_syslog("error=".$error." errormessage=".$errormessage, LOG_DEBUG, 0, '_payment');
+ dol_syslog("_SERVER[SERVER_NAME] = ".(empty($_SERVER["SERVER_NAME"]) ? '' : dol_escape_htmltag($_SERVER["SERVER_NAME"])), LOG_DEBUG, 0, '_payment');
+ dol_syslog("_SERVER[SERVER_ADDR] = ".(empty($_SERVER["SERVER_ADDR"]) ? '' : dol_escape_htmltag($_SERVER["SERVER_ADDR"])), LOG_DEBUG, 0, '_payment');
dol_syslog("Now call the redirect to paymentok or paymentko, URL = ".($error ? $urlko : $urlok), LOG_DEBUG, 0, '_payment');
if ($error) {
@@ -834,7 +836,10 @@ $conf->dol_hide_leftmenu = 1;
$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '' : '').' ';
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
-dol_syslog("newpayment.php show page paymentmethod=".$paymentmethod.' amount='.$amount.' newamount='.GETPOST("newamount", 'alpha'), LOG_DEBUG, 0, '_payment');
+dol_syslog("--- newpayment.php action = ".$action, LOG_DEBUG, 0, '_payment');
+dol_syslog("newpayment.php show page source=".$source." paymentmethod=".$paymentmethod.' amount='.$amount.' newamount='.GETPOST("newamount", 'alpha')." ref=".$ref, LOG_DEBUG, 0, '_payment');
+dol_syslog("_SERVER[SERVER_NAME] = ".(empty($_SERVER["SERVER_NAME"]) ? '' : dol_escape_htmltag($_SERVER["SERVER_NAME"])), LOG_DEBUG, 0, '_payment');
+dol_syslog("_SERVER[SERVER_ADDR] = ".(empty($_SERVER["SERVER_ADDR"]) ? '' : dol_escape_htmltag($_SERVER["SERVER_ADDR"])), LOG_DEBUG, 0, '_payment');
// Check link validity
if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', 'donation_ref', ''))) {
@@ -2358,7 +2363,17 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme
// Code for payment with option STRIPE_USE_NEW_CHECKOUT set
// Create a Stripe client.
+
var stripe = Stripe('');
+
+ var stripe = Stripe('', { stripeAccount: '' });
+
// Create an instance of Elements
var elements = stripe.elements();
@@ -2403,7 +2418,17 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme
// Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set to 1 or 2
// Create a Stripe client.
+
var stripe = Stripe('');
+
+ var stripe = Stripe('', { stripeAccount: '' });
+
$v) {
$tracepost .= "{$k} - {$v}\n";
}
dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment');
+$tracesession = "";
+foreach ($_SESSION as $k => $v) {
+ $tracesession .= "{$k} - {$v}\n";
+}
+dol_syslog("SESSION=".$tracesession, LOG_DEBUG, 0, '_payment');
$head = '';
if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php
index b1f5dbdc7f9..1e26bf5871a 100644
--- a/htdocs/reception/stats/index.php
+++ b/htdocs/reception/stats/index.php
@@ -36,7 +36,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php
index d5c109a5516..dda796c243e 100644
--- a/htdocs/recruitment/class/recruitmentjobposition.class.php
+++ b/htdocs/recruitment/class/recruitmentjobposition.class.php
@@ -254,7 +254,7 @@ class RecruitmentJobPosition extends CommonObject
// Reset some properties
unset($object->id);
unset($object->fk_user_creat);
- unset($object->import_key);
+ $object->import_key = null;
// Clear fields
if (property_exists($object, 'ref')) {
diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php
index 9988140393d..04118f55572 100644
--- a/htdocs/recruitment/recruitmentcandidature_agenda.php
+++ b/htdocs/recruitment/recruitmentcandidature_agenda.php
@@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$socid = GETPOST('socid', 'int');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
@@ -79,7 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
+ $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php
@@ -209,7 +210,8 @@ if ($object->id > 0) {
if (get_class($objthirdparty) == 'Societe') {
$out .= '&socid='.$objthirdparty->id;
}
- $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1';
+ $backtopageurl = urlencode($_SERVER['PHP_SELF'].'?id='.$objthirdparty->id);
+ $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$backtopageurl.'&percentage=-1';
//$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
//$out.="";
diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php
index 4226e016e73..2452c9e530b 100644
--- a/htdocs/recruitment/recruitmentcandidature_card.php
+++ b/htdocs/recruitment/recruitmentcandidature_card.php
@@ -43,7 +43,7 @@ $cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturecard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
-//$lineid = GETPOST('lineid', 'int');
+$lineid = GETPOST('lineid', 'int');
// Initialize technical objects
$object = new RecruitmentCandidature($db);
@@ -565,7 +565,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Clone
if ($permissiontoadd) {
- print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd);
+ print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd);
}
// Button to convert into a user
diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php
index 0489d68bffb..9b860ac54d5 100644
--- a/htdocs/recruitment/recruitmentcandidature_list.php
+++ b/htdocs/recruitment/recruitmentcandidature_list.php
@@ -47,6 +47,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : ((e
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$mode = GETPOST('mode', 'aZ');
+$lineid = GETPOST('lineid', 'int');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@@ -437,7 +438,7 @@ if ($jobposition->id > 0 && (empty($action) || ($action != 'edit' && $action !=
$morehtmlref .= ' ';
$morehtmlref .= '';
} 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, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {
diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php
index 543d7a66c10..1649ab5ee5e 100644
--- a/htdocs/recruitment/recruitmentcandidature_note.php
+++ b/htdocs/recruitment/recruitmentcandidature_note.php
@@ -48,7 +48,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
+ $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php
index 88424f1b06d..be1b9eec084 100644
--- a/htdocs/recruitment/recruitmentjobposition_card.php
+++ b/htdocs/recruitment/recruitmentjobposition_card.php
@@ -42,7 +42,7 @@ $cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
-//$lineid = GETPOST('lineid', 'int');
+$lineid = GETPOST('lineid', 'int');
// Initialize technical objects
$object = new RecruitmentJobPosition($db);
@@ -279,6 +279,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
if ($action == 'closeas') {
+ $text = "";
//Form to close proposal (signed or not)
$formquestion = array(
array('type' => 'select', 'name' => 'status', 'label' => ' '.$langs->trans("CloseAs").'', 'values' => array(3=>$object->LibStatut($object::STATUS_RECRUITED), 9=>$object->LibStatut($object::STATUS_CANCELED))),
@@ -340,7 +341,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref .= ' ';
$morehtmlref .= '';
} 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, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {
@@ -435,7 +436,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Clone
if ($permissiontoadd) {
- print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd);
+ print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd);
}
/*
diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php
index ca9907976be..a162f4c3af7 100644
--- a/htdocs/recruitment/recruitmentjobposition_document.php
+++ b/htdocs/recruitment/recruitmentjobposition_document.php
@@ -148,7 +148,7 @@ if ($object->id) {
$morehtmlref .= ' ';
$morehtmlref .= '';
} 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, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {
diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php
index dcda5b53109..5dc4004a361 100644
--- a/htdocs/recruitment/recruitmentjobposition_note.php
+++ b/htdocs/recruitment/recruitmentjobposition_note.php
@@ -53,7 +53,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id;
+ $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
}
$permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
@@ -125,7 +125,7 @@ if ($id > 0 || !empty($ref)) {
$morehtmlref .= ' ';
$morehtmlref .= '';
} 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, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (!empty($object->fk_project)) {
diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php
index 9ee2e52a226..5ba1b818137 100644
--- a/htdocs/salaries/card.php
+++ b/htdocs/salaries/card.php
@@ -459,7 +459,7 @@ if ($id > 0) {
// Create
if ($action == 'create') {
- $year_current = strftime("%Y", dol_now());
+ $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php
index 4dfd0c84e0c..ba5d254f22b 100644
--- a/htdocs/salaries/stats/index.php
+++ b/htdocs/salaries/stats/index.php
@@ -51,7 +51,7 @@ if ($user->socid) {
}
$result = restrictedArea($user, 'salaries', '', '', '');
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index c0401ce958f..3901db79cc4 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -1094,7 +1094,7 @@ class Thirdparties extends DolibarrApi
$invoice = new Facture($this->db);
$result = $invoice->list_replacable_invoices($id);
if ($result < 0) {
- throw new RestException(405, $this->thirdparty->error);
+ throw new RestException(405, $invoice->error);
}
return $result;
@@ -1137,7 +1137,7 @@ class Thirdparties extends DolibarrApi
$invoice = new Facture($this->db);
$result = $invoice->list_qualified_avoir_invoices($id);
if ($result < 0) {
- throw new RestException(405, $this->thirdparty->error);
+ throw new RestException(405, $invoice->error);
}
return $result;
@@ -1176,10 +1176,9 @@ class Thirdparties extends DolibarrApi
$sql .= " WHERE fk_soc = ".((int) $id);
}
-
$result = $this->db->query($sql);
- if ($result->num_rows == 0) {
+ if ($this->db->num_rows($result) == 0) {
throw new RestException(404, 'Account not found');
}
@@ -1421,7 +1420,7 @@ class Thirdparties extends DolibarrApi
if ($result > 0) {
return array("success" => $result);
} else {
- throw new RestException(500, 'Error generating the document '.$this->error);
+ throw new RestException(500, 'Error generating the document '.$this->company->error);
}
}
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 66f7cb6ee79..8ffe95731de 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -1474,7 +1474,7 @@ class Societe extends CommonObject
$sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null");
if (isset($this->stcomm_id)) {
- $sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? ((int) $this->stcomm_id) : "0");
+ $sql .= ",fk_stcomm=".(int) $this->stcomm_id;
}
if (isset($this->typent_id)) {
$sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0");
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index f32317163ad..c0f50a5e7b0 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -536,7 +536,11 @@ if (!empty($searchCategoryCustomerList)) {
if (intval($searchCategoryCustomer) == -2) {
$searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
} elseif (intval($searchCategoryCustomer) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
+ if ($searchCategoryCustomerOperator == 0) {
+ $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
+ }
}
}
if ($listofcategoryid) {
@@ -562,7 +566,11 @@ if (!empty($searchCategorySupplierList)) {
if (intval($searchCategorySupplier) == -2) {
$searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
} elseif (intval($searchCategorySupplier) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
+ if ($searchCategorySupplierOperator == 0) {
+ $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
+ }
}
}
if ($listofcategoryid) {
diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php
deleted file mode 100644
index b7bcd153092..00000000000
--- a/htdocs/societe/partnership.php
+++ /dev/null
@@ -1,274 +0,0 @@
-
- * Copyright (C) 2021 NextGestion
- * Copyright (C) 2022 Charlene Benke
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file partnership_card.php
- * \ingroup partnership
- * \brief Page to create/edit/view partnership
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
-require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("companies", "partnership", "other"));
-
-// Get parameters
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
-$action = GETPOST('action', 'aZ09');
-$confirm = GETPOST('confirm', 'alpha');
-$cancel = GETPOST('cancel', 'aZ09');
-$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search
-$backtopage = GETPOST('backtopage', 'alpha');
-$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
-//$lineid = GETPOST('lineid', 'int');
-
-// Security check
-$socid = GETPOST('socid', 'int');
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
-
-if (empty($id) && $socid && (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty')) {
- $id = $socid;
-}
-
-$object = new Societe($db);
-if ($id > 0) {
- $object->fetch($id);
-}
-
-// Initialize technical objects
-$object = new Partnership($db);
-$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('thirdpartypartnership', 'globalcard')); // Note that conf->hooks_modules contains array
-
-// Fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label($object->table_element);
-
-$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
-
-// Initialize array of search criterias
-$search_all = GETPOST("search_all", 'alpha');
-$search = array();
-
-foreach ($object->fields as $key => $val) {
- if (GETPOST('search_'.$key, 'alpha')) {
- $search[$key] = GETPOST('search_'.$key, 'alpha');
- }
-}
-
-// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-
-$permissiontoread = $user->rights->partnership->read;
-$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
-$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php
-$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
-
-
-if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') != 'thirdparty') {
- accessforbidden('Partnership is not activated for thirdparties');
-}
-if (empty($conf->partnership->enabled)) {
- accessforbidden();
-}
-if (empty($permissiontoread)) {
- accessforbidden();
-}
-if ($action == 'edit' && empty($permissiontoadd)) {
- accessforbidden();
-}
-
-if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) {
- accessforbidden();
-}
-
-
-// Security check
-$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
-
-
-/*
- * Actions
- */
-
-$parameters = array('socid' => $id);
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
-
-$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int'));
-$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int'));
-
-if (empty($reshook)) {
- $error = 0;
-
- $backtopage = DOL_URL_ROOT.'/partnership/partnership.php?id='.($id > 0 ? $id : '__ID__');
-
- // Actions when linking object each other
- include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
-}
-
-$object->fields['fk_soc']['visible'] = 0;
-if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) {
- $object->fields['reason_decline_or_cancel']['visible'] = 1;
-}
-$object->fields['note_public']['visible'] = 1;
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-$formfile = new FormFile($db);
-
-$title = $langs->trans("Partnership");
-llxHeader('', $title);
-
-$form = new Form($db);
-
-if ($id > 0) {
- $langs->load("companies");
-
- $object = new Societe($db);
- $result = $object->fetch($id);
-
- if (isModEnabled('notification')) {
- $langs->load("mails");
- }
- $head = societe_prepare_head($object);
-
- print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'company');
-
- $linkback = ''.$langs->trans("BackToList").'';
-
- dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
-
- print '';
-
- print ' ';
- print ' ';
-
- if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
- print '| '.$langs->trans('Prefix').' | '.$object->prefix_comm.' | ';
- }
-
- if ($object->client) {
- print '| ';
- print $langs->trans('CustomerCode').' | ';
- print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
- $tmpcheck = $object->check_codeclient();
- if ($tmpcheck != 0 && $tmpcheck != -5) {
- print ' ('.$langs->trans("WrongCustomerCode").')';
- }
- print ' | ';
- }
-
- if ($object->fournisseur) {
- print '| ';
- print $langs->trans('SupplierCode').' | ';
- print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
- $tmpcheck = $object->check_codefournisseur();
- if ($tmpcheck != 0 && $tmpcheck != -5) {
- print ' ('.$langs->trans("WrongSupplierCode").')';
- }
- print ' | ';
- print ' ';
- }
-
- print ' ';
-
- print ' ';
-
- print dol_get_fiche_end();
-} else {
- dol_print_error('', 'Parameter id not defined');
-}
-
-// Part to show record
-if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
- // Buttons for actions
-
- if ($action != 'presend') {
- print ''."\n";
- $parameters = array();
- $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
-
- if (empty($reshook)) {
- // Show
- if ($permissiontoadd) {
- print dolGetButtonAction($langs->trans('AddPartnership'), '', 'default', DOL_URL_ROOT.'/partnership/partnership_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode(DOL_URL_ROOT.'/societe/partnership.php?id='.$object->id), '', $permissiontoadd);
- }
- }
- print ' '."\n";
- }
-
-
- //$morehtmlright = 'partnership/partnership_card.php?action=create&backtopage=%2Fdolibarr%2Fhtdocs%2Fpartnership%2Fpartnership_list.php';
- $morehtmlright = '';
-
- print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), $morehtmlright, '');
-
- $socid = $object->id;
-
-
- // TODO Replace this card with a table of list of all partnerships.
-
- $object = new Partnership($db);
- $partnershipid = $object->fetch(0, '', 0, $socid);
-
- if ($partnershipid > 0) {
- print '';
- print ' ';
- print ' ';
- print ' '."\n";
-
- // Common attributes
- unset($object->fields['fk_soc']); // Hide field already shown in banner
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
- $forcefieldid = 'socid';
- $forceobjectid = $object->fk_soc;
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
-
- print ' ';
- print ' ';
- }
-}
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php
index 25a4edb6123..43f940acdee 100644
--- a/htdocs/stripe/class/stripe.class.php
+++ b/htdocs/stripe/class/stripe.class.php
@@ -386,7 +386,7 @@ class Stripe extends CommonObject
// That's why we can comment the part of code to retrieve a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used)
$sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pi";
$sql .= " WHERE pi.fk_facture = ".((int) $object->id);
$sql .= " AND pi.sourcetype = '".$this->db->escape($object->element)."'";
$sql .= " AND pi.entity IN (".getEntity('societe').")";
@@ -530,12 +530,12 @@ class Stripe extends CommonObject
$paymentintentalreadyexists = 0;
// Check that payment intent $paymentintent->id is not already recorded.
$sql = "SELECT pi.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pi";
$sql .= " WHERE pi.entity IN (".getEntity('societe').")";
$sql .= " AND pi.ext_payment_site = '".$this->db->escape($service)."'";
$sql .= " AND pi.ext_payment_id = '".$this->db->escape($paymentintent->id)."'";
- dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG);
+ dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_demande", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -552,7 +552,7 @@ class Stripe extends CommonObject
// If not, we create it.
if (!$paymentintentalreadyexists) {
$now = dol_now();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)";
$sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", '".$this->db->escape($paymentintent->id)."', ".((int) $object->id).", '".$this->db->escape($object->element)."', ".((int) $conf->entity).", '".$this->db->escape($service)."', ".((float) $amount).")";
$resql = $this->db->query($sql);
if (!$resql) {
@@ -696,12 +696,12 @@ class Stripe extends CommonObject
$setupintentalreadyexists = 0;
// Check that payment intent $setupintent->id is not already recorded.
$sql = "SELECT pi.rowid";
- $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi";
+ $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_demande as pi";
$sql.= " WHERE pi.entity IN (".getEntity('societe').")";
$sql.= " AND pi.ext_payment_site = '" . $this->db->escape($service) . "'";
$sql.= " AND pi.ext_payment_id = '".$this->db->escape($setupintent->id)."'";
- dol_syslog(get_class($this) . "::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG);
+ dol_syslog(get_class($this) . "::getPaymentIntent search if payment intent already in prelevement_demande", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -717,7 +717,7 @@ class Stripe extends CommonObject
if (! $setupintentalreadyexists)
{
$now=dol_now();
- $sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site)";
+ $sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site)";
$sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $user->id).", '".$this->db->escape($setupintent->id)."', ".((int) $object->id).", '".$this->db->escape($object->element)."', " . ((int) $conf->entity) . ", '" . $this->db->escape($service) . "', ".((float) $amount).")";
$resql = $this->db->query($sql);
if (! $resql)
diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 37853d1488a..66f69a25ff9 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -52,7 +52,7 @@ if (!empty($conf->project->enabled)) {
// Load translation files required by the page
$langs->loadLangs(array('companies', 'supplier_proposal', 'compta', 'bills', 'propal', 'orders', 'products', 'deliveries', 'sendings'));
-if (!empty($conf->margin->enabled)) {
+if (isModEnabled('margin')) {
$langs->load('margins');
}
@@ -62,13 +62,13 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
-$cancel = GETPOST('cancel');
+$cancel = GETPOST('cancel', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
$confirm = GETPOST('confirm', 'alpha');
-$projectid = GETPOST('projectid', 'int');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
+$projectid = GETPOST('projectid', 'int');
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
@@ -79,12 +79,6 @@ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($con
// Nombre de ligne pour choix de produit/service predefinis
$NBLINES = 4;
-// Security check
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
-$result = restrictedArea($user, 'supplier_proposal', $id);
-
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('supplier_proposalcard', 'globalcard'));
@@ -100,8 +94,9 @@ if ($id > 0 || !empty($ref)) {
if ($ret > 0) {
$ret = $object->fetch_thirdparty();
}
- if ($ret < 0) {
- dol_print_error('', $object->error);
+ if ($ret <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
}
}
@@ -124,6 +119,12 @@ $permissiondellink = $usercancreate; // Used by the include of actions_dellink.i
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd = $usercancreate;
+// Security check
+if (!empty($user->socid)) {
+ $socid = $user->socid;
+}
+$result = restrictedArea($user, 'supplier_proposal', $object->id);
+
/*
* Actions
@@ -166,7 +167,7 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object
- if ($action == 'confirm_clone' && $confirm == 'yes') {
+ if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) {
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else {
@@ -195,8 +196,11 @@ if (empty($reshook)) {
// Remove line
$result = $object->deleteline($lineid);
// reorder lines
- if ($result) {
+ if ($result > 0) {
$object->line_order(true);
+ } else {
+ $langs->load("errors");
+ setEventMessages($object->error, $object->errors, 'errors');
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@@ -208,6 +212,9 @@ if (empty($reshook)) {
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
+ if ($ret > 0) {
+ $object->fetch_thirdparty();
+ }
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
@@ -218,25 +225,25 @@ if (empty($reshook)) {
$result = $object->valid($user);
if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- // Define output language
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- $outputlangs = $langs;
- $newlang = '';
- if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
- $newlang = GETPOST('lang_id', 'aZ09');
- }
- if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
- $newlang = $object->thirdparty->default_lang;
- }
- if (!empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- }
- $model = $object->model_pdf;
- $ret = $object->fetch($id); // Reload to get new records
-
- $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ $outputlangs = $langs;
+ $newlang = '';
+ if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
}
+ if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ $model = $object->model_pdf;
+ $ret = $object->fetch($id); // Reload to get new records
+ if ($ret > 0) {
+ $object->fetch_thirdparty();
+ }
+
+ $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
} else {
$langs->load("errors");
@@ -322,6 +329,7 @@ if (empty($reshook)) {
if (!$error) {
if ($origin && $originid) {
+ // Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs[1];
@@ -336,6 +344,15 @@ if (empty($reshook)) {
$element = 'comm/propal';
$subelement = 'propal';
}
+ if ($element == 'contract') {
+ $element = $subelement = 'contrat';
+ }
+ if ($element == 'inter') {
+ $element = $subelement = 'ficheinter';
+ }
+ if ($element == 'shipping') {
+ $element = $subelement = 'expedition';
+ }
$object->origin = $origin;
$object->origin_id = $originid;
@@ -533,6 +550,9 @@ if (empty($reshook)) {
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
+ if ($ret > 0) {
+ $object->fetch_thirdparty();
+ }
$object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
} elseif ($action == "setabsolutediscount" && $usercancreate) {
@@ -568,11 +588,13 @@ if (empty($reshook)) {
$ref_supplier = GETPOST('fourn_ref', 'alpha');
- $prod_entry_mode = GETPOST('prod_entry_mode');
- if ($prod_entry_mode == 'free') {
+ $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
+ if ($prod_entry_mode == 'free') {
$idprod = 0;
+ $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else {
$idprod = GETPOST('idprod', 'int');
+ $tva_tx = '';
}
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); // Can be '1.2' or '1.2 (CODE)'
@@ -581,7 +603,8 @@ if (empty($reshook)) {
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
- $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
+
+ $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
if (empty($remise_percent)) {
@@ -864,6 +887,9 @@ if (empty($reshook)) {
}
$model = $object->model_pdf;
$ret = $object->fetch($id); // Reload to get new records
+ if ($ret > 0) {
+ $object->fetch_thirdparty();
+ }
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
@@ -917,7 +943,7 @@ if (empty($reshook)) {
}
}
} elseif ($action == 'updateline' && $usercancreate && GETPOST('save') == $langs->trans("Save")) {
- // Mise a jour d'une ligne dans la demande de prix
+ // Update a line within proposal
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
// Define info_bits
@@ -1403,7 +1429,7 @@ if ($action == 'create') {
/*
- * Combobox pour la fonction de copie
+ * Combobox for copy function
*/
if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
@@ -1425,7 +1451,7 @@ if ($action == 'create') {
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal p";
$sql .= ", ".MAIN_DB_PREFIX."societe s";
$sql .= " WHERE s.rowid = p.fk_soc";
- $sql .= " AND p.entity = ".$conf->entity;
+ $sql .= " AND p.entityy IN (".getEntity('supplier_proposal').")";
$sql .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
$sql .= " ORDER BY Id";
@@ -1435,8 +1461,8 @@ if ($action == 'create') {
$i = 0;
while ($i < $num) {
$row = $db->fetch_row($resql);
- $askPriceSupplierRefAndSocName = $row [1]." - ".$row [2];
- $liste_ask [$row [0]] = $askPriceSupplierRefAndSocName;
+ $askPriceSupplierRefAndSocName = $row[1]." - ".$row[2];
+ $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
$i++;
}
print $form->selectarray("copie_supplier_proposal", $liste_ask, 0);
@@ -1564,39 +1590,28 @@ if ($action == 'create') {
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', null, null, '', 1);
// Thirdparty
- $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'supplier');
+ $morehtmlref .= $object->thirdparty->getNomUrl(1, 'supplier');
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
$morehtmlref .= ' ( '.$langs->trans("OtherProposals").')';
}
// Project
- if (!empty($conf->project->enabled)) {
+ if (isModEnabled('project')) {
$langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
+ $morehtmlref .= ' ';
if ($usercancreate) {
+ $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- $morehtmlref .= ' '.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ $morehtmlref .= ' '.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, '');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
- $morehtmlref .= ' : '.$proj->getNomUrl(1);
+ $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
- $morehtmlref .= ' - '.$proj->title;
+ $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).'';
}
- } else {
- $morehtmlref .= '';
}
}
}
@@ -1610,7 +1625,7 @@ if ($action == 'create') {
print ' ';
print ' ';
- print ' ';
+ print '';
// Relative and absolute discounts
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php
index 1fa344cbb5e..8db19cfb2a7 100644
--- a/htdocs/supplier_proposal/contact.php
+++ b/htdocs/supplier_proposal/contact.php
@@ -132,15 +132,15 @@ if ($id > 0 || !empty($ref)) {
$morehtmlref = '';
// Ref supplier
- $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
+ //$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
+ //$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
- $morehtmlref .= ' '.$object->thirdparty->getNomUrl(1);
+ $morehtmlref .= $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->project->enabled)) {
$langs->load("projects");
$morehtmlref .= ' ';
- if ($permissiontoedit) {
+ if (0) {
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
$morehtmlref .= ' '.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php
index 7aacfb8f8b2..c1829fd61d6 100644
--- a/htdocs/supplier_proposal/document.php
+++ b/htdocs/supplier_proposal/document.php
@@ -77,6 +77,7 @@ if ($object->id > 0) {
}
$permissiontoadd = $user->rights->supplier_proposal->creer;
+$usercancreate = $permissiontoadd;
/*
* Actions
@@ -120,37 +121,25 @@ if ($object->id > 0) {
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
- $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+ $morehtmlref .= $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->project->enabled)) {
$langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->supplier_proposal->creer) {
+ $morehtmlref .= ' ';
+ if (0) {
+ $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- //$morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ $morehtmlref .= ' '.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, '');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
- $morehtmlref .= ' : '.$proj->getNomUrl(1);
+ $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
- } else {
- $morehtmlref .= '';
}
}
}
diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php
index d1f0daad639..0b2af861163 100644
--- a/htdocs/supplier_proposal/info.php
+++ b/htdocs/supplier_proposal/info.php
@@ -72,32 +72,22 @@ $morehtmlref = ' ';
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
-$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+$morehtmlref .= $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->project->enabled)) {
$langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->supplier_proposal->creer) {
+ $morehtmlref .= ' ';
+ if (0) {
+ $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- //$morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ $morehtmlref .= ' '.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, '');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
- $morehtmlref .= ' : '.$proj->getNomUrl(1);
+ $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php
index 5cb7cf69ef8..fd71dc26204 100644
--- a/htdocs/supplier_proposal/list.php
+++ b/htdocs/supplier_proposal/list.php
@@ -94,6 +94,7 @@ $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'a
$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
$search_status = GETPOST('search_status', 'int');
+$search_product_category = GETPOST('search_product_category', 'int');
$object_statut = $db->escape(GETPOST('supplier_proposal_statut'));
$search_btn = GETPOST('button_search', 'alpha');
@@ -216,8 +217,6 @@ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
-$search_product_category = 0;
-
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Do we click on purge search criteria ?
@@ -295,7 +294,7 @@ $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
llxHeader('', $title, $help_url);
$sql = 'SELECT';
-if ($sall || $search_product_category > 0 || $search_user > 0) {
+if ($sall || $search_user > 0) {
$sql = 'SELECT DISTINCT';
}
$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
@@ -327,12 +326,9 @@ $sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp';
if (isset($extrafields->attributes[$object->table_element]['label']) && 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 (sp.rowid = ef.fk_object)";
}
-if ($sall || $search_product_category > 0) {
+if ($sall) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal';
}
-if ($search_product_category > 0) {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
-}
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid';
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet";
// We'll need this table joined to the select in order to filter by sale
@@ -426,6 +422,36 @@ if ($search_sale > 0) {
if ($search_user > 0) {
$sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".((int) $search_user);
}
+// Search for tag/category ($searchCategoryProductList is an array of ID)
+$searchCategoryProductOperator = -1;
+$searchCategoryProductList = array($search_product_category);
+if (!empty($searchCategoryProductList)) {
+ $searchCategoryProductSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryProductList as $searchCategoryProduct) {
+ if (intval($searchCategoryProduct) == -2) {
+ $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product)";
+ } elseif (intval($searchCategoryProduct) > 0) {
+ if ($searchCategoryProductOperator == 0) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ }
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."supplier_proposaldet as sd WHERE sd.fk_supplier_proposal = sp.rowid AND sd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryProductOperator == 1) {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryProductSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
+ }
+ }
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@@ -1121,7 +1147,7 @@ if ($resql) {
$userstatic->id = $obj->fk_user_author;
$userstatic->login = $obj->login;
- $userstatic->status = $obj->status;
+ $userstatic->status = $obj->ustatus;
$userstatic->lastname = $obj->name;
$userstatic->firstname = $obj->firstname;
$userstatic->photo = $obj->photo;
@@ -1201,6 +1227,17 @@ if ($resql) {
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+ // If no record found
+ if ($num == 0) {
+ $colspan = 1;
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
+ print ' | '.$langs->trans("NoRecordFound").' | ';
+ }
+
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php
index 118855cecf3..aa0ccc5276a 100644
--- a/htdocs/supplier_proposal/note.php
+++ b/htdocs/supplier_proposal/note.php
@@ -21,9 +21,9 @@
*/
/**
- * \file htdocs/comm/propal/note.php
+ * \file htdocs/supplier_proposal/note.php
* \ingroup propal
- * \brief Fiche d'information sur une proposition commerciale
+ * \brief Page to show notes of a supplier proposal request
*/
// Load Dolibarr environment
@@ -53,6 +53,8 @@ $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal');
$object = new SupplierProposal($db);
+$usercancreate = $user->hasRight("supplier_propal", "write");
+
/*
@@ -104,37 +106,25 @@ if ($id > 0 || !empty($ref)) {
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
- $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+ $morehtmlref .= $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->project->enabled)) {
$langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->supplier_proposal->creer) {
+ $morehtmlref .= ' ';
+ if ($usercancreate) {
+ $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
- //$morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ $morehtmlref .= ' '.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, '');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
- $morehtmlref .= ' : '.$proj->getNomUrl(1);
+ $morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
- } else {
- $morehtmlref .= '';
}
}
}
diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php
index 52965da8182..7e94af1a431 100644
--- a/htdocs/ticket/stats/index.php
+++ b/htdocs/ticket/stats/index.php
@@ -45,7 +45,7 @@ if ($user->socid > 0) {
$socid = $user->socid;
}
-$nowyear = strftime("%Y", dol_now());
+$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
$endyear = $year;
diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php
index c48eda2312e..44ab46193d9 100644
--- a/htdocs/user/hierarchy.php
+++ b/htdocs/user/hierarchy.php
@@ -4,7 +4,7 @@
* Copyright (C) 2006-2015 Laurent Destailleur
* Copyright (C) 2007 Patrick Raguin
* Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2019-2021 Frédéric France
+ * Copyright (C) 2019-2021 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
// Load translation files required by page
-$langs->loadLangs(array('users', 'companies'));
+$langs->loadLangs(array('users', 'companies', 'hrm', 'salaries'));
// Security check (for external users)
$socid = 0;
@@ -40,16 +40,15 @@ if ($user->socid > 0) {
}
$optioncss = GETPOST('optioncss', 'alpha');
-$contextpage = GETPOST('optioncss', 'aZ09');
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search
+$mode = GETPOST("mode", 'alpha');
+
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-// Load mode employee
-$mode = GETPOST("mode", 'alpha');
$search_statut = GETPOST('search_statut', 'int');
-
if ($search_statut == '' || $search_statut == '0') {
$search_statut = '1';
}
@@ -58,18 +57,30 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_statut = "";
}
+if ($contextpage == 'employeelist') {
+ $search_employee = 1;
+}
+
$userstatic = new User($db);
// Define value to know what current user can do on users
$canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
-if (!$user->hasRight("user", "user", "read") && !$user->admin) {
- accessforbidden();
+// Permission to list
+if ($contextpage == 'employeelist' && $search_employee == 1) {
+ if (!$user->hasRight("salaries", "read")) {
+ accessforbidden();
+ }
+} else {
+ if (!$user->hasRight("user", "user", "read") && empty($user->admin)) {
+ accessforbidden();
+ }
}
$childids = $user->getAllChildIds(1);
+
/*
* View
*/
@@ -77,7 +88,11 @@ $childids = $user->getAllChildIds(1);
$form = new Form($db);
$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios|DE:Modul_Benutzer';
-$title = $langs->trans("Users");
+if ($contextpage == 'employeelist' && $search_employee == 1) {
+ $title = $langs->trans("Employees");
+} else {
+ $title = $langs->trans("Users");
+}
$arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js',
@@ -152,6 +167,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) {
//var_dump($data);
$param = "&search_statut=".urlencode($search_statut);
+ $param = "&contextpage=".urlencode($contextpage);
$newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
diff --git a/htdocs/user/list.php b/htdocs/user/list.php
index 05d2f88c035..c5681326817 100644
--- a/htdocs/user/list.php
+++ b/htdocs/user/list.php
@@ -41,9 +41,10 @@ $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
-$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
+$mode = GETPOST("mode", 'alpha');
// Security check (for external users)
$socid = 0;
@@ -51,9 +52,6 @@ if ($user->socid > 0) {
$socid = $user->socid;
}
-// Load mode employee
-$mode = GETPOST("mode", 'alpha');
-
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@@ -125,7 +123,7 @@ $arrayfields = array(
'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20),
'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22),
- 'u.employee'=>array('label'=>"Employee", 'checked'=>($mode == 'employee' ? 1 : 0), 'position'=>25),
+ 'u.employee'=>array('label'=>"Employee", 'checked'=>($contextpage == 'employeelist' ? 1 : 0), 'position'=>25),
'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27),
'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30),
'u.office_phone'=>array('label'=>"PhonePro", 'checked'=>1, 'position'=>31),
@@ -164,6 +162,17 @@ $search_thirdparty = GETPOST('search_thirdparty', 'alpha');
$search_warehouse = GETPOST('search_warehouse', 'alpha');
$search_supervisor = GETPOST('search_supervisor', 'intcomma');
$search_categ = GETPOST("search_categ", 'int');
+$searchCategoryUserOperator = 0;
+if (GETPOSTISSET('formfilteraction')) {
+ $searchCategoryUserOperator = GETPOSTINT('search_category_user_operator');
+} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
+ $searchCategoryUserOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
+}
+$searchCategoryUserList = GETPOST('search_category_user_list', 'array');
+$catid = GETPOST('catid', 'int');
+if (!empty($catid) && empty($searchCategoryUserList)) {
+ $searchCategoryUserList = array($catid);
+}
$catid = GETPOST('catid', 'int');
if (!empty($catid) && empty($search_categ)) {
$search_categ = $catid;
@@ -173,7 +182,7 @@ if (!empty($catid) && empty($search_categ)) {
if ($search_statut == '') {
$search_statut = '1';
}
-if ($mode == 'employee' && !GETPOSTISSET('search_employee')) {
+if ($contextpage == 'employeelist' && !GETPOSTISSET('search_employee')) {
$search_employee = 1;
}
@@ -192,7 +201,7 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
$error = 0;
// Permission to list
-if ($mode == 'employee') {
+if ($contextpage == 'employeelist' && $search_employee == 1) {
if (!$user->hasRight("salaries", "read")) {
accessforbidden();
}
@@ -427,36 +436,39 @@ if ($search_statut != '' && $search_statut >= 0) {
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
-
-// Search for tag/category ($searchCategoryProductList is an array of ID)
-$searchCategoryProductList = array($search_categ);
-if (!empty($searchCategoryProductList)) {
- $searchCategoryProductSqlList = array();
+// Search for tag/category ($searchCategoryUserList is an array of ID)
+$searchCategoryUserList = array($search_categ);
+if (!empty($searchCategoryUserList)) {
+ $searchCategoryUserSqlList = array();
$listofcategoryid = '';
- foreach ($searchCategoryProductList as $searchCategoryProduct) {
- if (intval($searchCategoryProduct) == -2) {
- $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)";
- } elseif (intval($searchCategoryProduct) > 0) {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
+ foreach ($searchCategoryUserList as $searchCategoryUser) {
+ if (intval($searchCategoryUser) == -2) {
+ $searchCategoryUserSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)";
+ } elseif (intval($searchCategoryUser) > 0) {
+ if ($searchCategoryUserOperator == 0) {
+ $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie = ".((int) $searchCategoryUser).")";
+ } else {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryUser);
+ }
}
}
if ($listofcategoryid) {
- $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
}
- if ($searchCategoryProductOperator == 1) {
- if (!empty($searchCategoryProductSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
+ if ($searchCategoryUserOperator == 1) {
+ if (!empty($searchCategoryUserSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryUserSqlList).")";
}
} else {
- if (!empty($searchCategoryProductSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
+ if (!empty($searchCategoryUserSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryUserSqlList).")";
}
}
}
if ($search_warehouse > 0) {
$sql .= " AND u.fk_warehouse = ".((int) $search_warehouse);
}
-if ($mode == 'employee' && !$user->hasRight("salaries", "readall")) {
+if ($contextpage == 'employeelist' && !$user->hasRight("salaries", "readall")) {
$sql .= " AND u.rowid IN (".$db->sanitize(join(',', $childids)).")";
}
// Add where from extra fields
@@ -523,7 +535,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
// Output page
// --------------------------------------------------------------------
-$title = $langs->trans("ListOfUsers");
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
@@ -626,7 +637,7 @@ print '';
print '';
print '';
-$url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu=';
+$url = DOL_URL_ROOT.'/user/card.php?action=create'.($contextpage == 'employeelist' ? '&search_employee=1' : '').'&leftmenu=';
if (!empty($socid)) {
$url .= '&socid='.urlencode($socid);
}
diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php
index a8a4363ba5c..d7793c3ced1 100755
--- a/scripts/accountancy/export-thirdpartyaccount.php
+++ b/scripts/accountancy/export-thirdpartyaccount.php
@@ -45,7 +45,7 @@ if (!$user->admin) {
// Date range
$year = GETPOST("year");
if (empty($year)) {
- $year_current = strftime("%Y", dol_now());
+ $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$month_current = strftime("%m", dol_now());
$year_start = $year_current;
} else {
diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php
index ee866203665..630ae8c9948 100755
--- a/scripts/cron/cron_run_jobs.php
+++ b/scripts/cron/cron_run_jobs.php
@@ -92,7 +92,7 @@ $hookmanager->initHooks(array('cli'));
$now = dol_now();
@set_time_limit(0);
-print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=".$userlogin." ***** ".dol_print_date($now, 'dayhourrfc')." *****\n";
+print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - userlogin=".$userlogin." - ".dol_print_date($now, 'dayhourrfc')." *****\n";
// Check module cron is activated
if (empty($conf->cron->enabled)) {
@@ -164,6 +164,10 @@ $user->getrights();
if (isset($argv[3]) && $argv[3]) {
$id = $argv[3];
}
+$forcequalified = 0;
+if (isset($argv[4]) && $argv[4] == '--force') {
+ $forcequalified = 1;
+}
// create a jobs object
$object = new Cronjob($db);
@@ -246,7 +250,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
}
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
- if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) {
+ if ($forcequalified || (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now))) {
echo " - qualified";
dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
@@ -313,7 +317,7 @@ exit(0);
*/
function usage($path, $script_file)
{
- print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid]\n";
+ print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid] [--force]\n";
print "The script return 0 when everything worked successfully.\n";
print "\n";
print "On Linux system, you can have cron jobs ran automatically by adding an entry into cron.\n";
@@ -321,4 +325,6 @@ function usage($path, $script_file)
print "30 3 * * * ".$path.$script_file." securitykey userlogin > ".DOL_DATA_ROOT."/".$script_file.".log\n";
print "For example, to run pending tasks every 5mn, you can add this line:\n";
print "*/5 * * * * ".$path.$script_file." securitykey userlogin > ".DOL_DATA_ROOT."/".$script_file.".log\n";
+ print "\n";
+ print "The option --force allow to bypass the check on date of execution so job will be executed even if date is not yet reached.\n";
}
diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php
index 317d486434e..6649aa19798 100644
--- a/test/phpunit/AdminLibTest.php
+++ b/test/phpunit/AdminLibTest.php
@@ -165,6 +165,9 @@ class AdminLibTest extends PHPUnit\Framework\TestCase
require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php';
print "Enable module modExpenseReport";
$moduledescriptor=new modExpenseReport($db);
+
+ $result = $moduledescriptor->remove();
+
$result = $moduledescriptor->init();
print __METHOD__." result=".$result."\n";
$this->assertEquals(1, $result);
@@ -173,6 +176,9 @@ class AdminLibTest extends PHPUnit\Framework\TestCase
require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php';
print "Enable module modAPI";
$moduledescriptor=new modApi($db);
+
+ $result = $moduledescriptor->remove();
+
$result = $moduledescriptor->init();
print __METHOD__." result=".$result."\n";
$this->assertEquals(1, $result);
|