diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index ecb8a0da6f937a7271e6fc7115c0f6cb7685bdcc..dc794f77ebe2e23f515340f3b76a5f0f009990d7 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -18,14 +18,14 @@ /** * \file htdocs/core/class/html.formcontract.class.php - * \ingroup core + * \ingroup core * \brief File of class with all html predefined components */ /** - * 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 $error; @@ -41,7 +41,7 @@ class Formcontract $this->db = $db; } - + /** * Show a combo list with contracts qualified for a third party * @@ -49,32 +49,30 @@ class Formcontract * @param int $selected Id contract 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_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; - + $hideunselectables = false; if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; - + // 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.= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; - if ($socid == 0) - $sql.= " AND (c.fk_soc=0 OR c.fk_soc IS NULL)"; - else - $sql.= " AND c.fk_soc=".$socid; - $sql.= " ORDER BY c.note ASC"; - - dol_syslog("contact.lib::select_contrats sql=".$sql); + if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; + else $sql.= " AND c.fk_soc = ".$socid; + + dol_syslog(get_class($this)."::select_contract sql=".$sql); $resql=$db->query($sql); if ($resql) { print '<select class="flat" name="'.$htmlname.'">'; - print '<option value="0"> </option>'; + if ($showempty) print '<option value="0"> </option>'; $num = $db->num_rows($resql); $i = 0; if ($num) @@ -102,14 +100,14 @@ class Formcontract if (! $obj->statut > 0) { $disabled=1; - $labeltoshow.=' - '.$langs->trans("Draft"); + $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=''; @@ -121,7 +119,6 @@ class Formcontract //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; $resultat.='>'.$labeltoshow; - if (! $disabled) $resultat.=' - '.dol_trunc($obj->title,$maxlength); $resultat.='</option>'; } print $resultat; @@ -141,4 +138,4 @@ class Formcontract } } } -?> +?> \ No newline at end of file diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 9f725b52404ce33eb6b81fbb5f4579ea9ebeaf70..488b83525093ea4afe1e1c34d8355afc14fc60f1 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -891,12 +891,13 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheint /* * View -*/ + */ $form = new Form($db); $formfile = new FormFile($db); +$formcontract = new FormContract($db); -llxHeader(); +llxHeader('',$langs->trans("Fichinter")); if ($action == 'create') { @@ -1022,18 +1023,18 @@ if ($action == 'create') print '</td></tr>'; } - // Contrat - if ($conf->contrat->enabled) - { - $langs->load("contrat"); - print '<tr><td valign="top">'.$langs->trans("Contrat").'</td><td>'; - $numcontrat=select_contrats($soc->id,GETPOST('contratid','int'),'contratid'); - if ($numcontrat==0) + // Contract + if ($conf->contrat->enabled) { - print ' <a href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContract").'</a>'; + $langs->load("contrat"); + print '<tr><td valign="top">'.$langs->trans("Contract").'</td><td>'; + $numcontrat=$formcontract->select_contract($soc->id,GETPOST('contratid','int'),'contratid',0,1); + if ($numcontrat==0) + { + print ' <a href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContract").'</a>'; + } + print '</td></tr>'; } - print '</td></tr>'; - } // Model print '<tr>'; @@ -1243,7 +1244,7 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'contrat') { 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 '</tr></table>'; @@ -1280,7 +1281,7 @@ else if ($id > 0 || ! empty($ref)) print '</td>'; print '</tr>'; } - + // Statut print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';