[CORE] ajout de l'incoterm sur les pages propal et à l'objet (#incoterm).

This commit is contained in:
phf 2015-02-10 11:46:35 +01:00
parent 2a1a5e74c6
commit 36304234d2
2 changed files with 62 additions and 1 deletions

View File

@ -53,6 +53,7 @@ $langs->load('orders');
$langs->load('products'); $langs->load('products');
$langs->load("deliveries"); $langs->load("deliveries");
$langs->load('sendings'); $langs->load('sendings');
if ($conf->incoterm->enabled) $langs->load('incoterm');
if (! empty($conf->margin->enabled)) if (! empty($conf->margin->enabled))
$langs->load('margins'); $langs->load('margins');
@ -241,6 +242,12 @@ if (empty($reshook))
$object->set_ref_client($user, $_POST['ref_client']); $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 // Create proposal
else if ($action == 'add' && $user->rights->propal->creer) else if ($action == 'add' && $user->rights->propal->creer)
{ {
@ -296,6 +303,8 @@ if (empty($reshook))
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note = GETPOST('note'); $object->note = GETPOST('note');
$object->statut = 0; $object->statut = 0;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$id = $object->create_from($user); $id = $object->create_from($user);
} else { } else {
@ -319,6 +328,8 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model'); $object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated $object->author = $user->id; // deprecated
$object->note = GETPOST('note'); $object->note = GETPOST('note');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->origin = GETPOST('origin'); $object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid'); $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 $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
print "</td></tr>"; print "</td></tr>";
// Incoterms
if ($conf->incoterm->enabled)
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
print '</td></tr>';
}
// Project // Project
if (! empty($conf->projet->enabled) && $socid > 0) if (! empty($conf->projet->enabled) && $socid > 0)
{ {
@ -1948,6 +1969,29 @@ if ($action == 'create')
print '</tr>'; print '</tr>';
} }
// Incoterms
if ($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->societe->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal.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

@ -122,6 +122,11 @@ class Propal extends CommonObject
var $specimen; var $specimen;
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
/** /**
* Constructor * Constructor
@ -745,6 +750,8 @@ class Propal extends CommonObject
$sql.= ", fk_availability"; $sql.= ", fk_availability";
$sql.= ", fk_input_reason"; $sql.= ", fk_input_reason";
$sql.= ", fk_projet"; $sql.= ", fk_projet";
$sql.= ", fk_incoterms";
$sql.= ", location_incoterms";
$sql.= ", entity"; $sql.= ", entity";
$sql.= ") "; $sql.= ") ";
$sql.= " VALUES ("; $sql.= " VALUES (";
@ -772,6 +779,8 @@ class Propal extends CommonObject
$sql.= ", ".$this->availability_id; $sql.= ", ".$this->availability_id;
$sql.= ", ".$this->demand_reason_id; $sql.= ", ".$this->demand_reason_id;
$sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ")"; $sql.= ")";
@ -1088,6 +1097,8 @@ class Propal extends CommonObject
$sql.= ", p.fk_mode_reglement"; $sql.= ", p.fk_mode_reglement";
$sql.= ', p.fk_account'; $sql.= ', p.fk_account';
$sql.= ", p.fk_shipping_method"; $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.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability"; $sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; $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_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_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_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.= " WHERE p.fk_statut = c.id";
$sql.= " AND p.entity = ".$conf->entity; $sql.= " AND p.entity = ".$conf->entity;
if ($ref) $sql.= " AND p.ref='".$ref."'"; 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_valid_id = $obj->fk_user_valid;
$this->user_close_id = $obj->fk_user_cloture; $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) if ($obj->fk_statut == 0)
{ {
$this->brouillon = 1; $this->brouillon = 1;