Fix: Some quality fixes
This commit is contained in:
parent
83cf8a8e73
commit
482a771e7c
@ -23,9 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to manage generation of HTML components for bank module
|
* Class to manage generation of HTML components for contract module
|
||||||
*/
|
*/
|
||||||
class Formcontract
|
class FormContract
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
@ -49,9 +49,10 @@ class Formcontract
|
|||||||
* @param int $selected Id contract preselected
|
* @param int $selected Id contract preselected
|
||||||
* @param string $htmlname Nom de la zone html
|
* @param string $htmlname Nom de la zone html
|
||||||
* @param int $maxlength Maximum length of label
|
* @param int $maxlength Maximum length of label
|
||||||
|
* @param int $showempty Show empty line
|
||||||
* @return int Nbre of project if OK, <0 if KO
|
* @return int Nbre of project if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
function select_contract($socid=-1, $selected='', $htmlname='contrattid', $maxlength=16)
|
function select_contract($socid=-1, $selected='', $htmlname='contrattid', $maxlength=16, $showempty=1)
|
||||||
{
|
{
|
||||||
global $db,$user,$conf,$langs;
|
global $db,$user,$conf,$langs;
|
||||||
|
|
||||||
@ -59,22 +60,19 @@ class Formcontract
|
|||||||
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
|
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
|
||||||
|
|
||||||
// Search all contacts
|
// Search all contacts
|
||||||
$sql = 'SELECT c.rowid, c.ref, c.note, c.fk_soc, c.statut';
|
$sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c';
|
$sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c';
|
||||||
$sql.= " WHERE c.entity = ".$conf->entity;
|
$sql.= " WHERE c.entity = ".$conf->entity;
|
||||||
//if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")";
|
//if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")";
|
||||||
if ($socid == 0)
|
if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)";
|
||||||
$sql.= " AND (c.fk_soc=0 OR c.fk_soc IS NULL)";
|
else $sql.= " AND c.fk_soc = ".$socid;
|
||||||
else
|
|
||||||
$sql.= " AND c.fk_soc=".$socid;
|
|
||||||
$sql.= " ORDER BY c.note ASC";
|
|
||||||
|
|
||||||
dol_syslog("contact.lib::select_contrats sql=".$sql);
|
dol_syslog(get_class($this)."::select_contract sql=".$sql);
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
print '<option value="0"> </option>';
|
if ($showempty) print '<option value="0"> </option>';
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -102,7 +100,7 @@ class Formcontract
|
|||||||
if (! $obj->statut > 0)
|
if (! $obj->statut > 0)
|
||||||
{
|
{
|
||||||
$disabled=1;
|
$disabled=1;
|
||||||
$labeltoshow.=' - '.$langs->trans("Draft");
|
$labeltoshow.=' ('.$langs->trans("Draft").')';
|
||||||
}
|
}
|
||||||
if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
|
if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
|
||||||
{
|
{
|
||||||
@ -121,7 +119,6 @@ class Formcontract
|
|||||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
|
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
|
||||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||||
$resultat.='>'.$labeltoshow;
|
$resultat.='>'.$labeltoshow;
|
||||||
if (! $disabled) $resultat.=' - '.dol_trunc($obj->title,$maxlength);
|
|
||||||
$resultat.='</option>';
|
$resultat.='</option>';
|
||||||
}
|
}
|
||||||
print $resultat;
|
print $resultat;
|
||||||
|
|||||||
@ -895,8 +895,9 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheint
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
|
$formcontract = new FormContract($db);
|
||||||
|
|
||||||
llxHeader();
|
llxHeader('',$langs->trans("Fichinter"));
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
@ -1022,12 +1023,12 @@ if ($action == 'create')
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contrat
|
// Contract
|
||||||
if ($conf->contrat->enabled)
|
if ($conf->contrat->enabled)
|
||||||
{
|
{
|
||||||
$langs->load("contrat");
|
$langs->load("contrat");
|
||||||
print '<tr><td valign="top">'.$langs->trans("Contrat").'</td><td>';
|
print '<tr><td valign="top">'.$langs->trans("Contract").'</td><td>';
|
||||||
$numcontrat=select_contrats($soc->id,GETPOST('contratid','int'),'contratid');
|
$numcontrat=$formcontract->select_contract($soc->id,GETPOST('contratid','int'),'contratid',0,1);
|
||||||
if ($numcontrat==0)
|
if ($numcontrat==0)
|
||||||
{
|
{
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContract").'</a>';
|
print ' <a href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContract").'</a>';
|
||||||
@ -1243,7 +1244,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
if ($action != 'contrat')
|
if ($action != 'contrat')
|
||||||
{
|
{
|
||||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=contrat&id='.$object->id.'">';
|
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=contrat&id='.$object->id.'">';
|
||||||
print img_edit($langs->trans('SetContrat'),1);
|
print img_edit($langs->trans('SetContract'),1);
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user