Show ref in contract form on interventions
This commit is contained in:
parent
3281d5ec17
commit
c2590433fe
@ -58,9 +58,10 @@ class FormContract
|
|||||||
* @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
|
* @param int $showempty Show empty line
|
||||||
|
* @param int $showRef Show customer and supplier reference on each contract (when found)
|
||||||
* @return int Nbr of project if OK, <0 if KO
|
* @return int Nbr of project if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1)
|
public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $db, $user, $conf, $langs;
|
global $db, $user, $conf, $langs;
|
||||||
@ -70,6 +71,10 @@ class FormContract
|
|||||||
|
|
||||||
// Search all contacts
|
// Search all contacts
|
||||||
$sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut';
|
$sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut';
|
||||||
|
if($showRef)
|
||||||
|
{
|
||||||
|
$sql .= ', c.ref_customer, c.ref_supplier';
|
||||||
|
}
|
||||||
$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.")";
|
||||||
@ -105,6 +110,13 @@ class FormContract
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
} else {
|
} else {
|
||||||
$labeltoshow = dol_trunc($obj->ref, 18);
|
$labeltoshow = dol_trunc($obj->ref, 18);
|
||||||
|
|
||||||
|
if($showRef)
|
||||||
|
{
|
||||||
|
if($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer;
|
||||||
|
if($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier;
|
||||||
|
}
|
||||||
|
|
||||||
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
|
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
|
||||||
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
//else $labeltoshow.=' ('.$langs->trans("Private").')';
|
||||||
if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
|
if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
|
||||||
@ -166,9 +178,10 @@ class FormContract
|
|||||||
* @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
|
* @param int $showempty Show empty line
|
||||||
|
* @param int $showRef Show customer and supplier reference on each contract (when found)
|
||||||
* @return int Nbr of project if OK, <0 if KO
|
* @return int Nbr of project if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1)
|
public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
@ -176,7 +189,7 @@ class FormContract
|
|||||||
print '<form method="post" action="'.$page.'">';
|
print '<form method="post" action="'.$page.'">';
|
||||||
print '<input type="hidden" name="action" value="setcontract">';
|
print '<input type="hidden" name="action" value="setcontract">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
$this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty);
|
$this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef);
|
||||||
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -906,7 +906,7 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
$langs->load("contracts");
|
$langs->load("contracts");
|
||||||
print '<tr><td>'.$langs->trans("Contract").'</td><td>';
|
print '<tr><td>'.$langs->trans("Contract").'</td><td>';
|
||||||
$numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1);
|
$numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1, 1);
|
||||||
if ($numcontrat == 0)
|
if ($numcontrat == 0)
|
||||||
{
|
{
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddContract").'"></span></a>';
|
print ' <a href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddContract").'"></span></a>';
|
||||||
@ -1238,7 +1238,7 @@ if ($action == 'create')
|
|||||||
if ($action == 'contrat')
|
if ($action == 'contrat')
|
||||||
{
|
{
|
||||||
$formcontract = new Formcontract($db);
|
$formcontract = new Formcontract($db);
|
||||||
$formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1);
|
$formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
if ($object->fk_contrat)
|
if ($object->fk_contrat)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user