Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/admin/dict.php htdocs/product/stock/replenish.php htdocs/ticket/card.php htdocs/user/class/api_users.class.php
This commit is contained in:
commit
cc1f98329d
@ -869,13 +869,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
|
||||
$keycode = $value;
|
||||
}
|
||||
|
||||
if ($value == 'price' || preg_match('/^amount/i', $value)) {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
||||
} elseif ($value == 'taux' || $value == 'localtax1' || $value == 'localtax2') {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 8);
|
||||
} elseif ($value == 'entity') {
|
||||
$_POST[$keycode] = getEntity($tabname[$id]);
|
||||
}
|
||||
if ($value == 'price' || preg_match('/^amount/i', $value)) {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
||||
} elseif ($value == 'taux' || $value == 'localtax1') {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
|
||||
} elseif ($value == 'entity') {
|
||||
$_POST[$keycode] = getEntity($tabname[$id]);
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
$sql .= ",";
|
||||
@ -938,13 +938,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
|
||||
$keycode = $field;
|
||||
}
|
||||
|
||||
if ($field == 'price' || preg_match('/^amount/i', $field)) {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
||||
} elseif ($field == 'taux' || $field == 'localtax1' || $field == 'localtax2') {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 8);
|
||||
} elseif ($field == 'entity') {
|
||||
$_POST[$keycode] = getEntity($tabname[$id]);
|
||||
}
|
||||
if ($field == 'price' || preg_match('/^amount/i', $field)) {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
||||
} elseif ($field == 'taux' || $field == 'localtax1') {
|
||||
$_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
|
||||
} elseif ($field == 'entity') {
|
||||
$_POST[$keycode] = getEntity($tabname[$id]);
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
$sql .= ",";
|
||||
@ -1254,13 +1254,13 @@ if ($id) {
|
||||
$valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0;
|
||||
}
|
||||
if ($value == 'localtax1') {
|
||||
$valuetoshow = $langs->trans("Rate")." 2"; $class = "center";
|
||||
$valuetoshow = $langs->trans("RateOfTaxN", '2'); $class = "center";
|
||||
}
|
||||
if ($value == 'localtax2_type') {
|
||||
$valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0;
|
||||
}
|
||||
if ($value == 'localtax2') {
|
||||
$valuetoshow = $langs->trans("Rate")." 3"; $class = "center";
|
||||
$valuetoshow = $langs->trans("RateOfTaxN", '3'); $class = "center";
|
||||
}
|
||||
if ($value == 'organization') {
|
||||
$valuetoshow = $langs->trans("Organization");
|
||||
@ -1598,17 +1598,18 @@ if ($id) {
|
||||
}
|
||||
$cssprefix = 'center ';
|
||||
}
|
||||
|
||||
if ($value == 'localtax1_type') {
|
||||
$valuetoshow = $langs->trans("UseLocalTax")." 2"; $cssprefix = "center "; $sortable = 0;
|
||||
}
|
||||
if ($value == 'localtax1') {
|
||||
$valuetoshow = $langs->trans("Rate")." 2"; $cssprefix = "center "; $sortable = 0;
|
||||
$valuetoshow = $langs->trans("RateOfTaxN", '2'); $cssprefix = "center "; $sortable = 0;
|
||||
}
|
||||
if ($value == 'localtax2_type') {
|
||||
$valuetoshow = $langs->trans("UseLocalTax")." 3"; $cssprefix = "center "; $sortable = 0;
|
||||
}
|
||||
if ($value == 'localtax2') {
|
||||
$valuetoshow = $langs->trans("Rate")." 3"; $cssprefix = "center "; $sortable = 0;
|
||||
$valuetoshow = $langs->trans("RateOfTaxN", '3'); $cssprefix = "center "; $sortable = 0;
|
||||
}
|
||||
if ($value == 'organization') {
|
||||
$valuetoshow = $langs->trans("Organization");
|
||||
|
||||
@ -280,6 +280,11 @@ class CommandeFournisseur extends CommonOrder
|
||||
const STATUS_REFUSED = 9;
|
||||
|
||||
|
||||
/**
|
||||
* The constant used into source field to track the order was generated by the replenishement feature
|
||||
*/
|
||||
const SOURCE_ID_REPLENISHMENT = 42;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -430,6 +430,7 @@ LT1IN=CGST
|
||||
LT2IN=SGST
|
||||
LT1GC=Additionnal cents
|
||||
VATRate=Tax Rate
|
||||
RateOfTaxN=Rate of tax %s
|
||||
VATCode=Tax Rate code
|
||||
VATNPR=Tax Rate NPR
|
||||
DefaultTaxRate=Default tax rate
|
||||
|
||||
@ -224,17 +224,24 @@ if ($action == 'order' && GETPOST('valid')) {
|
||||
$suppliersid = array_keys($suppliers);
|
||||
foreach ($suppliers as $supplier) {
|
||||
$order = new CommandeFournisseur($db);
|
||||
|
||||
// Check if an order for the supplier exists
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||
$sql .= " WHERE fk_soc = ".((int) $suppliersid[$i]);
|
||||
$sql .= " AND source = 42 AND fk_statut = 0";
|
||||
$sql .= " AND source = ".((int) $order::SOURCE_ID_REPLENISHMENT)." AND fk_statut = ".$order::STATUS_DRAFT;
|
||||
$sql .= " AND entity IN (".getEntity('commande_fournisseur').")";
|
||||
$sql .= " ORDER BY date_creation DESC";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql && $db->num_rows($resql) > 0) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$order->fetch($obj->rowid);
|
||||
$order->fetch_thirdparty();
|
||||
|
||||
foreach ($supplier['lines'] as $line) {
|
||||
if (empty($line->remise_percent)) {
|
||||
$line->remise_percent = $order->thirdparty->remise_supplier_percent;
|
||||
}
|
||||
$result = $order->addline(
|
||||
$line->desc,
|
||||
$line->subprice,
|
||||
@ -268,13 +275,19 @@ if ($action == 'order' && GETPOST('valid')) {
|
||||
} else {
|
||||
$order->socid = $suppliersid[$i];
|
||||
$order->fetch_thirdparty();
|
||||
//trick to know which orders have been generated this way
|
||||
$order->source = 42;
|
||||
|
||||
// Trick to know which orders have been generated using the replenishment feature
|
||||
$order->source = $order::SOURCE_ID_REPLENISHMENT;
|
||||
|
||||
foreach ($supplier['lines'] as $line) {
|
||||
if (empty($line->remise_percent)) {
|
||||
$line->remise_percent = $order->thirdparty->remise_supplier_percent;
|
||||
}
|
||||
$order->lines[] = $line;
|
||||
}
|
||||
$order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id;
|
||||
$order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id;
|
||||
|
||||
$id = $order->create($user);
|
||||
if ($id < 0) {
|
||||
$fail++;
|
||||
|
||||
@ -1320,15 +1320,28 @@ if ($action == 'create' || $action == 'presend') {
|
||||
|
||||
// add a message
|
||||
if ($action == 'presend' || $action == 'presend_addmessage') {
|
||||
if ($object->fk_soc > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
||||
$newlang = GETPOST('lang_id', 'aZ09');
|
||||
}
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) {
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
}
|
||||
$arrayoffamiliestoexclude = array('objectamount');
|
||||
|
||||
$action = 'add_message'; // action to use to post the message
|
||||
$modelmail = 'ticket_send';
|
||||
|
||||
// Substitution array
|
||||
$morehtmlright = '';
|
||||
$help = "";
|
||||
$substitutionarray = array();
|
||||
$substitutionarray = getCommonSubstitutionArray($newlang, 0, $arrayoffamiliestoexclude, $object);
|
||||
if ($object->fk_soc > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
$substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
|
||||
}
|
||||
$substitutionarray['__USER_SIGNATURE__'] = $user->signature;
|
||||
@ -1361,16 +1374,6 @@ if ($action == 'create' || $action == 'presend') {
|
||||
|
||||
print '<hr>';
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
||||
$newlang = GETPOST('lang_id', 'aZ09');
|
||||
}
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
|
||||
$newlang = $object->default_lang;
|
||||
}
|
||||
|
||||
$formticket = new FormTicket($db);
|
||||
|
||||
$formticket->action = $action;
|
||||
|
||||
@ -21,6 +21,7 @@ use Luracast\Restler\RestException;
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* API class for users
|
||||
*
|
||||
@ -47,6 +48,7 @@ class Users extends DolibarrApi
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
$this->db = $db;
|
||||
$this->useraccount = new User($this->db);
|
||||
}
|
||||
@ -68,11 +70,11 @@ class Users extends DolibarrApi
|
||||
*/
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $category = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
global $conf;
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->user->user->lire && empty(DolibarrApiAccess::$user->admin)) {
|
||||
throw new RestException(401, "You are not allowed to read list of users");
|
||||
}
|
||||
if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) {
|
||||
throw new RestException(401, "You are not allowed to read list of users");
|
||||
}
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
@ -423,12 +425,12 @@ class Users extends DolibarrApi
|
||||
*/
|
||||
public function getGroups($id)
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
$user = new User($this->db);
|
||||
$result = $user->fetch($id);
|
||||
if (!$result) {
|
||||
@ -512,13 +514,13 @@ class Users extends DolibarrApi
|
||||
*/
|
||||
public function listGroups($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $group_ids = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
global $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) ||
|
||||
!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) {
|
||||
throw new RestException(401, "You are not allowed to read groups");
|
||||
throw new RestException(401, "You are not allowed to read groups");
|
||||
}
|
||||
|
||||
// case of external user, $societe param is ignored and replaced by user's socid
|
||||
|
||||
Loading…
Reference in New Issue
Block a user