diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 302b49fbdb7..d6b130749ed 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -53,6 +53,7 @@ $langs->load('orders');
$langs->load('products');
$langs->load("deliveries");
$langs->load('sendings');
+if ($conf->incoterm->enabled) $langs->load('incoterm');
if (! empty($conf->margin->enabled))
$langs->load('margins');
@@ -240,6 +241,12 @@ if (empty($reshook))
{
$object->set_ref_client($user, $_POST['ref_client']);
}
+
+ // Set incoterm
+ elseif ($action == 'set_incoterms' && $conf->incoterm->enabled)
+ {
+ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
+ }
// Create proposal
else if ($action == 'add' && $user->rights->propal->creer)
@@ -296,6 +303,8 @@ if (empty($reshook))
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->statut = 0;
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$id = $object->create_from($user);
} else {
@@ -319,6 +328,8 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid');
@@ -1388,6 +1399,16 @@ if ($action == 'create')
print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
print "";
+ // Incoterms
+ if ($conf->incoterm->enabled)
+ {
+ print '
';
+ print ' | ';
+ print '';
+ print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
+ print ' |
';
+ }
+
// Project
if (! empty($conf->projet->enabled) && $socid > 0)
{
@@ -1948,6 +1969,29 @@ if ($action == 'create')
print '';
}
+ // Incoterms
+ if ($conf->incoterm->enabled)
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->societe->creer) print ''.img_edit().'';
+ else print ' ';
+ print ' | ';
+ print ' | ';
+ print '';
+ 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'].'?id='.$object->id);
+ }
+ print ' |
';
+ }
+
// Other attributes
$cols = 3;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
@@ -1964,7 +2008,7 @@ if ($action == 'create')
print '';
}
print '';
-
+
// Amount VAT
print '| ' . $langs->trans('AmountVAT') . ' | ';
print '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . ' | ';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 8fae698ba94..b05a9c2a8b5 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -121,6 +121,11 @@ class Propal extends CommonObject
var $nbtodolate;
var $specimen;
+
+ //Incorterms
+ var $fk_incoterms;
+ var $location_incoterms;
+ var $libelle_incoterms; //Used into tooltip
/**
@@ -745,6 +750,8 @@ class Propal extends CommonObject
$sql.= ", fk_availability";
$sql.= ", fk_input_reason";
$sql.= ", fk_projet";
+ $sql.= ", fk_incoterms";
+ $sql.= ", location_incoterms";
$sql.= ", entity";
$sql.= ") ";
$sql.= " VALUES (";
@@ -772,6 +779,8 @@ class Propal extends CommonObject
$sql.= ", ".$this->availability_id;
$sql.= ", ".$this->demand_reason_id;
$sql.= ", ".($this->fk_project?$this->fk_project:"null");
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
@@ -1088,6 +1097,8 @@ class Propal extends CommonObject
$sql.= ", p.fk_mode_reglement";
$sql.= ', p.fk_account';
$sql.= ", p.fk_shipping_method";
+ $sql.= ", p.fk_incoterms, p.location_incoterms";
+ $sql.= ", i.libelle as libelle_incoterms";
$sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
@@ -1098,6 +1109,7 @@ class Propal extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
$sql.= " WHERE p.fk_statut = c.id";
$sql.= " AND p.entity = ".$conf->entity;
if ($ref) $sql.= " AND p.ref='".$ref."'";
@@ -1165,6 +1177,11 @@ class Propal extends CommonObject
$this->user_valid_id = $obj->fk_user_valid;
$this->user_close_id = $obj->fk_user_cloture;
+ //Incoterms
+ $this->fk_incoterms = $obj->fk_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
+ $this->libelle_incoterms = $obj->libelle_incoterms;
+
if ($obj->fk_statut == 0)
{
$this->brouillon = 1;