New allow to define order min amount

This commit is contained in:
Maxime Kohlhaas 2018-01-20 16:40:56 +01:00
parent e6bfc3354a
commit 6f248a6590
5 changed files with 79 additions and 0 deletions

View File

@ -176,6 +176,15 @@ if (empty($reshook))
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// update order min amount
if ($action == 'setorder_min_amount')
{
$object->fetch($id);
$object->order_min_amount=GETPOST('order_min_amount');
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
if ($action == 'update_extras') {
$object->fetch($id);
@ -401,9 +410,19 @@ if ($id > 0)
print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
//if (empty($object->outstanding_limit)) print $langs->trans("NoLimit");
print '</td>';
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
print '</td>';
print '</tr>';
}
// Multiprice level
if (! empty($conf->global->PRODUIT_MULTIPRICES))

View File

@ -101,6 +101,15 @@ if (empty($reshook))
$result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// update supplier order min amount
if ($action == 'setsupplier_order_min_amount')
{
$object->fetch($id);
$object->supplier_order_min_amount=GETPOST('supplier_order_min_amount');
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -230,6 +239,16 @@ if ($object->id > 0)
}
print "</td>";
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
$limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : ''));
print '</td>';
print '</tr>';
// Categories
if (! empty($conf->categorie->enabled))

View File

@ -0,0 +1,29 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 8.0.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table
-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex
-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL;
-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL;
-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL;
-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- Note: fields with type BLOB/TEXT can't have default value.
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit;
ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount;

View File

@ -96,6 +96,8 @@ create table llx_societe
fk_barcode_type integer NULL DEFAULT 0, -- barcode type
price_level integer NULL, -- level of price for multiprices
outstanding_limit double(24,8) DEFAULT NULL, -- allowed outstanding limit
order_min_amount double(24,8) DEFAULT NULL, -- min amount for orders
supplier_order_min_amount double(24,8) DEFAULT NULL, -- min amount for supplier orders
default_lang varchar(6), -- default language
logo varchar(255) DEFAULT NULL,
canvas varchar(32) DEFAULT NULL, -- type of canvas if used (null by default)

View File

@ -334,6 +334,12 @@ class Societe extends CommonObject
*/
var $price_level;
var $outstanding_limit;
/**
* Min order amounts
*/
var $order_min_amount;
var $supplier_order_min_amount;
/**
* Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives.
@ -785,6 +791,8 @@ class Societe extends CommonObject
$this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):'');
$this->prefix_comm = trim($this->prefix_comm);
$this->outstanding_limit = price2num($this->outstanding_limit);
$this->order_min_amount = price2num($this->order_min_amount);
$this->supplier_order_min_amount = price2num($this->supplier_order_min_amount);
$this->tva_assuj = trim($this->tva_assuj);
$this->tva_intra = dol_sanitizeFileName($this->tva_intra,'');
@ -955,6 +963,8 @@ class Societe extends CommonObject
$sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null");
$sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null");
$sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null');
$sql .= ",order_min_amount= ".($this->order_min_amount!=''?$this->order_min_amount:'null');
$sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount!=''?$this->supplier_order_min_amount:'null');
$sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'";
$sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null");