Qual: Clean code from user table tr td
This commit is contained in:
parent
0d6d064e7e
commit
7fc8799c3d
@ -520,7 +520,7 @@ class FormCompany
|
||||
* @param string $htmlname Name of HTML form
|
||||
* @param array $limitto Disable answers that are not id in this array list
|
||||
* @param int $forceid This is to force another object id than object->id
|
||||
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @param array $events More js events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @param string $moreparam String with more param to add into url when noajax search is used.
|
||||
* @return int The selected third party ID
|
||||
*/
|
||||
@ -573,13 +573,13 @@ class FormCompany
|
||||
var obj = '.json_encode($events).';
|
||||
$.each(obj, function(key,values) {
|
||||
if (values.method.length) {
|
||||
getMethod'.$htmlname.'(values);
|
||||
runJsCodeForEvent'.$htmlname.'(values);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Function used to execute events when search_htmlname change
|
||||
function getMethod'.$htmlname.'(obj) {
|
||||
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||
var id = $("#'.$htmlname.'").val();
|
||||
var method = obj.method;
|
||||
var url = obj.url;
|
||||
@ -612,8 +612,8 @@ class FormCompany
|
||||
}
|
||||
|
||||
print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n";
|
||||
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
|
||||
print '<td class="nobordernopadding">';
|
||||
//print '<table class="nobordernopadding"><tr class="nobordernopadding">';
|
||||
//print '<td class="nobordernopadding">';
|
||||
if ($obj->rowid == 0)
|
||||
{
|
||||
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="" '.$htmloption.' />';
|
||||
@ -623,10 +623,10 @@ class FormCompany
|
||||
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" '.$htmloption.' />';
|
||||
}
|
||||
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php','',$minLength);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print "\n";
|
||||
//print '</td>';
|
||||
//print '</tr>';
|
||||
//print '</table>';
|
||||
//print "\n";
|
||||
return $socid;
|
||||
}
|
||||
else
|
||||
|
||||
144
htdocs/core/class/html.formintervention.class.php
Normal file
144
htdocs/core/class/html.formintervention.class.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012-2013 Charles-Fr BENKE <charles.fr@benke.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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/html.formintervention.class.php
|
||||
* \ingroup core
|
||||
* \brief File of class with all html predefined components
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage generation of HTML components for contract module
|
||||
*/
|
||||
class FormIntervention
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show a combo list with contracts qualified for a third party
|
||||
*
|
||||
* @param int $socid Id third party (-1=all, 0=only interventions not linked to a third party, id=intervention not linked or linked to third party id)
|
||||
* @param int $selected Id intervention preselected
|
||||
* @param string $htmlname Nom de la zone html
|
||||
* @param int $maxlength Maximum length of label
|
||||
* @param int $showempty Show empty line
|
||||
* @return int Nbre of project if OK, <0 if KO
|
||||
*/
|
||||
function select_interventions($socid=-1, $selected='', $htmlname='interventionid', $maxlength=16, $showempty=1)
|
||||
{
|
||||
global $db,$user,$conf,$langs;
|
||||
|
||||
$out='';
|
||||
|
||||
$hideunselectables=false;
|
||||
|
||||
// Search all contacts
|
||||
$sql = 'SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX .'fichinter as f';
|
||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||
//if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")";
|
||||
if ($socid != '')
|
||||
{
|
||||
if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
|
||||
else $sql.= " AND f.fk_soc = ".$socid;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$out.='<select class="flat" name="'.$htmlname.'">';
|
||||
if ($showempty) $out.='<option value="0"> </option>';
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
|
||||
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
$labeltoshow=dol_trunc($obj->ref,18);
|
||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
|
||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||
if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
|
||||
{
|
||||
$out.='<option value="'.$obj->rowid.'" selected="selected">'.$labeltoshow.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$disabled=0;
|
||||
if (! $obj->fk_statut > 0)
|
||||
{
|
||||
$disabled=1;
|
||||
$labeltoshow.=' ('.$langs->trans("Draft").')';
|
||||
}
|
||||
if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
|
||||
{
|
||||
$disabled=1;
|
||||
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
|
||||
}
|
||||
|
||||
if ($hideunselectables && $disabled)
|
||||
{
|
||||
$resultat='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$resultat='<option value="'.$obj->rowid.'"';
|
||||
if ($disabled) $resultat.=' disabled="disabled"';
|
||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
|
||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||
$resultat.='>'.$labeltoshow;
|
||||
$resultat.='</option>';
|
||||
}
|
||||
$out.=$resultat;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$out.='</select>';
|
||||
$db->free($resql);
|
||||
return $out;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -311,7 +311,7 @@ function ajax_dialog($title,$message,$w=350,$h=150)
|
||||
* TODO: It is used when COMPANY_USE_SEARCH_TO_SELECT and CONTACT_USE_SEARCH_TO_SELECT are set by html.formcompany.class.php. Should use ajax_autocompleter instead like done by html.form.class.php for select_produits.
|
||||
*
|
||||
* @param string $htmlname Name of html select field
|
||||
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @param array $events More events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
|
||||
* @return string Return html string to convert a select field into a combo
|
||||
*/
|
||||
@ -344,13 +344,13 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
||||
var obj = '.json_encode($events).';
|
||||
$.each(obj, function(key,values) {
|
||||
if (values.method.length) {
|
||||
getMethod(values);
|
||||
runJsCodeForEvent(values);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function getMethod(obj) {
|
||||
function runJsCodeForEvent(obj) {
|
||||
var id = $("#'.$htmlname.'").val();
|
||||
var method = obj.method;
|
||||
var url = obj.url;
|
||||
@ -382,6 +382,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
||||
} else {
|
||||
$("#inputautocomplete"+htmlname).val("");
|
||||
}
|
||||
$("select#" + htmlname).change(); /* Trigger event change */
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user