Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
1b0c875dcb
69
htdocs/core/ajax/ajaxinvoiceline.php
Normal file
69
htdocs/core/ajax/ajaxinvoiceline.php
Normal 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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -46,9 +46,9 @@ class FormProjets
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
@ -56,26 +56,27 @@ class FormProjets
|
||||
}
|
||||
|
||||
// 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
|
||||
*
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param string|Project $selected Id of preselected project or Project (or ''). Note: If you know the ref, you can also provide it into $selected_input_value to save one request in some cases.
|
||||
* @param string $htmlname Name of HTML field
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param int $show_empty Add an empty line
|
||||
* @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable). Use a negative value to not show the "discarded" tooltip.
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param int $mode 0 for HTML mode and 1 for JSON mode
|
||||
* @param string $filterkey Key to filter on ref or title
|
||||
* @param int $nooutput No print output. Return it only.
|
||||
* @param int $forceaddid Force to add project id in list, event if not qualified
|
||||
* @param string $morecss More css
|
||||
* @param int $htmlid Html id to use instead of htmlname
|
||||
* @param string $morefilter More filters (Must be a sql sanitized string)
|
||||
* @return string Return html content
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param string|Project $selected Id of preselected project or Project (or ''). Note: If you know the ref, you can also provide it into $selected_input_value to save one request in some cases.
|
||||
* @param string $htmlname Name of HTML field
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param int $show_empty Add an empty line
|
||||
* @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable). Use a negative value to not show the "discarded" tooltip.
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param int $mode 0 for HTML mode and 1 for JSON mode
|
||||
* @param string $filterkey Key to filter on ref or title
|
||||
* @param int $nooutput No print output. Return it only.
|
||||
* @param int $forceaddid Force to add project id in list, event if not qualified
|
||||
* @param string $morecss More css
|
||||
* @param int $htmlid Html id to use instead of htmlname
|
||||
* @param string $morefilter More filters (Must be a sql sanitized string)
|
||||
* @return string Return html content
|
||||
*/
|
||||
public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '', $morefilter = '')
|
||||
{
|
||||
@ -94,18 +95,18 @@ class FormProjets
|
||||
$placeholder = '';
|
||||
|
||||
if ($selected && empty($selected_input_value)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
||||
$project = new Project($this->db);
|
||||
$project->fetch($selected);
|
||||
$selected_input_value = $project->ref;
|
||||
}
|
||||
$urloption = 'socid='.((int) $socid).'&htmlname='.urlencode($htmlname).'&discardclosed='.((int) $discard_closed);
|
||||
$urloption = 'socid=' . ((int) $socid) . '&htmlname=' . urlencode($htmlname) . '&discardclosed=' . ((int) $discard_closed);
|
||||
if ($morefilter == 'usage_organize_event=1') {
|
||||
$urloption .= '&usage_organize_event=1';
|
||||
}
|
||||
$out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
|
||||
$out .= '<input type="text" class="minwidth200' . ($morecss ? ' ' . $morecss : '') . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' />';
|
||||
|
||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array());
|
||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array());
|
||||
} else {
|
||||
$out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss, $morefilter);
|
||||
}
|
||||
@ -124,33 +125,34 @@ class FormProjets
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
|
||||
/**
|
||||
* Returns an array with projects qualified for a third party
|
||||
*
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param int $selected Id project preselected
|
||||
* @param string $htmlname Nom de la zone html
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param int $show_empty Add an empty line
|
||||
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example)
|
||||
* @param string $filterkey Key to filter on title or ref
|
||||
* @param int $nooutput No print output. Return it only.
|
||||
* @param int $forceaddid Force to add project id in list, event if not qualified
|
||||
* @param int $htmlid Html id to use instead of htmlname
|
||||
* @param string $morecss More CSS
|
||||
* @param string $morefilter More filters (Must be a sql sanitized string)
|
||||
* @return int Nb of project if OK, <0 if KO
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param int $selected Id project preselected
|
||||
* @param string $htmlname Nom de la zone html
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param int $show_empty Add an empty line
|
||||
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example)
|
||||
* @param string $filterkey Key to filter on title or ref
|
||||
* @param int $nooutput No print output. Return it only.
|
||||
* @param int $forceaddid Force to add project id in list, event if not qualified
|
||||
* @param int $htmlid Html id to use instead of htmlname
|
||||
* @param string $morecss More CSS
|
||||
* @param string $morefilter More filters (Must be a sql sanitized string)
|
||||
* @return int Nb of project if OK, <0 if KO
|
||||
*/
|
||||
public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500', $morefilter = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $conf, $langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
||||
|
||||
if (empty($htmlid)) {
|
||||
$htmlid = $htmlname;
|
||||
@ -172,26 +174,26 @@ class FormProjets
|
||||
|
||||
// Search all projects
|
||||
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias";
|
||||
$sql .= " FROM ".$this->db->prefix()."projet as p LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = p.fk_soc";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('project').")";
|
||||
$sql .= " FROM " . $this->db->prefix() . "projet as p LEFT JOIN " . $this->db->prefix() . "societe as s ON s.rowid = p.fk_soc";
|
||||
$sql .= " WHERE p.entity IN (" . getEntity('project') . ")";
|
||||
if ($projectsListId !== false) {
|
||||
$sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
|
||||
$sql .= " AND p.rowid IN (" . $this->db->sanitize($projectsListId) . ")";
|
||||
}
|
||||
if ($socid == 0) {
|
||||
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
|
||||
}
|
||||
if ($socid > 0) {
|
||||
if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) {
|
||||
$sql .= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
|
||||
$sql .= " AND (p.fk_soc=" . ((int) $socid) . " OR p.fk_soc IS NULL)";
|
||||
} elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
|
||||
$sql .= " AND (p.fk_soc IN (".$this->db->sanitize(((int) $socid).", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).") OR p.fk_soc IS NULL)";
|
||||
$sql .= " AND (p.fk_soc IN (" . $this->db->sanitize(((int) $socid) . ", " . $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) . ") OR p.fk_soc IS NULL)";
|
||||
}
|
||||
}
|
||||
if (!empty($filterkey)) {
|
||||
$sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
|
||||
}
|
||||
if ($morefilter) {
|
||||
$sql .= ' AND ('.$this->db->sanitize($morefilter, 0, 1).')';
|
||||
$sql .= ' AND (' . $this->db->sanitize($morefilter, 0, 1) . ')';
|
||||
}
|
||||
$sql .= " ORDER BY p.ref ASC";
|
||||
|
||||
@ -201,7 +203,7 @@ class FormProjets
|
||||
$morecss .= ' minwidth100';
|
||||
}
|
||||
if (empty($option_only)) {
|
||||
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlid.'" name="'.$htmlname.'">';
|
||||
$out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled="disabled"' : '') . ' id="' . $htmlid . '" name="' . $htmlname . '">';
|
||||
}
|
||||
if (!empty($show_empty)) {
|
||||
$out .= '<option value="0"> </option>';
|
||||
@ -223,37 +225,37 @@ class FormProjets
|
||||
$labeltoshow = dol_trunc($obj->ref, 18);
|
||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
|
||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||
$labeltoshow .= ', '.dol_trunc($obj->title, $maxlength);
|
||||
$labeltoshow .= ', ' . dol_trunc($obj->title, $maxlength);
|
||||
if ($obj->name) {
|
||||
$labeltoshow .= ' - '.$obj->name;
|
||||
$labeltoshow .= ' - ' . $obj->name;
|
||||
if ($obj->name_alias) {
|
||||
$labeltoshow .= ' ('.$obj->name_alias.')';
|
||||
$labeltoshow .= ' (' . $obj->name_alias . ')';
|
||||
}
|
||||
}
|
||||
|
||||
$disabled = 0;
|
||||
if ($obj->fk_statut == 0) {
|
||||
$disabled = 1;
|
||||
$labeltoshow .= ' - '.$langs->trans("Draft");
|
||||
$labeltoshow .= ' - ' . $langs->trans("Draft");
|
||||
} elseif ($obj->fk_statut == 2) {
|
||||
if ($discard_closed == 2) {
|
||||
$disabled = 1;
|
||||
}
|
||||
$labeltoshow .= ' - '.$langs->trans("Closed");
|
||||
$labeltoshow .= ' - ' . $langs->trans("Closed");
|
||||
} elseif (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
|
||||
$disabled = 1;
|
||||
$labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
|
||||
$labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany");
|
||||
}
|
||||
|
||||
if (!empty($selected) && $selected == $obj->rowid) {
|
||||
$out .= '<option value="'.$obj->rowid.'" selected';
|
||||
$out .= '<option value="' . $obj->rowid . '" selected';
|
||||
//if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
|
||||
$out .= '>'.$labeltoshow.'</option>';
|
||||
$out .= '>' . $labeltoshow . '</option>';
|
||||
} else {
|
||||
if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
|
||||
$resultat = '';
|
||||
} else {
|
||||
$resultat = '<option value="'.$obj->rowid.'"';
|
||||
$resultat = '<option value="' . $obj->rowid . '"';
|
||||
if ($disabled) {
|
||||
$resultat .= ' disabled';
|
||||
}
|
||||
@ -270,7 +272,7 @@ class FormProjets
|
||||
'value' => $obj->ref,
|
||||
'ref' => $obj->ref,
|
||||
'labelx' => $labeltoshow,
|
||||
'label' => ($disabled ? '<span class="opacitymedium">'.$labeltoshow.'</span>' : $labeltoshow),
|
||||
'label' => ($disabled ? '<span class="opacitymedium">' . $labeltoshow . '</span>' : $labeltoshow),
|
||||
'disabled' => (bool) $disabled
|
||||
);
|
||||
}
|
||||
@ -288,7 +290,7 @@ class FormProjets
|
||||
|
||||
// Use select2 selector
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
|
||||
$out .= $comboenhancement;
|
||||
$morecss .= ' minwidth100';
|
||||
@ -312,26 +314,26 @@ class FormProjets
|
||||
/**
|
||||
* Output a combo list with tasks qualified for a third party
|
||||
*
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param int $selected Id task preselected
|
||||
* @param string $htmlname Name of HTML select
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
|
||||
* @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable)
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param string $morecss More css added to the select component
|
||||
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
|
||||
* @param string $showmore 'all' = Show project info, 'progress' = Show task progression, ''=Show nothing more
|
||||
* @param User $usertofilter User object to use for filtering
|
||||
* @return int Nbr of tasks if OK, <0 if KO
|
||||
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
|
||||
* @param int $selected Id task preselected
|
||||
* @param string $htmlname Name of HTML select
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $option_only Return only html options lines without the select tag
|
||||
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
|
||||
* @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable)
|
||||
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||
* @param int $disabled Disabled
|
||||
* @param string $morecss More css added to the select component
|
||||
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
|
||||
* @param string $showmore 'all' = Show project info, 'progress' = Show task progression, ''=Show nothing more
|
||||
* @param User $usertofilter User object to use for filtering
|
||||
* @return int Nbr of tasks if OK, <0 if KO
|
||||
*/
|
||||
public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showmore = 'all', $usertofilter = null)
|
||||
{
|
||||
global $user, $conf, $langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
||||
|
||||
if (is_null($usertofilter)) {
|
||||
$usertofilter = $user;
|
||||
@ -355,19 +357,19 @@ class FormProjets
|
||||
$sql = "SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,";
|
||||
$sql .= " p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,";
|
||||
$sql .= " s.nom as name";
|
||||
$sql .= " FROM ".$this->db->prefix()."projet as p";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = p.fk_soc,";
|
||||
$sql .= " ".$this->db->prefix()."projet_task as t";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('project').")";
|
||||
$sql .= " FROM " . $this->db->prefix() . "projet as p";
|
||||
$sql .= " LEFT JOIN " . $this->db->prefix() . "societe as s ON s.rowid = p.fk_soc,";
|
||||
$sql .= " " . $this->db->prefix() . "projet_task as t";
|
||||
$sql .= " WHERE p.entity IN (" . getEntity('project') . ")";
|
||||
$sql .= " AND t.fk_projet = p.rowid";
|
||||
if ($projectsListId) {
|
||||
$sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
|
||||
$sql .= " AND p.rowid IN (" . $this->db->sanitize($projectsListId) . ")";
|
||||
}
|
||||
if ($socid == 0) {
|
||||
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
|
||||
}
|
||||
if ($socid > 0) {
|
||||
$sql .= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
|
||||
$sql .= " AND (p.fk_soc=" . ((int) $socid) . " OR p.fk_soc IS NULL)";
|
||||
}
|
||||
$sql .= " ORDER BY p.ref, t.ref ASC";
|
||||
|
||||
@ -375,14 +377,14 @@ class FormProjets
|
||||
if ($resql) {
|
||||
// Use select2 selector
|
||||
if (empty($option_only) && !empty($conf->use_javascript_ajax)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
|
||||
$out .= $comboenhancement;
|
||||
$morecss .= ' minwidth200 maxwidth500';
|
||||
}
|
||||
|
||||
if (empty($option_only)) {
|
||||
$out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
$out .= '<select class="valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled="disabled"' : '') . ' id="' . $htmlname . '" name="' . $htmlname . '">';
|
||||
}
|
||||
if (!empty($show_empty)) {
|
||||
$out .= '<option value="0" class="optiongrey">';
|
||||
@ -428,58 +430,58 @@ class FormProjets
|
||||
$labeltoshow .= dol_trunc($obj->ref, 18); // Project ref
|
||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
|
||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||
$labeltoshow .= ' '.dol_trunc($obj->title, $maxlength);
|
||||
$labeltoshow .= ' ' . dol_trunc($obj->title, $maxlength);
|
||||
$titletoshow = $labeltoshow;
|
||||
|
||||
if ($obj->name) {
|
||||
$labeltoshow .= ' ('.$obj->name.')';
|
||||
$titletoshow .= ' <span class="opacitymedium">('.$obj->name.')</span>';
|
||||
$labeltoshow .= ' (' . $obj->name . ')';
|
||||
$titletoshow .= ' <span class="opacitymedium">(' . $obj->name . ')</span>';
|
||||
}
|
||||
|
||||
$disabled = 0;
|
||||
if ($obj->fk_statut == Project::STATUS_DRAFT) {
|
||||
$disabled = 1;
|
||||
$labeltoshow .= ' - '.$langs->trans("Draft");
|
||||
$titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Draft").'</span>';
|
||||
$labeltoshow .= ' - ' . $langs->trans("Draft");
|
||||
$titletoshow .= ' - <span class="opacitymedium">' . $langs->trans("Draft") . '</span>';
|
||||
} elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
|
||||
if ($discard_closed == 2) {
|
||||
$disabled = 1;
|
||||
}
|
||||
$labeltoshow .= ' - '.$langs->trans("Closed");
|
||||
$titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Closed").'</span>';
|
||||
$labeltoshow .= ' - ' . $langs->trans("Closed");
|
||||
$titletoshow .= ' - <span class="opacitymedium">' . $langs->trans("Closed") . '</span>';
|
||||
} elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
|
||||
$disabled = 1;
|
||||
$labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany");
|
||||
$titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("LinkedToAnotherCompany").'</span>';
|
||||
$labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany");
|
||||
$titletoshow .= ' - <span class="opacitymedium">' . $langs->trans("LinkedToAnotherCompany") . '</span>';
|
||||
}
|
||||
$labeltoshow .= ' - ';
|
||||
$titletoshow .= ' - ';
|
||||
}
|
||||
|
||||
// Label for task
|
||||
$labeltoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
|
||||
$titletoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
|
||||
$labeltoshow .= $obj->tref . ' ' . dol_trunc($obj->tlabel, $maxlength);
|
||||
$titletoshow .= $obj->tref . ' ' . dol_trunc($obj->tlabel, $maxlength);
|
||||
if ($obj->usage_task && preg_match('/progress/', $showmore)) {
|
||||
$labeltoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>';
|
||||
$titletoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>';
|
||||
$labeltoshow .= ' <span class="opacitymedium">(' . $obj->progress . '%)</span>';
|
||||
$titletoshow .= ' <span class="opacitymedium">(' . $obj->progress . '%)</span>';
|
||||
}
|
||||
|
||||
if (!empty($selected) && $selected == $obj->rowid) {
|
||||
$out .= '<option value="'.$obj->rowid.'" selected';
|
||||
$out .= ' data-html="'.dol_escape_htmltag($titletoshow).'"';
|
||||
$out .= '<option value="' . $obj->rowid . '" selected';
|
||||
$out .= ' data-html="' . dol_escape_htmltag($titletoshow) . '"';
|
||||
//if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
|
||||
$out .= '>'.$labeltoshow.'</option>';
|
||||
$out .= '>' . $labeltoshow . '</option>';
|
||||
} else {
|
||||
if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
|
||||
$resultat = '';
|
||||
} else {
|
||||
$resultat = '<option value="'.$obj->rowid.'"';
|
||||
$resultat = '<option value="' . $obj->rowid . '"';
|
||||
if ($disabled) {
|
||||
$resultat .= ' disabled';
|
||||
}
|
||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
|
||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||
$resultat .= ' data-html="'.dol_escape_htmltag($titletoshow).'"';
|
||||
$resultat .= ' data-html="' . dol_escape_htmltag($titletoshow) . '"';
|
||||
$resultat .= '>';
|
||||
$resultat .= $labeltoshow;
|
||||
$resultat .= '</option>';
|
||||
@ -508,16 +510,17 @@ class FormProjets
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
|
||||
/**
|
||||
* Build a HTML select list of element of same thirdparty to suggest to link them to project
|
||||
*
|
||||
* @param string $table_element Table of the element to update
|
||||
* @param string $socid If of thirdparty to use as filter or 'id1,id2,...'
|
||||
* @param string $morecss More CSS
|
||||
* @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement
|
||||
* @param string $projectkey Equivalent key to fk_projet for actual table_element
|
||||
* @param string $placeholder Placeholder
|
||||
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
|
||||
* @param string $table_element Table of the element to update
|
||||
* @param string $socid If of thirdparty to use as filter or 'id1,id2,...'
|
||||
* @param string $morecss More CSS
|
||||
* @param int $limitonstatus Add filters to limit length of list to opened status (for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project/element.php page). TODO To implement
|
||||
* @param string $projectkey Equivalent key to fk_projet for actual table_element
|
||||
* @param string $placeholder Placeholder
|
||||
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
|
||||
*/
|
||||
public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet", $placeholder = '')
|
||||
{
|
||||
@ -530,15 +533,15 @@ class FormProjets
|
||||
|
||||
$linkedtothirdparty = false;
|
||||
if (!in_array($table_element, array(
|
||||
'don',
|
||||
'expensereport_det',
|
||||
'expensereport', 'loan',
|
||||
'stock_mouvement',
|
||||
'payment_salary',
|
||||
'payment_various',
|
||||
'salary',
|
||||
'chargesociales',
|
||||
'entrepot')
|
||||
'don',
|
||||
'expensereport_det',
|
||||
'expensereport', 'loan',
|
||||
'stock_mouvement',
|
||||
'payment_salary',
|
||||
'payment_various',
|
||||
'salary',
|
||||
'chargesociales',
|
||||
'entrepot')
|
||||
)) {
|
||||
$linkedtothirdparty = true;
|
||||
}
|
||||
@ -597,30 +600,30 @@ class FormProjets
|
||||
if ($linkedtothirdparty) {
|
||||
$sql .= ", s.nom as name";
|
||||
}
|
||||
$sql .= " FROM ".$this->db->prefix().$table_element." as t";
|
||||
$sql .= " FROM " . $this->db->prefix() . $table_element . " as t";
|
||||
if ($linkedtothirdparty) {
|
||||
$sql .= ", ".$this->db->prefix()."societe as s";
|
||||
$sql .= ", " . $this->db->prefix() . "societe as s";
|
||||
}
|
||||
$sql .= " WHERE ".$projectkey." is null";
|
||||
$sql .= " WHERE " . $projectkey . " is null";
|
||||
if (!empty($socid) && $linkedtothirdparty) {
|
||||
if (is_numeric($socid)) {
|
||||
$sql .= " AND t.fk_soc = ".((int) $socid);
|
||||
$sql .= " AND t.fk_soc = " . ((int) $socid);
|
||||
} else {
|
||||
$sql .= " AND t.fk_soc IN (".$this->db->sanitize($socid).")";
|
||||
$sql .= " AND t.fk_soc IN (" . $this->db->sanitize($socid) . ")";
|
||||
}
|
||||
}
|
||||
if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) {
|
||||
$sql .= ' AND t.entity IN ('.getEntity('project').')';
|
||||
$sql .= ' AND t.entity IN (' . getEntity('project') . ')';
|
||||
}
|
||||
if ($linkedtothirdparty) {
|
||||
$sql .= " AND s.rowid = t.fk_soc";
|
||||
}
|
||||
if ($sqlfilter) {
|
||||
$sql .= " AND ".$sqlfilter;
|
||||
$sql .= " AND " . $sqlfilter;
|
||||
}
|
||||
$sql .= " ORDER BY ref DESC";
|
||||
|
||||
dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
|
||||
dol_syslog(get_class($this) . '::select_element', LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
@ -628,18 +631,18 @@ class FormProjets
|
||||
$sellist = '';
|
||||
|
||||
if ($num > 0) {
|
||||
$sellist = '<select class="flat elementselect css'.$table_element.($morecss ? ' '.$morecss : '').'" name="elementselect">';
|
||||
$sellist .= '<option value="-1"'.($placeholder ? ' class="optiongrey"' : '').'>'.$placeholder.'</option>';
|
||||
$sellist = '<select class="flat elementselect css' . $table_element . ($morecss ? ' ' . $morecss : '') . '" name="elementselect">';
|
||||
$sellist .= '<option value="-1"' . ($placeholder ? ' class="optiongrey"' : '') . '>' . $placeholder . '</option>';
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$ref = $obj->ref ? $obj->ref : $obj->rowid;
|
||||
if (!empty($obj->ref_supplier)) {
|
||||
$ref .= ' ('.$obj->ref_supplier.')';
|
||||
$ref .= ' (' . $obj->ref_supplier . ')';
|
||||
}
|
||||
if (!empty($obj->name)) {
|
||||
$ref .= ' - '.$obj->name;
|
||||
$ref .= ' - ' . $obj->name;
|
||||
}
|
||||
$sellist .= '<option value="'.$obj->rowid.'">'.$ref.'</option>';
|
||||
$sellist .= '<option value="' . $obj->rowid . '">' . $ref . '</option>';
|
||||
$i++;
|
||||
}
|
||||
$sellist .= '</select>';
|
||||
@ -657,7 +660,7 @@ class FormProjets
|
||||
dol_print_error($this->db);
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::select_element ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -666,23 +669,23 @@ class FormProjets
|
||||
/**
|
||||
* Build a HTML select list of element of same thirdparty to suggest to link them to project
|
||||
*
|
||||
* @param string $htmlname HTML name
|
||||
* @param string $preselected Preselected (int or 'all' or 'none')
|
||||
* @param int $showempty Add an empty line
|
||||
* @param int $useshortlabel Use short label
|
||||
* @param int $showallnone Add choice "All" and "None"
|
||||
* @param int $showpercent Show default probability for status
|
||||
* @param string $morecss Add more css
|
||||
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
|
||||
* @param int $addcombojs 1=Add a js combo
|
||||
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
|
||||
* @param string $htmlname HTML name
|
||||
* @param string $preselected Preselected (int or 'all' or 'none')
|
||||
* @param int $showempty Add an empty line
|
||||
* @param int $useshortlabel Use short label
|
||||
* @param int $showallnone Add choice "All" and "None"
|
||||
* @param int $showpercent Show default probability for status
|
||||
* @param string $morecss Add more css
|
||||
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
|
||||
* @param int $addcombojs 1=Add a js combo
|
||||
* @return int|string The HTML select list of element or '' if nothing or -1 if KO
|
||||
*/
|
||||
public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0)
|
||||
{
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$sql = "SELECT rowid, code, label, percent";
|
||||
$sql .= " FROM ".$this->db->prefix().'c_lead_status';
|
||||
$sql .= " FROM " . $this->db->prefix() . 'c_lead_status';
|
||||
$sql .= " WHERE active = 1";
|
||||
$sql .= " ORDER BY position";
|
||||
|
||||
@ -691,31 +694,31 @@ class FormProjets
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num > 0) {
|
||||
$sellist = '<select class="flat oppstatus'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
$sellist = '<select class="flat oppstatus' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '">';
|
||||
if ($showempty) {
|
||||
// Without  , strange move of screen when switching value
|
||||
$sellist .= '<option value="-1"> </option>';
|
||||
}
|
||||
if ($showallnone) {
|
||||
$sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>-- '.$langs->trans("OnlyOpportunitiesShort").'</option>';
|
||||
$sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("OpenedOpportunitiesShort").'</option>';
|
||||
$sellist .= '<option value="notopenedopp"'.($preselected == 'notopenedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotOpenedOpportunitiesShort").'</option>';
|
||||
$sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotAnOpportunityShort").'</option>';
|
||||
$sellist .= '<option value="all"' . ($preselected == 'all' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("OnlyOpportunitiesShort") . '</option>';
|
||||
$sellist .= '<option value="openedopp"' . ($preselected == 'openedopp' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("OpenedOpportunitiesShort") . '</option>';
|
||||
$sellist .= '<option value="notopenedopp"' . ($preselected == 'notopenedopp' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("NotOpenedOpportunitiesShort") . '</option>';
|
||||
$sellist .= '<option value="none"' . ($preselected == 'none' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("NotAnOpportunityShort") . '</option>';
|
||||
}
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$sellist .= '<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"';
|
||||
$sellist .= '<option value="' . $obj->rowid . '" defaultpercent="' . $obj->percent . '" elemcode="' . $obj->code . '"';
|
||||
if ($obj->rowid == $preselected) {
|
||||
$sellist .= ' selected="selected"';
|
||||
}
|
||||
$sellist .= '>';
|
||||
if ($useshortlabel) {
|
||||
$finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
|
||||
$finallabel = ($langs->transnoentitiesnoconv("OppStatus" . $obj->code) != "OppStatus" . $obj->code ? $langs->transnoentitiesnoconv("OppStatus" . $obj->code) : $obj->label);
|
||||
} else {
|
||||
$finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
|
||||
$finallabel = ($langs->transnoentitiesnoconv("OppStatus" . $obj->code) != "OppStatus" . $obj->code ? $langs->transnoentitiesnoconv("OppStatus" . $obj->code) : $obj->label);
|
||||
if ($showpercent) {
|
||||
$finallabel .= ' ('.$obj->percent.'%)';
|
||||
$finallabel .= ' (' . $obj->percent . '%)';
|
||||
}
|
||||
}
|
||||
$sellist .= $finallabel;
|
||||
@ -744,8 +747,134 @@ class FormProjets
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::selectOpportunityStatus ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this) . "::selectOpportunityStatus " . $this->error, LOG_ERR);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,6 +128,8 @@ class Task extends CommonObjectLine
|
||||
public $timespent_thm;
|
||||
public $timespent_note;
|
||||
public $timespent_fk_product;
|
||||
public $timespent_invoiceid;
|
||||
public $timespent_invoicelineid;
|
||||
|
||||
public $comments = array();
|
||||
|
||||
@ -1736,6 +1738,8 @@ class Task extends CommonObjectLine
|
||||
$sql .= " task_duration = ".((int) $this->timespent_duration).",";
|
||||
$sql .= " fk_user = ".((int) $this->timespent_fk_user).",";
|
||||
$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 .= " WHERE rowid = ".((int) $this->timespent_id);
|
||||
|
||||
|
||||
@ -309,6 +309,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
|
||||
}
|
||||
$object->timespent_fk_user = GETPOST("userid_line", 'int');
|
||||
$object->timespent_fk_product = GETPOST("fk_product", 'int');
|
||||
$object->timespent_invoiceid = GETPOST("invoiceid", 'int');
|
||||
$object->timespent_invoicelineid = GETPOST("invoicelineid", 'int');
|
||||
|
||||
$result = 0;
|
||||
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_product = GETPOST("fk_product", 'int');
|
||||
|
||||
$object->timespent_invoiceid = GETPOST("invoiceid", 'int');
|
||||
$object->timespent_invoicelineid = GETPOST("invoicelineid", 'int');
|
||||
$result = 0;
|
||||
|
||||
if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
|
||||
$result = $object->updateTimeSpent($user);
|
||||
|
||||
@ -1468,7 +1472,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
|
||||
print $langs->trans('InvoiceToUse');
|
||||
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 '</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 .= " il.fk_facture as invoice_id, inv.fk_statut,";
|
||||
$sql .= " p.fk_soc,s.name_alias,";
|
||||
$sql .= " t.invoice_line_id";
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
$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) {
|
||||
$result = $tmpinvoice->fetch($task_time->invoice_id);
|
||||
if ($result > 0) {
|
||||
print $tmpinvoice->getNomUrl(1);
|
||||
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);
|
||||
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 {
|
||||
print $langs->trans("No");
|
||||
|
||||
@ -255,12 +255,18 @@ if ($object->id > 0) {
|
||||
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 '</td>';
|
||||
} else {
|
||||
print '<td></td>';
|
||||
}
|
||||
print '<td class="center" width="24"> </td>';
|
||||
print '<td>'.$langs->trans("Permissions").'</td>';
|
||||
if ($user->admin) {
|
||||
print '<td class="right"></td>';
|
||||
}
|
||||
print '<td class="center" width="24"></td>';
|
||||
//print '<td>'.$langs->trans("Permissions").'</td>';
|
||||
print '<td class="center"></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";
|
||||
|
||||
$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);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
$i = 0;$j = 0;
|
||||
$oldmod = '';
|
||||
|
||||
$cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));
|
||||
$cookietohidegrouparray = explode(',', $cookietohidegroup);
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
@ -289,48 +298,78 @@ if ($object->id > 0) {
|
||||
|
||||
$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
|
||||
if (isset($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
|
||||
$objMod = $modules[$obj->module];
|
||||
$picto = ($objMod->picto ? $objMod->picto : 'generic');
|
||||
|
||||
// Show break line
|
||||
print '<tr class="oddeven trforbreak">';
|
||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
|
||||
print '<tr class="oddeven trforbreakperms" data-hide-perms="'.$obj->module.'" data-j="'.$j.'">';
|
||||
// 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 '<a name="'.$objMod->getName().'"></a>';
|
||||
print '</td>';
|
||||
// Permission and tick (2 columns)
|
||||
if ($caneditperms) {
|
||||
print '<td class="center nowrap">';
|
||||
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 '/';
|
||||
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 '<td class="center wraponsmartphone">';
|
||||
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 '<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>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
|
||||
// Permission id
|
||||
if ($user->admin) {
|
||||
print '<td class="right"></td>';
|
||||
}
|
||||
|
||||
// Description of permission (2 columns)
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
|
||||
print '<td class="maxwidthonsmartphone right tdforbreakperms" data-hide-perms="'.$obj->module.'">';
|
||||
print '<div class="switchfolderperms folderperms_'.$obj->module.'"'.($isexpanded ? ' style="display:none;"' : '').'>';
|
||||
print img_picto('', 'folder', 'class="marginright"');
|
||||
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 '<!-- '.$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
|
||||
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 '</td>';
|
||||
|
||||
// Permission and tick (2 columns)
|
||||
if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {
|
||||
if (in_array($obj->id, $permsgroupbyentity[$entity])) {
|
||||
// Own permission by group
|
||||
@ -360,11 +399,13 @@ if ($object->id > 0) {
|
||||
//print img_edit_add($langs->trans("Add"));
|
||||
print img_picto($langs->trans("Add"), 'switch_off');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </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)));
|
||||
print '<td>';
|
||||
print $permlabel;
|
||||
@ -383,6 +424,8 @@ if ($object->id > 0) {
|
||||
print $form->textwithpicto('', $htmltext);
|
||||
//print '<span class="opacitymedium">'.$obj->id.'</span>';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print '</tr>'."\n";
|
||||
@ -393,6 +436,82 @@ if ($object->id > 0) {
|
||||
print '</table>';
|
||||
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>';
|
||||
|
||||
$parameters = array();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user