[CORE] incorporation de l'ajout / modification de l'incoterm sur un tiers (#incoterm
This commit is contained in:
parent
c7e1528594
commit
62762f82a9
@ -558,6 +558,77 @@ class Form
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return select list of incoterms
|
||||
*
|
||||
* @param string $selected Id or Code of preselected incoterm
|
||||
* @param string $htmlname Name of html select object
|
||||
* @param string $htmloption Options html on select object
|
||||
* @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)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$langs->load("dict");
|
||||
|
||||
$out='';
|
||||
$incotermArray=array();
|
||||
|
||||
$sql = "SELECT rowid, code";
|
||||
$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.'>';
|
||||
$out.= '<option value=""></option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
$foundselected=false;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$incotermArray[$i]['rowid'] = $obj->rowid;
|
||||
$incotermArray[$i]['code'] = $obj->code;
|
||||
$i++;
|
||||
}
|
||||
|
||||
foreach ($incotermArray as $row)
|
||||
{
|
||||
if ($selected && ($selected == $row['rowid'] || $selected == $row['code']))
|
||||
{
|
||||
$out.= '<option value="'.$row['rowid'].'" selected="selected">';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= '<option value="'.$row['rowid'].'">';
|
||||
}
|
||||
|
||||
$out.= dol_trunc($row['label'],$maxlength,'middle');
|
||||
|
||||
if ($row['code']) $out.= $row['code'];
|
||||
|
||||
$out.= '</option>';
|
||||
}
|
||||
}
|
||||
$out.= '</select>';
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of types of lines (product or service)
|
||||
* Example: 0=product, 1=service, 9=other (for external module)
|
||||
|
||||
@ -352,6 +352,11 @@ class Societe extends CommonObject
|
||||
|
||||
var $array_options;
|
||||
|
||||
// Incoterms
|
||||
var $fk_incoterms;
|
||||
var $location_incoterms;
|
||||
var $libelle_incoterms; //Used into tooltip
|
||||
|
||||
/**
|
||||
* To contains a clone of this when we need to save old properties of object
|
||||
*/
|
||||
@ -424,7 +429,7 @@ class Societe extends CommonObject
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, import_key)";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key)";
|
||||
$sql.= " VALUES ('".$this->db->escape($this->name)."', ".$conf->entity.", '".$this->db->idate($now)."'";
|
||||
$sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null");
|
||||
$sql.= ", ".(! empty($this->canvas) ? "'".$this->canvas."'":"null");
|
||||
@ -432,6 +437,8 @@ class Societe extends CommonObject
|
||||
$sql.= ", ".(! empty($this->ref_int) ? "'".$this->ref_int."'":"null");
|
||||
$sql.= ", ".(! empty($this->ref_ext) ? "'".$this->ref_ext."'":"null");
|
||||
$sql.= ", 0";
|
||||
$sql.= ", ".(int) $this->fk_incoterms;
|
||||
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
|
||||
$sql.= ", ".(! empty($this->import_key) ? "'".$this->import_key."'":"null").")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
@ -731,6 +738,10 @@ class Societe extends CommonObject
|
||||
$this->webservices_url = $this->webservices_url?clean_url($this->webservices_url,0):'';
|
||||
$this->webservices_key = trim($this->webservices_key);
|
||||
|
||||
//Incoterms
|
||||
$this->fk_incoterms = (int) $this->fk_incoterms;
|
||||
$this->location_incoterms = trim($this->location_incoterms);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Check name is required and codes are ok or unique.
|
||||
@ -814,6 +825,10 @@ class Societe extends CommonObject
|
||||
$sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null");
|
||||
$sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null");
|
||||
|
||||
//Incoterms
|
||||
$sql.= ", fk_incoterms = ".$this->fk_incoterms;
|
||||
$sql.= ", location_incoterms = ".(! empty($this->location_incoterms)?"'".$this->db->escape($this->location_incoterms)."'":"null");
|
||||
|
||||
if ($customer)
|
||||
{
|
||||
$sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null");
|
||||
@ -976,13 +991,14 @@ class Societe extends CommonObject
|
||||
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
||||
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
|
||||
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
|
||||
$sql .= ', s.outstanding_limit, s.import_key, s.canvas';
|
||||
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
|
||||
$sql .= ', fj.libelle as forme_juridique';
|
||||
$sql .= ', e.libelle as effectif';
|
||||
$sql .= ', c.code as country_code, c.label as country';
|
||||
$sql .= ', d.code_departement as state_code, d.nom as state';
|
||||
$sql .= ', st.libelle as stcomm';
|
||||
$sql .= ', te.code as typent_code';
|
||||
$sql .= ', i.libelle as libelle_incoterms';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as e ON s.fk_effectif = e.id';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
|
||||
@ -990,6 +1006,7 @@ class Societe extends CommonObject
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as fj ON s.fk_forme_juridique = fj.code';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid';
|
||||
if ($rowid) $sql .= ' WHERE s.rowid = '.$rowid;
|
||||
if ($ref) $sql .= " WHERE s.nom = '".$this->db->escape($ref)."' AND s.entity IN (".getEntity($this->element, 1).")";
|
||||
if ($ref_ext) $sql .= " WHERE s.ref_ext = '".$this->db->escape($ref_ext)."' AND s.entity IN (".getEntity($this->element, 1).")";
|
||||
@ -1118,6 +1135,11 @@ class Societe extends CommonObject
|
||||
|
||||
$this->import_key = $obj->import_key;
|
||||
|
||||
//Incoterms
|
||||
$this->fk_incoterms = $obj->fk_incoterms;
|
||||
$this->location_incoterms = $obj->location_incoterms;
|
||||
$this->libelle_incoterms = $obj->libelle_incoterms;
|
||||
|
||||
$result = 1;
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
@ -2067,6 +2089,31 @@ class Societe extends CommonObject
|
||||
$bac->fetch(0,$this->id);
|
||||
return $bac->getRibLabel(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return incoterms informations
|
||||
*
|
||||
* @return string Bank number
|
||||
*/
|
||||
function display_incoterms()
|
||||
{
|
||||
$out = '';
|
||||
$this->incoterms_libelle = '';
|
||||
if (!empty($this->fk_incoterms))
|
||||
{
|
||||
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$res = $this->db->fetch_object($result);
|
||||
$out .= $res->code;
|
||||
}
|
||||
}
|
||||
|
||||
$out .= ' - '.$this->location_incoterms;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Array of RIB
|
||||
|
||||
@ -45,6 +45,7 @@ $langs->load("commercial");
|
||||
$langs->load("bills");
|
||||
$langs->load("banks");
|
||||
$langs->load("users");
|
||||
if ($conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE)) $langs->load("incoterm");
|
||||
if (! empty($conf->notification->enabled)) $langs->load("mails");
|
||||
|
||||
$mesg=''; $error=0; $errors=array();
|
||||
@ -191,6 +192,12 @@ if (empty($reshook))
|
||||
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
|
||||
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
|
||||
|
||||
// Incoterms
|
||||
if ($conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE))
|
||||
{
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
@ -1074,7 +1081,18 @@ else
|
||||
$form->select_users((! empty($object->commercial_id)?$object->commercial_id:$user->id),'commercial_id',1); // Add current user by default
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Incoterms
|
||||
if ($conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE))
|
||||
{
|
||||
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 '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
@ -1197,6 +1215,13 @@ else
|
||||
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
|
||||
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
|
||||
|
||||
//Incoterms
|
||||
if ($conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE))
|
||||
{
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha');
|
||||
}
|
||||
|
||||
//Local Taxes
|
||||
$object->localtax1_assuj = GETPOST('localtax1assuj_value');
|
||||
$object->localtax2_assuj = GETPOST('localtax2assuj_value');
|
||||
@ -1584,6 +1609,17 @@ else
|
||||
print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.'"></td></tr>';
|
||||
}
|
||||
|
||||
// Incoterms
|
||||
if ($conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE))
|
||||
{
|
||||
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 '</td></tr>';
|
||||
}
|
||||
|
||||
// Logo
|
||||
print '<tr class="hideonsmartphone">';
|
||||
print '<td><label for="photoinput">'.$langs->trans("Logo").'</label></td>';
|
||||
@ -1970,6 +2006,22 @@ else
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Incoterms
|
||||
if ($conf->incoterm->enabled && !empty($conf->global->INCOTERM_ACTIVATE))
|
||||
{
|
||||
print '<tr><td>';
|
||||
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>';
|
||||
else print ' ';
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
Loading…
Reference in New Issue
Block a user