mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-07 09:32:47 +01:00
Uniformize code for contacts linking
This commit is contained in:
@@ -395,107 +395,6 @@ class CommonObject
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste d<>roulante des soci<63>t<EFBFBD>s
|
||||
* \param object Fetch du document
|
||||
* \param var_id Nom de la variable de l'id du document
|
||||
* \param selected Societe pr<70>s<EFBFBD>lectionn<6E>e
|
||||
* \param htmlname Nom champ formulaire
|
||||
*/
|
||||
function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany')
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
// On recherche les societes
|
||||
$sql = "SELECT s.rowid, s.nom FROM";
|
||||
$sql .= " ".MAIN_DB_PREFIX."societe as s";
|
||||
if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
|
||||
{
|
||||
$sql.= " WHERE rowid = ".$selected;
|
||||
}
|
||||
$sql .= " ORDER BY nom ASC";
|
||||
|
||||
$resql = $object->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$socid = $obj->rowid?$obj->rowid:'';
|
||||
$javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&".$htmlname."=\' + document.getElementById(\'newcompany_id\').value;";
|
||||
|
||||
// On applique un delai d'execution pour le bon fonctionnement
|
||||
$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"';
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding">';
|
||||
print '<div>';
|
||||
if ($obj->rowid == 0)
|
||||
{
|
||||
print '<input type="text" size="30" id="newcompany" name="newcompany" value="'.$langs->trans("SelectCompany").'" '.$htmloption.' />';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="30" id="newcompany" name="newcompany" value="'.$obj->nom.'" '.$htmloption.' />';
|
||||
}
|
||||
print ajax_autocompleter($socid,'newcompany','/societe/ajaxcompanies.php','');
|
||||
print '</td>';
|
||||
print '<td class="nobordernopadding" align="left" width="16">';
|
||||
print ajax_indicator($htmlname,'working');
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
return $socid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
|
||||
print '<select class="flat" name="'.$htmlname.'" onChange="'.$javaScript.'">';
|
||||
$num = $object->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $object->db->fetch_object($resql);
|
||||
if ($i == 0) $firstCompany = $obj->rowid;
|
||||
if ($selected > 0 && $selected == $obj->rowid)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected="true">'.dolibarr_trunc($obj->nom,24).'</option>';
|
||||
$firstCompany = $obj->rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">'.dolibarr_trunc($obj->nom,24).'</option>';
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
print "</select>\n";
|
||||
return $firstCompany;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($object->db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function selectTypeContact($object, $defValue, $htmlname = 'type', $source)
|
||||
{
|
||||
$lesTypes = $object->liste_type_contact($source);
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
foreach($lesTypes as $key=>$value)
|
||||
{
|
||||
print '<option value="'.$key.'">'.$value.'</option>';
|
||||
}
|
||||
print "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load properties id_previous and id_next
|
||||
|
||||
Reference in New Issue
Block a user