[CORE] fin de la mise en place de la gestion incoterms des sociétés (#incoterm).
This commit is contained in:
parent
792ec17993
commit
23751c75dc
@ -567,7 +567,7 @@ class Form
|
||||
* @param string $maxlength Max length for labels (0=no limit)
|
||||
* @return string HTML string with select
|
||||
*/
|
||||
function select_incoterms($selected='',$htmlname='incoterm_id',$htmloption='',$maxlength=0)
|
||||
function select_incoterms($selected='', $location_incoterms='', $page='',$htmlname='incoterm_id',$htmloption='', $forcecombo=0, $events=array())
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -580,12 +580,25 @@ class Form
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_incoterms";
|
||||
$sql.= " WHERE active = 1";
|
||||
$sql.= " ORDER BY code ASC";
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$out.= '<select id="select'.$htmlname.'" class="flat selectincoterm" name="'.$htmlname.'" '.$htmloption.'>';
|
||||
if (!$forcecombo)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname, $events);
|
||||
}
|
||||
|
||||
if (!empty($page))
|
||||
{
|
||||
$out .= '<form method="post" action="'.$page.'">';
|
||||
$out .= '<input type="hidden" name="action" value="set_incoterms">';
|
||||
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
}
|
||||
|
||||
$out.= '<select id="'.$htmlname.'" class="flat selectincoterm" name="'.$htmlname.'" '.$htmloption.'>';
|
||||
$out.= '<option value=""></option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
@ -612,14 +625,19 @@ class Form
|
||||
$out.= '<option value="'.$row['rowid'].'">';
|
||||
}
|
||||
|
||||
$out.= dol_trunc($row['label'],$maxlength,'middle');
|
||||
|
||||
if ($row['code']) $out.= $row['code'];
|
||||
|
||||
$out.= '</option>';
|
||||
}
|
||||
}
|
||||
$out.= '</select>';
|
||||
|
||||
$out .= '<input id="location_incoterms" name="location_incoterms" size="14" value="'.$location_incoterms.'">';
|
||||
|
||||
if (!empty($page))
|
||||
{
|
||||
$out .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -521,6 +521,12 @@ if (empty($reshook))
|
||||
$result = $object->set_parent(GETPOST('editparentcompany','int'));
|
||||
}
|
||||
|
||||
// Set incoterm
|
||||
if ($action == 'set_incoterms' && $conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE))
|
||||
{
|
||||
$object->fetch($socid);
|
||||
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
|
||||
}
|
||||
|
||||
// Actions to send emails
|
||||
$id=$socid;
|
||||
@ -1088,8 +1094,7 @@ else
|
||||
print '<tr>';
|
||||
print '<td><label for="incoterm_id">'.$langs->trans("IncotermLabel").'</label></td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''));
|
||||
print '<input id="location_incoterms" name="location_incoterms" size="14" value="'.(!empty($object->location_incoterms)?$object->location_incoterms:'').'">';
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -1615,8 +1620,7 @@ else
|
||||
print '<tr>';
|
||||
print '<td><label for="incoterm_id">'.$langs->trans("IncotermLabel").'</label></td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''));
|
||||
print '<input id="location_incoterms" name="location_incoterms" size="14" value="'.$object->location_incoterms.'">';
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -2013,12 +2017,19 @@ else
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('IncotermLabel');
|
||||
print '<td><td align="right">';
|
||||
if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$object->id.'&action=set_incoterms">'.img_edit().'</a>';
|
||||
if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
||||
else print ' ';
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
|
||||
if ($action != 'editincoterm')
|
||||
{
|
||||
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?socid='.$object->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user