diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index f044af50980..57ac3a8bbcd 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1976,7 +1976,7 @@ if ($action == 'create')
print '
| ';
print $langs->trans('IncotermLabel');
print ' | | ';
- if ($user->rights->commande->creer) print ''.img_edit().'';
+ if ($user->rights->propal->creer) print ''.img_edit().'';
else print ' ';
print ' |
';
print '';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 1459dac849e..8cb304daf27 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -58,6 +58,7 @@ $langs->load('compta');
$langs->load('products');
$langs->load('banks');
$langs->load('main');
+if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->margin->enabled))
$langs->load('margins');
@@ -318,6 +319,12 @@ if (empty($reshook))
dol_print_error($db, $object->error);
}
+ // Set incoterm
+ elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
+ {
+ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
+ }
+
// bank account
else if ($action == 'setbankaccount' && $user->rights->facture->creer)
{
@@ -674,6 +681,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement'];
@@ -718,6 +727,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Proprietes particulieres a facture avoir
$object->fk_facture_source = $_POST['fac_avoir'];
@@ -846,6 +857,8 @@ if (empty($reshook))
$object->amount = $_POST['amount'];
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
if (GETPOST('type') == Facture::TYPE_SITUATION)
{
@@ -2262,6 +2275,16 @@ if ($action == 'create')
print '';
}
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print ' | ';
+ print '';
+ print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
+ print ' |
';
+ }
+
// Other attributes
$parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
@@ -3361,6 +3384,29 @@ if ($action == 'create')
print '';
print '';
}
+
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->facture->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 = 5;
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5c645783cc1..3dd4076188b 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -123,6 +123,11 @@ class Facture extends CommonInvoice
var $specimen;
var $fac_rec;
+
+ //Incoterms
+ var $fk_incoterms;
+ var $location_incoterms;
+ var $libelle_incoterms; //Used into tooltip
/**
* @var int Situation cycle reference number
@@ -237,6 +242,8 @@ class Facture extends CommonInvoice
$this->mode_reglement_id = $_facrec->mode_reglement_id;
$this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent;
+ $this->fk_incoterms = $_facrec->fk_incoterms;
+ $this->location_incoterms= $_facrec->location_incoterms;
// Clean parametres
if (! $this->type) $this->type = self::TYPE_STANDARD;
@@ -271,6 +278,7 @@ class Facture extends CommonInvoice
$sql.= ", fk_facture_source, fk_user_author, fk_projet";
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
$sql.= ", situation_cycle_ref, situation_counter, situation_final";
+ $sql.= ", fk_incoterms, location_incoterms";
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
@@ -296,6 +304,8 @@ class Facture extends CommonInvoice
$sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0);
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.=")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -913,9 +923,12 @@ class Facture extends CommonInvoice
$sql.= ', f.fk_account';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
+ $sql.= ', f.fk_incoterms, f.location_incoterms';
+ $sql.= ", i.libelle as libelle_incoterms";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
$sql.= ' WHERE f.entity = '.$conf->entity;
if ($rowid) $sql.= " AND f.rowid=".$rowid;
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
@@ -975,6 +988,11 @@ class Facture extends CommonInvoice
$this->situation_final = $obj->situation_final;
$this->extraparams = (array) json_decode($obj->extraparams, true);
+ //Incoterms
+ $this->fk_incoterms = $obj->fk_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
+ $this->libelle_incoterms = $obj->libelle_incoterms;
+
if ($this->statut == 0) $this->brouillon = 1;
// Retreive all extrafield for invoice
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 7e7b3cf6e3b..c9e3609eafa 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -51,6 +51,7 @@ $langs->load('orders');
$langs->load('stocks');
$langs->load('other');
$langs->load('propal');
+if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->productbatch->enabled)) $langs->load('productbatch');
$origin = GETPOST('origin','alpha')?GETPOST('origin','alpha'):'expedition'; // Example: commande, propal
@@ -104,6 +105,12 @@ if (($action == 'create') || ($action == 'add'))
}
}
+// Set incoterm
+if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
+{
+ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
+}
+
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -143,6 +150,8 @@ if (empty($reshook))
$object->ref_int = GETPOST('ref_int','alpha');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$num=count($objectsrc->lines);
$totalqty=0;
@@ -571,6 +580,16 @@ if ($action == 'create')
print '';
print "\n";
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print ' | ';
+ print '';
+ print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
+ print ' |
';
+ }
+
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook
@@ -1159,6 +1178,29 @@ else if ($id || $ref)
print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number);
print '';
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->expedition->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
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 67426510da2..03f4868dbbf 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -90,6 +90,10 @@ class Expedition extends CommonObject
var $listmeths; // List of carriers
+ //Incorterms
+ var $fk_incoterms;
+ var $location_incoterms;
+ var $libelle_incoterms; //Used into tooltip
/**
* Constructor
@@ -214,6 +218,7 @@ class Expedition extends CommonObject
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ", model_pdf";
+ $sql.= ", fk_incoterms, location_incoterms";
$sql.= ") VALUES (";
$sql.= "'(PROV)'";
$sql.= ", ".$conf->entity;
@@ -236,6 +241,8 @@ class Expedition extends CommonObject
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -414,8 +421,11 @@ class Expedition extends CommonObject
$sql.= ", e.fk_shipping_method, e.tracking_number";
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
$sql.= ", e.note_private, e.note_public";
+ $sql.= ', e.fk_incoterms, e.location_incoterms';
+ $sql.= ', i.libelle as libelle_incoterms';
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->element."'";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid';
$sql.= " WHERE e.entity = ".$conf->entity;
if ($id) $sql.= " AND e.rowid=".$id;
if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'";
@@ -468,6 +478,11 @@ class Expedition extends CommonObject
$this->trueSize = $obj->size."x".$obj->width."x".$obj->height;
$this->size_units = $obj->size_units;
+ //Incoterms
+ $this->fk_incoterms = $obj->fk_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
+ $this->libelle_incoterms = $obj->libelle_incoterms;
+
$this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1;
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 7f2237859ea..19819e55387 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -86,6 +86,11 @@ class CommandeFournisseur extends CommonOrder
var $user_valid_id;
var $user_approve_id;
+ //Incorterms
+ var $fk_incoterms;
+ var $location_incoterms;
+ var $libelle_incoterms; //Used into tooltip
+
var $extraparams=array();
@@ -137,10 +142,13 @@ class CommandeFournisseur extends CommonOrder
$sql.= " cm.libelle as methode_commande,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
$sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle";
+ $sql.= ', c.fk_incoterms, c.location_incoterms';
+ $sql.= ', i.libelle as libelle_incoterms';
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
$sql.= " WHERE c.entity = ".$conf->entity;
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
else $sql.= " AND c.rowid=".$id;
@@ -196,6 +204,11 @@ class CommandeFournisseur extends CommonOrder
$this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf;
+ //Incoterms
+ $this->fk_incoterms = $obj->fk_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
+ $this->libelle_incoterms = $obj->libelle_incoterms;
+
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql);
@@ -906,6 +919,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", fk_mode_reglement";
$sql.= ", fk_cond_reglement";
$sql.= ", fk_account";
+ $sql.= ", fk_incoterms, location_incoterms";
$sql.= ") ";
$sql.= " VALUES (";
$sql.= "''";
@@ -923,6 +937,8 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null');
$sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null');
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -2203,7 +2219,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
-
+
$this->db->free($result);
return 1;
}
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 71e5c320dfa..4260f23a343 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -93,6 +93,11 @@ class FactureFournisseur extends CommonInvoice
var $fournisseur; // deprecated
var $thirdparty; // To store thirdparty
+ //Incorterms
+ var $fk_incoterms;
+ var $location_incoterms;
+ var $libelle_incoterms; //Used into tooltip
+
var $extraparams=array();
/**
@@ -186,6 +191,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", note_public";
$sql.= ", fk_user_author";
$sql.= ", date_lim_reglement";
+ $sql.= ", fk_incoterms, location_incoterms";
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
@@ -203,6 +209,8 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", ".$user->id.",";
$sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null";
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -369,11 +377,14 @@ class FactureFournisseur extends CommonInvoice
$sql.= " t.extraparams,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
$sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,";
- $sql.= ' s.nom as socnom, s.rowid as socid';
+ $sql.= ' s.nom as socnom, s.rowid as socid,';
+ $sql.= ' t.fk_incoterms, t.location_incoterms,';
+ $sql.= " i.libelle as libelle_incoterms";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (t.fk_cond_reglement = cr.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (t.fk_mode_reglement = p.id)";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid';
if ($id) $sql.= " WHERE t.rowid=".$id;
if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'";
@@ -433,6 +444,11 @@ class FactureFournisseur extends CommonInvoice
$this->modelpdf = $obj->model_pdf;
$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;
+
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->socid = $obj->socid;
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index fe22a154251..b4857d4f9c3 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -55,6 +55,7 @@ $langs->load('propal');
$langs->load('deliveries');
$langs->load('products');
$langs->load('stocks');
+if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
@@ -135,6 +136,12 @@ if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
}
+// Set incoterm
+if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
+{
+ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
+}
+
// bank account
if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer)
{
@@ -844,6 +851,8 @@ if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$object->fk_account = GETPOST('fk_account', 'int');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
+ $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);
@@ -1284,6 +1293,16 @@ if ($action=="create")
print '';
}
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print ' | ';
+ print '';
+ print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
+ print ' |
';
+ }
+
print '| '.$langs->trans('NotePublic').' | ';
print '';
$doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
@@ -1624,7 +1643,30 @@ elseif (! empty($object->id))
print ' | ';
print '
';
}
-
+
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->fournisseur->commande->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';
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 325a9e5d591..290585ac080 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -52,6 +52,7 @@ $langs->load('suppliers');
$langs->load('companies');
$langs->load('products');
$langs->load('banks');
+if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
$action = GETPOST("action");
@@ -224,6 +225,12 @@ else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
}
+// Set incoterm
+elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
+{
+ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
+}
+
// bank account
else if ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
@@ -328,6 +335,8 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// Auto calculation of date due if not filled by user
if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
@@ -1404,6 +1413,16 @@ if ($action == 'create')
$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1'), $projectid, 'projectid', 0);
print '';
}
+
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print ' | ';
+ print '';
+ print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
+ print ' |
';
+ }
// Bank Account
print '| '.$langs->trans('BankAccount').' | ';
@@ -1950,6 +1969,29 @@ else
print ' |
';
}
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->fournisseur->facture->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 = 4;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
index 360c99af189..385268b1ad7 100755
--- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
+++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
@@ -101,7 +101,12 @@ ALTER TABLE llx_contratdet_extrafields ADD INDEX idx_contratdet_extrafields (fk_
--
-- Module incoterm
--
-ALTER TABLE llx_facture ADD COLUMN (
+ALTER TABLE llx_societe ADD COLUMN (
+ fk_incoterms integer,
+ location_incoterms varchar(255)
+);
+
+ALTER TABLE llx_propal ADD COLUMN (
fk_incoterms integer,
location_incoterms varchar(255)
);
@@ -111,7 +116,17 @@ ALTER TABLE llx_commande ADD COLUMN (
location_incoterms varchar(255)
);
-ALTER TABLE llx_propal ADD COLUMN (
+ALTER TABLE llx_commande_fournisseur ADD COLUMN (
+ fk_incoterms integer,
+ location_incoterms varchar(255)
+);
+
+ALTER TABLE llx_facture ADD COLUMN (
+ fk_incoterms integer,
+ location_incoterms varchar(255)
+);
+
+ALTER TABLE llx_facture_fourn ADD COLUMN (
fk_incoterms integer,
location_incoterms varchar(255)
);
@@ -126,16 +141,6 @@ ALTER TABLE llx_livraison ADD COLUMN (
location_incoterms varchar(255)
);
-ALTER TABLE llx_societe ADD COLUMN (
- fk_incoterms integer,
- location_incoterms varchar(255)
-);
-
-ALTER TABLE llx_commande_fournisseur ADD COLUMN (
- fk_incoterms integer,
- location_incoterms varchar(255)
-);
-
CREATE TABLE IF NOT EXISTS llx_c_incoterms (
rowid integer NOT NULL AUTO_INCREMENT,
code varchar(3) NOT NULL,
diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php
index 4ab76afe239..e50fb9c8ea8 100644
--- a/htdocs/livraison/card.php
+++ b/htdocs/livraison/card.php
@@ -43,6 +43,7 @@ $langs->load("sendings");
$langs->load("bills");
$langs->load('deliveries');
$langs->load('orders');
+if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
@@ -80,7 +81,8 @@ if ($action == 'add')
$object->date_livraison = time();
$object->note = $_POST["note"];
$object->commande_id = $_POST["commande_id"];
-
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
{
$expedition->entrepot_id = $_POST["entrepot_id"];
@@ -173,6 +175,12 @@ if ($action == 'setdate_livraison' && $user->rights->expedition->livraison->cree
}
}
+// Set incoterm
+elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
+{
+ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
+}
+
/*
* Build document
*/
@@ -579,6 +587,29 @@ else
print '';
print '';
+ // Incoterms
+ if (!empty($conf->incoterm->enabled))
+ {
+ print '';
+ print '| ';
+ print $langs->trans('IncotermLabel');
+ print ' | | ';
+ if ($user->rights->expedition->livraison->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 ' |
';
+ }
+
// Note Public
print '| '.$langs->trans("NotePublic").' | ';
print '';
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index e12781d5228..f1e9e3d6ca6 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -60,6 +60,10 @@ class Livraison extends CommonObject
var $date_valid;
var $model_pdf;
+ //Incorterms
+ var $fk_incoterms;
+ var $location_incoterms;
+ var $libelle_incoterms; //Used into tooltip
/**
* Constructor
@@ -115,6 +119,7 @@ class Livraison extends CommonObject
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ", model_pdf";
+ $sql.= ", fk_incoterms, location_incoterms";
$sql.= ") VALUES (";
$sql.= "'(PROV)'";
$sql.= ", ".$conf->entity;
@@ -127,6 +132,8 @@ class Livraison extends CommonObject
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog("Livraison::create", LOG_DEBUG);
@@ -265,8 +272,11 @@ class Livraison extends CommonObject
$sql.=" l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
$sql.= ", l.date_delivery, l.fk_address, l.model_pdf";
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
+ $sql.= ', l.fk_incoterms, l.location_incoterms';
+ $sql.= ", i.libelle as libelle_incoterms";
$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->element."'";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON l.fk_incoterms = i.rowid';
$sql.= " WHERE l.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@@ -295,6 +305,10 @@ class Livraison extends CommonObject
$this->origin = $obj->origin; // May be 'shipping'
$this->origin_id = $obj->origin_id; // May be id of shipping
+ //Incoterms
+ $this->fk_incoterms = $obj->fk_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
+ $this->libelle_incoterms = $obj->libelle_incoterms;
$this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1;
@@ -514,6 +528,10 @@ class Livraison extends CommonObject
$this->fk_delivery_address = $expedition->fk_delivery_address;
$this->socid = $expedition->socid;
$this->ref_customer = $expedition->ref_customer;
+
+ //Incoterms
+ $this->fk_incoterms = $expedition->fk_incoterms;
+ $this->location_incoterms = $expedition->location_incoterms;
return $this->create($user);
}
|