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

This commit is contained in:
Laurent Destailleur 2023-03-10 12:58:48 +01:00
commit 1b0c875dcb
6 changed files with 2962 additions and 2577 deletions

View File

@ -0,0 +1,69 @@
<?php
/* Copyright (C) 2022 Florian HENRY <florian.henry@scopen.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/ajax/ajaxinvoiceline.php
* \brief File to load contacts combobox
*/
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
$invoice_id = GETPOST('id', 'int'); // id of thirdparty
$action = GETPOST('action', 'aZ09');
$htmlname = GETPOST('htmlname', 'alpha');
// Security check
restrictedArea($user, 'facture', $invoice_id, '', '', 'fk_soc', 'rowid');
/*
* View
*/
top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($invoice_id) && !empty($action) && !empty($htmlname)) {
$formProject = new FormProjets($db);
$return = array();
if (empty($showempty)) {
$showempty = 0;
}
$return['value'] = $formProject->selectInvoiceAndLine($invoice_id, 0, 'invoiceid', 'invoicelineid', 'maxwidth500', array(), 1);
//$return['num'] = $form->num;
//$return['error'] = $form->error;
echo json_encode($return);
}

View File

@ -903,6 +903,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return combo list of activated countries, into language of user * Return combo list of activated countries, into language of user
* *
@ -1038,6 +1039,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return select list of incoterms * Return select list of incoterms
* *
@ -1126,6 +1128,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of types of lines (product or service) * Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module) * Example: 0=product, 1=service, 9=other (for external module)
@ -1187,6 +1190,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load into cache cache_types_fees, array of types of fees * Load into cache cache_types_fees, array of types of fees
* *
@ -1234,6 +1238,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of types of notes * Return list of types of notes
* *
@ -1278,6 +1283,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output html form to select a third party * Output html form to select a third party
* *
@ -1350,6 +1356,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output html form to select a third party. * Output html form to select a third party.
* Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company. * Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company.
@ -1579,6 +1586,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return HTML combo list of absolute discounts * Return HTML combo list of absolute discounts
* *
@ -1665,6 +1673,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of all contacts (for a third party or all) * Return list of all contacts (for a third party or all)
* *
@ -1915,6 +1924,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return the HTML select list of users * Return the HTML select list of users
* *
@ -1937,6 +1947,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return select list of users * Return select list of users
* *
@ -2090,7 +2101,8 @@ class Form
$disableline = ($enableonlytext ? $enableonlytext : '1'); $disableline = ($enableonlytext ? $enableonlytext : '1');
} }
$labeltoshow = ''; $labeltoshowhtml = ''; $labeltoshow = '';
$labeltoshowhtml = '';
// $fullNameMode is 0=Lastname+Firstname (MAIN_FIRSTNAME_NAME_POSITION=1), 1=Firstname+Lastname (MAIN_FIRSTNAME_NAME_POSITION=0) // $fullNameMode is 0=Lastname+Firstname (MAIN_FIRSTNAME_NAME_POSITION=1), 1=Firstname+Lastname (MAIN_FIRSTNAME_NAME_POSITION=0)
$fullNameMode = 0; $fullNameMode = 0;
@ -2105,7 +2117,8 @@ class Form
} }
// Complete name with a more info string like: ' (info1 - info2 - ...)' // Complete name with a more info string like: ' (info1 - info2 - ...)'
$moreinfo = ''; $moreinfohtml = ''; $moreinfo = '';
$moreinfohtml = '';
if (!empty($conf->global->MAIN_SHOW_LOGIN)) { if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
$moreinfo .= ($moreinfo ? ' - ' : ' ('); $moreinfo .= ($moreinfo ? ' - ' : ' (');
$moreinfohtml .= ($moreinfohtml ? ' - ' : ' <span class="opacitymedium">('); $moreinfohtml .= ($moreinfohtml ? ' - ' : ' <span class="opacitymedium">(');
@ -2192,6 +2205,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return select list of users. Selected users are stored into session. * Return select list of users. Selected users are stored into session.
* List of users are provided into $_SESSION['assignedtouser']. * List of users are provided into $_SESSION['assignedtouser'].
@ -2288,6 +2302,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of products for customer in Ajax if Ajax activated or go to select_produits_list * Return list of products for customer in Ajax if Ajax activated or go to select_produits_list
* *
@ -2525,6 +2540,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of products for a customer. * Return list of products for a customer.
* Called by select_produits. * Called by select_produits.
@ -3216,6 +3232,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list)
* *
@ -3262,6 +3279,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of suppliers products * Return list of suppliers products
* *
@ -3691,6 +3709,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of suppliers prices for a product * Return list of suppliers prices for a product
* *
@ -3800,6 +3819,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of delivery address * Return list of delivery address
* *
@ -3848,6 +3868,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load into cache list of payment terms * Load into cache list of payment terms
* *
@ -3896,6 +3917,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load int a cache property th elist of possible delivery delays. * Load int a cache property th elist of possible delivery delays.
* *
@ -4076,6 +4098,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Charge dans cache la liste des types de paiements possibles * Charge dans cache la liste des types de paiements possibles
* *
@ -4127,6 +4150,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* print list of payment modes. * print list of payment modes.
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
@ -4243,6 +4267,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of payment methods * Return list of payment methods
* Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want.
@ -4385,6 +4410,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load in cache list of transport mode * Load in cache list of transport mode
* *
@ -4700,6 +4726,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return a HTML select list of bank accounts * Return a HTML select list of bank accounts
* *
@ -4893,6 +4920,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of categories having choosed type * Return list of categories having choosed type
* *
@ -4987,6 +5015,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a confirmation HTML form or AJAX popup * Show a confirmation HTML form or AJAX popup
* *
@ -5431,6 +5460,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a form to select a project * Show a form to select a project
* *
@ -5486,6 +5516,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a form to select payment conditions * Show a form to select payment conditions
* *
@ -5546,6 +5577,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a form to select a delivery delay * Show a form to select a delivery delay
* *
@ -5613,6 +5645,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a form + html select a date * Show a form + html select a date
* *
@ -5662,6 +5695,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a select form to choose a user * Show a select form to choose a user
* *
@ -5698,6 +5732,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show form with payment mode * Show form with payment mode
* *
@ -5775,6 +5810,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show form with multicurrency code * Show form with multicurrency code
* *
@ -5801,6 +5837,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show form with multicurrency rate * Show form with multicurrency rate
* *
@ -5840,6 +5877,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a select box with available absolute discounts * Show a select box with available absolute discounts
* *
@ -5941,6 +5979,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show forms to select a contact * Show forms to select a contact
* *
@ -5983,6 +6022,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output html select to select thirdparty * Output html select to select thirdparty
* *
@ -6033,6 +6073,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Retourne la liste des devises, dans la langue de l'utilisateur * Retourne la liste des devises, dans la langue de l'utilisateur
* *
@ -6167,6 +6208,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load into the cache vat rates of a country * Load into the cache vat rates of a country
* *
@ -6237,6 +6279,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output an HTML select vat rate. * Output an HTML select vat rate.
* The name of this function should be selectVat. We keep bad name for compatibility purpose. * The name of this function should be selectVat. We keep bad name for compatibility purpose.
@ -6435,6 +6478,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes.
* Fields are preselected with : * Fields are preselected with :
@ -6991,6 +7035,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to show a form to select a duration on a page * Function to show a form to select a duration on a page
* *
@ -8913,7 +8958,8 @@ class Form
'perms' => 1, 'perms' => 1,
'label' => 'LinkToContract', 'label' => 'LinkToContract',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht
FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier'), FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "contrat as t, " . $this->db->prefix() . "contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('contract') . ') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier'
),
'fichinter' => array( 'fichinter' => array(
'enabled' => isModEnabled('ficheinter'), 'enabled' => isModEnabled('ficheinter'),
'perms' => 1, 'perms' => 1,
@ -9143,6 +9189,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of export templates * Return list of export templates
* *
@ -9643,6 +9690,7 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return select list of groups * Return select list of groups
* *
@ -10032,7 +10080,7 @@ class Form
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
* @param string $showproject 'all' = Show project info, ''=Hide project info * @param string $showproject 'all' = Show project info, ''=Hide project info
* @param User $usertofilter User object to use for filtering * @param User $usertofilter User object to use for filtering
* @return int Nbr of project if OK, <0 if KO * @return string HTML Select Invoice
*/ */
public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
{ {
@ -10159,13 +10207,12 @@ class Form
$out .= '</select>'; $out .= '</select>';
} }
print $out; return $out;
$this->db->free($resql); $this->db->free($resql);
return $num;
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return '';
} }
} }

View File

@ -56,6 +56,7 @@ class FormProjets
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output a combo list with projects qualified for a third party / user * Output a combo list with projects qualified for a third party / user
* *
@ -124,6 +125,7 @@ class FormProjets
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Returns an array with projects qualified for a third party * Returns an array with projects qualified for a third party
* *
@ -508,6 +510,7 @@ class FormProjets
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Build a HTML select list of element of same thirdparty to suggest to link them to project * Build a HTML select list of element of same thirdparty to suggest to link them to project
* *
@ -748,4 +751,130 @@ class FormProjets
return -1; return -1;
} }
} }
/**
* Output a combo list with invoices and lines qualified for a project
*
* @param int $selectedInvoiceId Id invoice preselected
* @param int $selectedLineId Id invoice line preselected
* @param string $htmlNameInvoice Name of HTML select for Invoice
* @param int $htmlNameInvoiceLine Name of HTML select for Invoice Line
* @param string $morecss More css added to the select component
* @param array $filters Array of filters
* @param int $lineOnly return only option for line
* @return string HTML Select
*/
public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoice = 'invoiceid', $htmlNameInvoiceLine = 'invoicelineid', $morecss = 'maxwidth500', $filters = array(), $lineOnly = 0)
{
global $user, $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$out = '';
if (empty($lineOnly)) {
// Search Invoice
$sql = "SELECT f.rowid, f.ref as fref,";
$sql .= ' s.nom as name';
$sql .= ' FROM ' . $this->db->prefix() . 'projet as p';
$sql .= ' INNER JOIN ' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc';
$sql .= ' INNER JOIN ' . $this->db->prefix() . 'facture as f ON f.fk_projet = p.rowid';
$sql .= " WHERE p.entity IN (" . getEntity('project') . ")";
if (!empty($filters)) {
foreach ($filters as $key => $value) {
if ($key == 'p.rowid') {
$sql .= " AND p.rowid=" . (int) $value;
}
if ($key == 'f.rowid') {
$sql .= " AND f.rowid=" . (int) $value;
}
}
}
$sql .= " ORDER BY p.ref, f.ref ASC";
$resql = $this->db->query($sql);
if ($resql) {
// Use select2 selector
if (!empty($conf->use_javascript_ajax)) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlNameInvoice, array(array('method'=>'getLines', 'url'=>dol_buildpath('/core/ajax/ajaxinvoiceline.php', 1), 'htmlname'=>$htmlNameInvoiceLine)), 0, 0);
$out .= $comboenhancement;
$morecss = 'minwidth200imp maxwidth500';
}
$out .= '<select class="valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlNameInvoice . '" name="' . $htmlNameInvoice . '">';
$num = $this->db->num_rows($resql);
if ($num) {
while ($obj = $this->db->fetch_object($resql)) {
$labeltoshow = $obj->fref; // Invoice ref
if ($obj->name) {
$labeltoshow .= ' - ' . $obj->name;
}
$out .= '<option value="' . $obj->rowid . '" ';
if (!empty($selectedInvoiceId) && $selectedInvoiceId == $obj->rowid) {
$out .= ' selected ';
}
$out .= '>' . $labeltoshow . '</option>';
}
}
$out .= '</select>';
} else {
dol_print_error($this->db->lasterror);
return '';
}
}
// Search Invoice Line
$sql = "SELECT fd.rowid, fd.label, fd.description";
$sql .= ' FROM ' . $this->db->prefix() . 'projet as p';
$sql .= ' INNER JOIN ' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc';
$sql .= ' INNER JOIN ' . $this->db->prefix() . 'facture as f ON f.fk_projet = p.rowid';
$sql .= ' INNER JOIN ' . $this->db->prefix() . 'facturedet as fd ON fd.fk_facture = f.rowid';
$sql .= " WHERE p.entity IN (" . getEntity('project') . ")";
if (!empty($filters)) {
foreach ($filters as $key => $value) {
if ($key == 'p.rowid') {
$sql .= " AND p.rowid=" . (int) $value;
}
}
}
if (!empty($selectedInvoiceId)) {
$sql .= " AND f.rowid=" . (int) $selectedInvoiceId;
}
$sql .= " ORDER BY p.ref, f.ref ASC";
$resql = $this->db->query($sql);
if ($resql) {
// Use select2 selector
if (empty($lineOnly)) {
if (!empty($conf->use_javascript_ajax)) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlNameInvoiceLine, '', 0, 0);
$out .= $comboenhancement;
$morecss = 'minwidth200imp maxwidth500';
}
$out .= '<select class="valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlNameInvoiceLine . '" name="' . $htmlNameInvoiceLine . '">';
}
$num = $this->db->num_rows($resql);
if ($num) {
while ($obj = $this->db->fetch_object($resql)) {
$labeltoshow .= $obj->description; // Invoice ref
$out .= '<option value="' . $obj->rowid . '" ';
if (!empty($selectedLineId) && $selectedLineId == $obj->rowid) {
$out .= ' selected ';
}
$out .= '>' . $labeltoshow . '</option>';
}
}
if (empty($lineOnly)) {
$out .= '</select>';
}
} else {
dol_print_error($this->db->lasterror);
return '';
}
return $out;
}
} }

View File

@ -128,6 +128,8 @@ class Task extends CommonObjectLine
public $timespent_thm; public $timespent_thm;
public $timespent_note; public $timespent_note;
public $timespent_fk_product; public $timespent_fk_product;
public $timespent_invoiceid;
public $timespent_invoicelineid;
public $comments = array(); public $comments = array();
@ -1736,6 +1738,8 @@ class Task extends CommonObjectLine
$sql .= " task_duration = ".((int) $this->timespent_duration).","; $sql .= " task_duration = ".((int) $this->timespent_duration).",";
$sql .= " fk_user = ".((int) $this->timespent_fk_user).","; $sql .= " fk_user = ".((int) $this->timespent_fk_user).",";
$sql .= " fk_product = ".((int) $this->timespent_fk_product).","; $sql .= " fk_product = ".((int) $this->timespent_fk_product).",";
$sql .= " invoice_id = ".((int) $this->timespent_invoiceid).",";
$sql .= " invoice_line_id = ".((int) $this->timespent_invoicelineid).",";
$sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); $sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null");
$sql .= " WHERE rowid = ".((int) $this->timespent_id); $sql .= " WHERE rowid = ".((int) $this->timespent_id);

View File

@ -309,6 +309,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
} }
$object->timespent_fk_user = GETPOST("userid_line", 'int'); $object->timespent_fk_user = GETPOST("userid_line", 'int');
$object->timespent_fk_product = GETPOST("fk_product", 'int'); $object->timespent_fk_product = GETPOST("fk_product", 'int');
$object->timespent_invoiceid = GETPOST("invoiceid", 'int');
$object->timespent_invoicelineid = GETPOST("invoicelineid", 'int');
$result = 0; $result = 0;
if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) { if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
@ -336,8 +338,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
} }
$object->timespent_fk_user = GETPOST("userid_line", 'int'); $object->timespent_fk_user = GETPOST("userid_line", 'int');
$object->timespent_fk_product = GETPOST("fk_product", 'int'); $object->timespent_fk_product = GETPOST("fk_product", 'int');
$object->timespent_invoiceid = GETPOST("invoiceid", 'int');
$object->timespent_invoicelineid = GETPOST("invoicelineid", 'int');
$result = 0; $result = 0;
if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) { if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
$result = $object->updateTimeSpent($user); $result = $object->updateTimeSpent($user);
@ -1468,7 +1472,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print $langs->trans('InvoiceToUse'); print $langs->trans('InvoiceToUse');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
/*print '<tr>'; /*print '<tr>';
@ -1553,6 +1557,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
$sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut,";
$sql .= " p.fk_soc,s.name_alias,"; $sql .= " p.fk_soc,s.name_alias,";
$sql .= " t.invoice_line_id";
// Add fields from hooks // Add fields from hooks
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
@ -2344,7 +2349,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($task_time->invoice_id) { if ($task_time->invoice_id) {
$result = $tmpinvoice->fetch($task_time->invoice_id); $result = $tmpinvoice->fetch($task_time->invoice_id);
if ($result > 0) { if ($result > 0) {
if ($action=='editline' && $_GET['lineid'] == $task_time->rowid) {
print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id, 'invoiceid', 'invoicelineid', 'maxwidth500', array('p.rowid'=>$projectstatic->id));
} else {
print $tmpinvoice->getNomUrl(1); print $tmpinvoice->getNomUrl(1);
if (!empty($task_time->invoice_line_id)) {
$invoiceLine = new FactureLigne($db);
$invoiceLine->fetch($task_time->invoice_line_id);
if (!empty($invoiceLine->id)) {
print '<br>'.$langs->trans('Qty').':'.$invoiceLine->qty;
print ' '.$langs->trans('TotalHT').':'.price($invoiceLine->total_ht);
}
}
}
} }
} else { } else {
print $langs->trans("No"); print $langs->trans("No");

View File

@ -255,12 +255,18 @@ if ($object->id > 0) {
print '/'; print '/';
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("None")."</a>"; print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&&token='.newToken().'&entity='.$entity.'&module=allmodules&confirm=yes">'.$langs->trans("None")."</a>";
print '</td>'; print '</td>';
} else {
print '<td></td>';
} }
print '<td class="center" width="24">&nbsp;</td>'; print '<td class="center" width="24"></td>';
print '<td>'.$langs->trans("Permissions").'</td>'; //print '<td>'.$langs->trans("Permissions").'</td>';
if ($user->admin) { print '<td class="center"></td>';
print '<td class="right"></td>';
} print '<td class="right nowrap">';
print '<a class="showallperms" title="'.dol_escape_htmltag($langs->trans("ShowAllPerms")).'" alt="'.dol_escape_htmltag($langs->trans("ShowAllPerms")).'" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("ExpandAll").'</span></a>';
print ' | ';
print '<a class="hideallperms" title="'.dol_escape_htmltag($langs->trans("HideAllPerms")).'" alt="'.dol_escape_htmltag($langs->trans("HideAllPerms")).'" href="#">'.img_picto('', 'folder', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("UndoExpandAll").'</span></a>';
print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault"; $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
@ -275,9 +281,12 @@ if ($object->id > 0) {
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;$j = 0;
$oldmod = ''; $oldmod = '';
$cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));
$cookietohidegrouparray = explode(',', $cookietohidegroup);
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -289,48 +298,78 @@ if ($object->id > 0) {
$objMod = $modules[$obj->module]; $objMod = $modules[$obj->module];
if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');
} elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
$ishidden = 1;
} else {
$ishidden = 0;
}
$isexpanded = ! $ishidden;
// Break found, it's a new module to catch // Break found, it's a new module to catch
if (isset($obj->module) && ($oldmod <> $obj->module)) { if (isset($obj->module) && ($oldmod <> $obj->module)) {
$oldmod = $obj->module; $oldmod = $obj->module;
$j++;
if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');
} elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
$ishidden = 1;
} else {
$ishidden = 0;
}
$isexpanded = ! $ishidden;
// Break detected, we get objMod // Break detected, we get objMod
$objMod = $modules[$obj->module]; $objMod = $modules[$obj->module];
$picto = ($objMod->picto ? $objMod->picto : 'generic'); $picto = ($objMod->picto ? $objMod->picto : 'generic');
// Show break line // Show break line
print '<tr class="oddeven trforbreak">'; print '<tr class="oddeven trforbreakperms" data-hide-perms="'.$obj->module.'" data-j="'.$j.'">';
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'; // Picto and label of module
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone tdforbreakperms" data-hide-perms="'.$obj->module.'">';
print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a>'; print '<a name="'.$objMod->getName().'"></a>';
print '</td>'; print '</td>';
// Permission and tick (2 columns)
if ($caneditperms) { if ($caneditperms) {
print '<td class="center nowrap">'; print '<td class="center wraponsmartphone">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.$langs->trans("All").'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("All")."</a>"; print '<span class="permtohide_'.$obj->module.'" '.(!$isexpanded ? ' style="display:none"' : '').'>';
print '<a class="reposition alink addexpandedmodulesinparamlist" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All")."</a>";
print ' / '; print ' / ';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.$langs->trans("None").'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'&token='.newToken().'">'.$langs->trans("None")."</a>"; print '<a class="reposition alink addexpandedmodulesinparamlist" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")."</a>";
print '</span>';
print '</td>';
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'">';
print '</td>'; print '</td>';
} else { } else {
print '<td>&nbsp;</td>'; print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
} }
print '<td>&nbsp;</td>'; // Description of permission (2 columns)
print '<td>&nbsp;</td>'; print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
print '<td class="maxwidthonsmartphone right tdforbreakperms" data-hide-perms="'.$obj->module.'">';
// Permission id print '<div class="switchfolderperms folderperms_'.$obj->module.'"'.($isexpanded ? ' style="display:none;"' : '').'>';
if ($user->admin) { print img_picto('', 'folder', 'class="marginright"');
print '<td class="right"></td>'; print '</div>';
} print '<div class="switchfolderperms folderopenperms_'.$obj->module.'"'.(!$isexpanded ? ' style="display:none;"' : '').'>';
print img_picto('', 'folder-open', 'class="marginright"');
print '</div>';
print '</td>'; //Add picto + / - when open en closed
print '</tr>'."\n"; print '</tr>'."\n";
} }
print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n"; print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n";
print '<tr class="oddeven">'; print '<tr class="oddeven trtohide_'.$obj->module.'"'.(!$isexpanded ? ' style="display:none"' : '').'>';
// Picto and label of module // Picto and label of module
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'; print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
print '<input type="hidden" name="forbreakperms_'.$obj->module.'" id="idforbreakperms_'.$obj->module.'" css="cssforfieldishiden" data-j="'.$j.'" value="'.($isexpanded ? '0' : "1").'">';
//print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName(); //print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();
print '</td>'; print '</td>';
// Permission and tick (2 columns)
if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) { if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {
if (in_array($obj->id, $permsgroupbyentity[$entity])) { if (in_array($obj->id, $permsgroupbyentity[$entity])) {
// Own permission by group // Own permission by group
@ -360,11 +399,13 @@ if ($object->id > 0) {
//print img_edit_add($langs->trans("Add")); //print img_edit_add($langs->trans("Add"));
print img_picto($langs->trans("Add"), 'switch_off'); print img_picto($langs->trans("Add"), 'switch_off');
print '</a></td>'; print '</a></td>';
} else {
print '<td>&nbsp;</td>';
} }
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
// Description of permission // Description of permission (2 columns)
$permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); $permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
print '<td>'; print '<td>';
print $permlabel; print $permlabel;
@ -383,6 +424,8 @@ if ($object->id > 0) {
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext);
//print '<span class="opacitymedium">'.$obj->id.'</span>'; //print '<span class="opacitymedium">'.$obj->id.'</span>';
print '</td>'; print '</td>';
} else {
print '<td>&nbsp;</td>';
} }
print '</tr>'."\n"; print '</tr>'."\n";
@ -393,6 +436,82 @@ if ($object->id > 0) {
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<script>';
print '$(".tdforbreakperms:not(.alink)").on("click", function(){
console.log("Click on tdforbreakperms");
moduletohide = $(this).data("hide-perms");
j = $(this).data("j");
if ($("#idforbreakperms_"+moduletohide).val() == 1) {
console.log("idforbreakperms_"+moduletohide+" has value hidden=1");
$(".trtohide_"+moduletohide).show();
$(".permtoshow_"+moduletohide).hide();
$(".permtohide_"+moduletohide).show();
$(".folderperms_"+moduletohide).hide();
$(".folderopenperms_"+moduletohide).show();
$("#idforbreakperms_"+moduletohide).val("0");
} else {
console.log("idforbreakperms_"+moduletohide+" has value hidden=0");
$(".trtohide_"+moduletohide).hide();
$(".folderopenperms_"+moduletohide).hide();
$(".folderperms_"+moduletohide).show();
$(".permtoshow_"+moduletohide).show();
$(".permtohide_"+moduletohide).hide();
$("#idforbreakperms_"+moduletohide).val("1");
}
// Now rebuild the value for cookie
var hideuserperm="";
$(".trforbreakperms").each(function(index) {
//console.log( index + ": " + $( this ).data("j") + " " + $( this ).data("hide-perms") + " " + $("input[data-j="+(index+1)+"]").val());
if ($("input[data-j="+(index+1)+"]").val() == 1) {
hideuserperm=hideuserperm+","+(index+1);
}
});
// set cookie by js
date = new Date(); date.setTime(date.getTime()+(30*86400000));
if (hideuserperm) {
console.log("set cookie DOLUSER_PERMS_HIDE_GRP="+hideuserperm);
document.cookie = "DOLUSER_PERMS_HIDE_GRP=" + hideuserperm + "; expires=" + date.toGMTString() + "; path=/ ";
} else {
console.log("delete cookie DOLUSER_PERMS_HIDE_GRP");
document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";
}
});';
// Button expand / collapse all
print '$(".showallperms").on("click", function(){
console.log("Click on showallperms");
console.log("delete cookie DOLUSER_PERMS_HIDE_GRP from showallperms click");
document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";
$(".tdforbreakperms").each( function(){
moduletohide = $(this).data("hide-perms");
//console.log(moduletohide);
if ($("#idforbreakperms_"+moduletohide).val() != 0) {
$(this).trigger("click"); // emulate the click, so the cooki will be resaved
}
})
});
$(".hideallperms").on("click", function(){
console.log("Click on hideallperms");
$(".tdforbreakperms").each( function(){
moduletohide = $(this).data("hide-perms");
//console.log(moduletohide);
if ($("#idforbreakperms_"+moduletohide).val() != 1) {
$(this).trigger("click"); // emulate the click, so the cooki will be resaved
}
})
});';
print "\n";
print '</script>';
print '<style>';
print '.switchfolderperms{
cursor: pointer;
}';
print '</style>';
print '</div>'; print '</div>';
$parameters = array(); $parameters = array();