[CORE] intégration de incoterm sur les différentes class (#incoterm).

This commit is contained in:
phf 2015-02-23 09:16:14 +01:00
parent 24a970a109
commit 81130634d3
12 changed files with 308 additions and 17 deletions

View File

@ -1976,7 +1976,7 @@ if ($action == 'create')
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel'); print $langs->trans('IncotermLabel');
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->commande->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; if ($user->rights->propal->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';

View File

@ -58,6 +58,7 @@ $langs->load('compta');
$langs->load('products'); $langs->load('products');
$langs->load('banks'); $langs->load('banks');
$langs->load('main'); $langs->load('main');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->margin->enabled)) if (! empty($conf->margin->enabled))
$langs->load('margins'); $langs->load('margins');
@ -318,6 +319,12 @@ if (empty($reshook))
dol_print_error($db, $object->error); 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 // bank account
else if ($action == 'setbankaccount' && $user->rights->facture->creer) else if ($action == 'setbankaccount' && $user->rights->facture->creer)
{ {
@ -674,6 +681,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = $_POST['remise_absolue']; $object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent']; $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 // Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement']; $object->fk_facture_source = $_POST['fac_replacement'];
@ -718,6 +727,8 @@ if (empty($reshook))
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = $_POST['remise_absolue']; $object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent']; $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 // Proprietes particulieres a facture avoir
$object->fk_facture_source = $_POST['fac_avoir']; $object->fk_facture_source = $_POST['fac_avoir'];
@ -846,6 +857,8 @@ if (empty($reshook))
$object->amount = $_POST['amount']; $object->amount = $_POST['amount'];
$object->remise_absolue = $_POST['remise_absolue']; $object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent']; $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) if (GETPOST('type') == Facture::TYPE_SITUATION)
{ {
@ -2262,6 +2275,16 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
} }
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
print '</td></tr>';
}
// Other attributes // Other attributes
$parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"'); $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
@ -3362,6 +3385,29 @@ if ($action == 'create')
print '</tr>'; print '</tr>';
} }
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->facture->creer) print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
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 '</td></tr>';
}
// Other attributes // Other attributes
$cols = 5; $cols = 5;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -124,6 +124,11 @@ class Facture extends CommonInvoice
var $fac_rec; var $fac_rec;
//Incoterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/** /**
* @var int Situation cycle reference number * @var int Situation cycle reference number
*/ */
@ -237,6 +242,8 @@ class Facture extends CommonInvoice
$this->mode_reglement_id = $_facrec->mode_reglement_id; $this->mode_reglement_id = $_facrec->mode_reglement_id;
$this->remise_absolue = $_facrec->remise_absolue; $this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent; $this->remise_percent = $_facrec->remise_percent;
$this->fk_incoterms = $_facrec->fk_incoterms;
$this->location_incoterms= $_facrec->location_incoterms;
// Clean parametres // Clean parametres
if (! $this->type) $this->type = self::TYPE_STANDARD; 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_facture_source, fk_user_author, fk_projet";
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
$sql.= ", situation_cycle_ref, situation_counter, situation_final"; $sql.= ", situation_cycle_ref, situation_counter, situation_final";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'(PROV)'"; $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_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0); $sql.= ", ".($this->situation_final?$this->situation_final:0);
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.=")"; $sql.=")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -913,9 +923,12 @@ class Facture extends CommonInvoice
$sql.= ', f.fk_account'; $sql.= ', f.fk_account';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $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.= ', 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.= ' 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_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_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; $sql.= ' WHERE f.entity = '.$conf->entity;
if ($rowid) $sql.= " AND f.rowid=".$rowid; if ($rowid) $sql.= " AND f.rowid=".$rowid;
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; 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->situation_final = $obj->situation_final;
$this->extraparams = (array) json_decode($obj->extraparams, true); $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; if ($this->statut == 0) $this->brouillon = 1;
// Retreive all extrafield for invoice // Retreive all extrafield for invoice

View File

@ -51,6 +51,7 @@ $langs->load('orders');
$langs->load('stocks'); $langs->load('stocks');
$langs->load('other'); $langs->load('other');
$langs->load('propal'); $langs->load('propal');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); if (! empty($conf->productbatch->enabled)) $langs->load('productbatch');
$origin = GETPOST('origin','alpha')?GETPOST('origin','alpha'):'expedition'; // Example: commande, propal $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(); $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $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'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -143,6 +150,8 @@ if (empty($reshook))
$object->ref_int = GETPOST('ref_int','alpha'); $object->ref_int = GETPOST('ref_int','alpha');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$num=count($objectsrc->lines); $num=count($objectsrc->lines);
$totalqty=0; $totalqty=0;
@ -571,6 +580,16 @@ if ($action == 'create')
print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">'; print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">';
print "</td></tr>\n"; print "</td></tr>\n";
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
print '</td></tr>';
}
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="3"'); $parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook $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 $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number);
print '</td></tr>'; print '</td></tr>';
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->expedition->creer) print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
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 '</td></tr>';
}
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="3"'); $parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

View File

@ -90,6 +90,10 @@ class Expedition extends CommonObject
var $listmeths; // List of carriers var $listmeths; // List of carriers
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/** /**
* Constructor * Constructor
@ -214,6 +218,7 @@ class Expedition extends CommonObject
$sql.= ", note_private"; $sql.= ", note_private";
$sql.= ", note_public"; $sql.= ", note_public";
$sql.= ", model_pdf"; $sql.= ", model_pdf";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$conf->entity; $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_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"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.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); 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.= ", e.fk_shipping_method, e.tracking_number";
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; $sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
$sql.= ", e.note_private, e.note_public"; $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.= " 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."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; $sql.= " WHERE e.entity = ".$conf->entity;
if ($id) $sql.= " AND e.rowid=".$id; if ($id) $sql.= " AND e.rowid=".$id;
if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; 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->trueSize = $obj->size."x".$obj->width."x".$obj->height;
$this->size_units = $obj->size_units; $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); $this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;

View File

@ -86,6 +86,11 @@ class CommandeFournisseur extends CommonOrder
var $user_valid_id; var $user_valid_id;
var $user_approve_id; var $user_approve_id;
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
var $extraparams=array(); var $extraparams=array();
@ -137,10 +142,13 @@ class CommandeFournisseur extends CommonOrder
$sql.= " cm.libelle as methode_commande,"; $sql.= " cm.libelle as methode_commande,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; $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.= " 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.= " 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_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_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_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; $sql.= " WHERE c.entity = ".$conf->entity;
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
else $sql.= " AND c.rowid=".$id; else $sql.= " AND c.rowid=".$id;
@ -196,6 +204,11 @@ class CommandeFournisseur extends CommonOrder
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf; $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->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql); $this->db->free($resql);
@ -906,6 +919,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", fk_mode_reglement"; $sql.= ", fk_mode_reglement";
$sql.= ", fk_cond_reglement"; $sql.= ", fk_cond_reglement";
$sql.= ", fk_account"; $sql.= ", fk_account";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ") "; $sql.= ") ";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "''"; $sql.= "''";
@ -923,6 +937,8 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null'); $sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null');
$sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null'); $sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null');
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);

View File

@ -93,6 +93,11 @@ class FactureFournisseur extends CommonInvoice
var $fournisseur; // deprecated var $fournisseur; // deprecated
var $thirdparty; // To store thirdparty var $thirdparty; // To store thirdparty
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
var $extraparams=array(); var $extraparams=array();
/** /**
@ -186,6 +191,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", note_public"; $sql.= ", note_public";
$sql.= ", fk_user_author"; $sql.= ", fk_user_author";
$sql.= ", date_lim_reglement"; $sql.= ", date_lim_reglement";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
@ -203,6 +209,8 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", ".$user->id.","; $sql.= ", ".$user->id.",";
$sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null"; $sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null";
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -369,11 +377,14 @@ class FactureFournisseur extends CommonInvoice
$sql.= " t.extraparams,"; $sql.= " t.extraparams,";
$sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; $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.= " 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.= ' 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."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_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_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 ($id) $sql.= " WHERE t.rowid=".$id;
if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'"; if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'";
@ -433,6 +444,11 @@ class FactureFournisseur extends CommonInvoice
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->import_key = $obj->import_key; $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->extraparams = (array) json_decode($obj->extraparams, true);
$this->socid = $obj->socid; $this->socid = $obj->socid;

View File

@ -55,6 +55,7 @@ $langs->load('propal');
$langs->load('deliveries'); $langs->load('deliveries');
$langs->load('products'); $langs->load('products');
$langs->load('stocks'); $langs->load('stocks');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref','alpha'); $ref = GETPOST('ref','alpha');
@ -135,6 +136,12 @@ if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); $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 // bank account
if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer) 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->fk_account = GETPOST('fk_account', 'int');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public'); $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 // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -1284,6 +1293,16 @@ if ($action=="create")
print '</td></tr>'; print '</td></tr>';
} }
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''));
print '</td></tr>';
}
print '<tr><td>'.$langs->trans('NotePublic').'</td>'; print '<tr><td>'.$langs->trans('NotePublic').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); $doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
@ -1625,6 +1644,29 @@ elseif (! empty($object->id))
print '</tr>'; print '</tr>';
} }
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->fournisseur->commande->creer) print '<a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
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 '</td></tr>';
}
// Other attributes // Other attributes
$cols = 3; $cols = 3;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -52,6 +52,7 @@ $langs->load('suppliers');
$langs->load('companies'); $langs->load('companies');
$langs->load('products'); $langs->load('products');
$langs->load('banks'); $langs->load('banks');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
$action = GETPOST("action"); $action = GETPOST("action");
@ -224,6 +225,12 @@ else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); $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 // bank account
else if ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) { else if ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int')); $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->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null; $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 // Auto calculation of date due if not filled by user
if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
@ -1405,6 +1414,16 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
} }
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
print '</td></tr>';
}
// Bank Account // Bank Account
print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1); $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
@ -1950,6 +1969,29 @@ else
print '</tr>'; print '</tr>';
} }
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->fournisseur->facture->creer) print '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
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 '</td></tr>';
}
// Other attributes // Other attributes
$cols = 4; $cols = 4;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';

View File

@ -101,7 +101,12 @@ ALTER TABLE llx_contratdet_extrafields ADD INDEX idx_contratdet_extrafields (fk_
-- --
-- Module incoterm -- 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, fk_incoterms integer,
location_incoterms varchar(255) location_incoterms varchar(255)
); );
@ -111,7 +116,17 @@ ALTER TABLE llx_commande ADD COLUMN (
location_incoterms varchar(255) 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, fk_incoterms integer,
location_incoterms varchar(255) location_incoterms varchar(255)
); );
@ -126,16 +141,6 @@ ALTER TABLE llx_livraison ADD COLUMN (
location_incoterms varchar(255) 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 ( CREATE TABLE IF NOT EXISTS llx_c_incoterms (
rowid integer NOT NULL AUTO_INCREMENT, rowid integer NOT NULL AUTO_INCREMENT,
code varchar(3) NOT NULL, code varchar(3) NOT NULL,

View File

@ -43,6 +43,7 @@ $langs->load("sendings");
$langs->load("bills"); $langs->load("bills");
$langs->load('deliveries'); $langs->load('deliveries');
$langs->load('orders'); $langs->load('orders');
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha'); $confirm=GETPOST('confirm', 'alpha');
@ -80,6 +81,7 @@ if ($action == 'add')
$object->date_livraison = time(); $object->date_livraison = time();
$object->note = $_POST["note"]; $object->note = $_POST["note"];
$object->commande_id = $_POST["commande_id"]; $object->commande_id = $_POST["commande_id"];
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled)) if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
{ {
@ -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 * Build document
*/ */
@ -579,6 +587,29 @@ else
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->expedition->livraison->creer) print '<a href="'.DOL_URL_ROOT.'/livaison/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
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 '</td></tr>';
}
// Note Public // Note Public
print '<tr><td>'.$langs->trans("NotePublic").'</td>'; print '<tr><td>'.$langs->trans("NotePublic").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';

View File

@ -60,6 +60,10 @@ class Livraison extends CommonObject
var $date_valid; var $date_valid;
var $model_pdf; var $model_pdf;
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/** /**
* Constructor * Constructor
@ -115,6 +119,7 @@ class Livraison extends CommonObject
$sql.= ", note_private"; $sql.= ", note_private";
$sql.= ", note_public"; $sql.= ", note_public";
$sql.= ", model_pdf"; $sql.= ", model_pdf";
$sql.= ", fk_incoterms, location_incoterms";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$conf->entity; $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_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"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.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")"; $sql.= ")";
dol_syslog("Livraison::create", LOG_DEBUG); 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.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.= ", l.date_delivery, l.fk_address, l.model_pdf";
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; $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.= " 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."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; $sql.= " WHERE l.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); 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 = $obj->origin; // May be 'shipping'
$this->origin_id = $obj->origin_id; // May be id of 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); $this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
@ -515,6 +529,10 @@ class Livraison extends CommonObject
$this->socid = $expedition->socid; $this->socid = $expedition->socid;
$this->ref_customer = $expedition->ref_customer; $this->ref_customer = $expedition->ref_customer;
//Incoterms
$this->fk_incoterms = $expedition->fk_incoterms;
$this->location_incoterms = $expedition->location_incoterms;
return $this->create($user); return $this->create($user);
} }