Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop Conflicts: htdocs/install/mysql/tables/llx_user.sql
This commit is contained in:
commit
e99f115a8f
@ -183,7 +183,7 @@ if (empty($reshook))
|
|||||||
// Remove a product line
|
// Remove a product line
|
||||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer)
|
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
$result = $object->deleteline($lineid);
|
$result = $object->deleteline($user, $lineid);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Define output language
|
// Define output language
|
||||||
@ -1919,9 +1919,9 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
|
|
||||||
|
|
||||||
// Order card
|
// Order card
|
||||||
|
|
||||||
$linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
$linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||||
|
|
||||||
|
|
||||||
$morehtmlref='<div class="refidno">';
|
$morehtmlref='<div class="refidno">';
|
||||||
// Ref customer
|
// Ref customer
|
||||||
@ -1962,17 +1962,17 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$morehtmlref.='</div>';
|
$morehtmlref.='</div>';
|
||||||
|
|
||||||
|
|
||||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||||
|
|
||||||
|
|
||||||
print '<div class="fichecenter">';
|
print '<div class="fichecenter">';
|
||||||
print '<div class="fichehalfleft">';
|
print '<div class="fichehalfleft">';
|
||||||
print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
/*
|
/*
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Ref') . '</td>';
|
print '<tr><td class="titlefield">' . $langs->trans('Ref') . '</td>';
|
||||||
@ -2309,7 +2309,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Incoterms
|
// Incoterms
|
||||||
if (!empty($conf->incoterm->enabled))
|
if (!empty($conf->incoterm->enabled))
|
||||||
{
|
{
|
||||||
@ -2358,14 +2358,14 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="fichehalfright">';
|
print '<div class="fichehalfright">';
|
||||||
print '<div class="ficheaddleft">';
|
print '<div class="ficheaddleft">';
|
||||||
print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
print '<table class="border centpercent">';
|
print '<table class="border centpercent">';
|
||||||
|
|
||||||
// Total HT
|
// Total HT
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('AmountHT') . '</td>';
|
print '<tr><td class="titlefield">' . $langs->trans('AmountHT') . '</td>';
|
||||||
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';
|
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';
|
||||||
@ -2408,19 +2408,19 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
|
|
||||||
// Statut
|
// Statut
|
||||||
//print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>';
|
//print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
// Margin Infos
|
// Margin Infos
|
||||||
if (! empty($conf->margin->enabled)) {
|
if (! empty($conf->margin->enabled)) {
|
||||||
$formmargin->displayMarginInfos($object);
|
$formmargin->displayMarginInfos($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '<div class="clearboth"></div><br>';
|
print '<div class="clearboth"></div><br>';
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
|
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
|
||||||
@ -2634,7 +2634,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
|
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
|
||||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||||
|
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
|
|||||||
@ -23,19 +23,19 @@
|
|||||||
* API class for commande object
|
* API class for commande object
|
||||||
*
|
*
|
||||||
* @smart-auto-routing false
|
* @smart-auto-routing false
|
||||||
* @access protected
|
* @access protected
|
||||||
* @class DolibarrApiAccess {@requires user,external}
|
* @class DolibarrApiAccess {@requires user,external}
|
||||||
*
|
*
|
||||||
* @category Api
|
* @category Api
|
||||||
* @package Api
|
* @package Api
|
||||||
*
|
*
|
||||||
* @deprecated Use Orders instead (defined in api_orders.class.php)
|
* @deprecated Use Orders instead (defined in api_orders.class.php)
|
||||||
*/
|
*/
|
||||||
class CommandeApi extends DolibarrApi
|
class CommandeApi extends DolibarrApi
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
static $FIELDS = array(
|
||||||
'socid'
|
'socid'
|
||||||
@ -50,7 +50,7 @@ class CommandeApi extends DolibarrApi
|
|||||||
* Constructor <b>Warning: Deprecated</b>
|
* Constructor <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* @url GET order/
|
* @url GET order/
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@ -63,40 +63,40 @@ class CommandeApi extends DolibarrApi
|
|||||||
* Get properties of a commande object <b>Warning: Deprecated</b>
|
* Get properties of a commande object <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* Return an array with commande informations
|
* Return an array with commande informations
|
||||||
*
|
*
|
||||||
* @param int $id ID of order
|
* @param int $id ID of order
|
||||||
* @param string $ref Ref of object
|
* @param string $ref Ref of object
|
||||||
* @param string $ref_ext External reference of object
|
* @param string $ref_ext External reference of object
|
||||||
* @param string $ref_int Internal reference of other object
|
* @param string $ref_int Internal reference of other object
|
||||||
* @return array|mixed data without useless information
|
* @return array|mixed data without useless information
|
||||||
*
|
*
|
||||||
* @url GET order/{id}
|
* @url GET order/{id}
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
function get($id='',$ref='', $ref_ext='', $ref_int='')
|
function get($id='',$ref='', $ref_ext='', $ref_int='')
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->commande->fetchObjectLinked();
|
$this->commande->fetchObjectLinked();
|
||||||
return $this->_cleanObjectDatas($this->commande);
|
return $this->_cleanObjectDatas($this->commande);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List orders <b>Warning: Deprecated</b>
|
* List orders <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* Get a list of orders
|
* Get a list of orders
|
||||||
*
|
*
|
||||||
* @param string $sortfield Sort field
|
* @param string $sortfield Sort field
|
||||||
* @param string $sortorder Sort order
|
* @param string $sortorder Sort order
|
||||||
* @param int $limit Limit for list
|
* @param int $limit Limit for list
|
||||||
@ -109,20 +109,20 @@ class CommandeApi extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $societe = 0) {
|
function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $societe = 0) {
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
// case of external user, $societe param is ignored and replaced by user's socid
|
// case of external user, $societe param is ignored and replaced by user's socid
|
||||||
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe;
|
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe;
|
||||||
|
|
||||||
// If the internal user must only see his customers, force searching by him
|
// If the internal user must only see his customers, force searching by him
|
||||||
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
|
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
|
||||||
|
|
||||||
$sql = "SELECT s.rowid";
|
$sql = "SELECT s.rowid";
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande as s";
|
||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
|
||||||
// Example of use $mode
|
// Example of use $mode
|
||||||
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
||||||
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
||||||
@ -131,13 +131,13 @@ class CommandeApi extends DolibarrApi
|
|||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
||||||
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
||||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|
||||||
// Insert sale filter
|
// Insert sale filter
|
||||||
if ($search_sale > 0)
|
if ($search_sale > 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nbtotalofrecords = 0;
|
$nbtotalofrecords = 0;
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
{
|
{
|
||||||
@ -157,7 +157,7 @@ class CommandeApi extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$i=0;
|
$i=0;
|
||||||
@ -183,9 +183,9 @@ class CommandeApi extends DolibarrApi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* List orders for specific thirdparty <b>Warning: Deprecated</b>
|
* List orders for specific thirdparty <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* Get a list of orders
|
* Get a list of orders
|
||||||
*
|
*
|
||||||
* @param int $socid Id of customer
|
* @param int $socid Id of customer
|
||||||
*
|
*
|
||||||
* @url GET /customer/{socid}/order/list
|
* @url GET /customer/{socid}/order/list
|
||||||
@ -196,14 +196,14 @@ class CommandeApi extends DolibarrApi
|
|||||||
return getList(0,"s.rowid","ASC",0,0,$socid);
|
return getList(0,"s.rowid","ASC",0,0,$socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create order object <b>Warning: Deprecated</b>
|
* Create order object <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* @param array $request_data Request datas
|
* @param array $request_data Request datas
|
||||||
*
|
*
|
||||||
* @url POST order/
|
* @url POST order/
|
||||||
*
|
*
|
||||||
* @return int ID of commande
|
* @return int ID of commande
|
||||||
*/
|
*/
|
||||||
function post($request_data = NULL)
|
function post($request_data = NULL)
|
||||||
@ -227,7 +227,7 @@ class CommandeApi extends DolibarrApi
|
|||||||
if(! $this->commande->create(DolibarrApiAccess::$user) ) {
|
if(! $this->commande->create(DolibarrApiAccess::$user) ) {
|
||||||
throw new RestException(500, "Error while creating order");
|
throw new RestException(500, "Error while creating order");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->commande->id;
|
return $this->commande->id;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -235,21 +235,21 @@ class CommandeApi extends DolibarrApi
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param int $id Id of order
|
* @param int $id Id of order
|
||||||
*
|
*
|
||||||
* @url GET order/{id}/line/list
|
* @url GET order/{id}/line/list
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getLines($id) {
|
function getLines($id) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -265,22 +265,22 @@ class CommandeApi extends DolibarrApi
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param array $request_data Orderline data
|
* @param array $request_data Orderline data
|
||||||
*
|
*
|
||||||
* @url POST order/{id}/line
|
* @url POST order/{id}/line
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function postLine($id, $request_data = NULL) {
|
function postLine($id, $request_data = NULL) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -325,22 +325,22 @@ class CommandeApi extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param int $lineid Id of line to update
|
* @param int $lineid Id of line to update
|
||||||
* @param array $request_data Orderline data
|
* @param array $request_data Orderline data
|
||||||
*
|
*
|
||||||
* @url PUT order/{id}/line/{lineid}
|
* @url PUT order/{id}/line/{lineid}
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function putLine($id, $lineid, $request_data = NULL) {
|
function putLine($id, $lineid, $request_data = NULL) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -382,26 +382,26 @@ class CommandeApi extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param int $lineid Id of line to delete
|
* @param int $lineid Id of line to delete
|
||||||
*
|
*
|
||||||
* @url DELETE order/{id}/line/{lineid}
|
* @url DELETE order/{id}/line/{lineid}
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function delLine($id, $lineid) {
|
function delLine($id, $lineid) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
$request_data = (object) $request_data;
|
$request_data = (object) $request_data;
|
||||||
$updateRes = $this->commande->deleteline($lineid);
|
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
|
||||||
if ($updateRes == 1) {
|
if ($updateRes == 1) {
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
}
|
}
|
||||||
@ -412,42 +412,42 @@ class CommandeApi extends DolibarrApi
|
|||||||
* Update order general fields (won't touch lines of order) <b>Warning: Deprecated</b>
|
* Update order general fields (won't touch lines of order) <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param array $request_data Datas
|
* @param array $request_data Datas
|
||||||
*
|
*
|
||||||
* @url PUT order/{id}
|
* @url PUT order/{id}
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function put($id, $request_data = NULL) {
|
function put($id, $request_data = NULL) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
foreach($request_data as $field => $value) {
|
foreach($request_data as $field => $value) {
|
||||||
$this->commande->$field = $value;
|
$this->commande->$field = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->commande->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
if($this->commande->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete order <b>Warning: Deprecated</b>
|
* Delete order <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* @param int $id Order ID
|
* @param int $id Order ID
|
||||||
*
|
*
|
||||||
* @url DELETE order/{id}
|
* @url DELETE order/{id}
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function delete($id)
|
function delete($id)
|
||||||
@ -459,35 +459,35 @@ class CommandeApi extends DolibarrApi
|
|||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
|
if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
|
||||||
throw new RestException(500, 'Error when delete order : '.$this->commande->error);
|
throw new RestException(500, 'Error when delete order : '.$this->commande->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Order deleted'
|
'message' => 'Order deleted'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an order <b>Warning: Deprecated</b>
|
* Validate an order <b>Warning: Deprecated</b>
|
||||||
*
|
*
|
||||||
* @param int $id Order ID
|
* @param int $id Order ID
|
||||||
* @param int $idwarehouse Warehouse ID
|
* @param int $idwarehouse Warehouse ID
|
||||||
*
|
*
|
||||||
* @url GET order/{id}/validate
|
* @url GET order/{id}/validate
|
||||||
* @url POST order/{id}/validate
|
* @url POST order/{id}/validate
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function validOrder($id, $idwarehouse=0)
|
function validOrder($id, $idwarehouse=0)
|
||||||
{
|
{
|
||||||
@ -498,15 +498,15 @@ class CommandeApi extends DolibarrApi
|
|||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) {
|
if( ! $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) {
|
||||||
throw new RestException(500, 'Error when validate order');
|
throw new RestException(500, 'Error when validate order');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
@ -514,12 +514,12 @@ class CommandeApi extends DolibarrApi
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate fields before create or update object
|
* Validate fields before create or update object
|
||||||
*
|
*
|
||||||
* @param array $data Array with data to verify
|
* @param array $data Array with data to verify
|
||||||
* @return array
|
* @return array
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
function _validate($data)
|
function _validate($data)
|
||||||
@ -529,7 +529,7 @@ class CommandeApi extends DolibarrApi
|
|||||||
if (!isset($data[$field]))
|
if (!isset($data[$field]))
|
||||||
throw new RestException(400, "$field field missing");
|
throw new RestException(400, "$field field missing");
|
||||||
$commande[$field] = $data[$field];
|
$commande[$field] = $data[$field];
|
||||||
|
|
||||||
}
|
}
|
||||||
return $commande;
|
return $commande;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,14 +23,14 @@
|
|||||||
/**
|
/**
|
||||||
* API class for orders
|
* API class for orders
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @class DolibarrApiAccess {@requires user,external}
|
* @class DolibarrApiAccess {@requires user,external}
|
||||||
*/
|
*/
|
||||||
class Orders extends DolibarrApi
|
class Orders extends DolibarrApi
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
static $FIELDS = array(
|
||||||
'socid'
|
'socid'
|
||||||
@ -55,36 +55,36 @@ class Orders extends DolibarrApi
|
|||||||
* Get properties of a commande object
|
* Get properties of a commande object
|
||||||
*
|
*
|
||||||
* Return an array with commande informations
|
* Return an array with commande informations
|
||||||
*
|
*
|
||||||
* @param int $id ID of order
|
* @param int $id ID of order
|
||||||
* @return array|mixed data without useless information
|
* @return array|mixed data without useless information
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
function get($id)
|
function get($id)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->commande->fetchObjectLinked();
|
$this->commande->fetchObjectLinked();
|
||||||
return $this->_cleanObjectDatas($this->commande);
|
return $this->_cleanObjectDatas($this->commande);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List orders
|
* List orders
|
||||||
*
|
*
|
||||||
* Get a list of orders
|
* Get a list of orders
|
||||||
*
|
*
|
||||||
* @param string $sortfield Sort field
|
* @param string $sortfield Sort field
|
||||||
* @param string $sortorder Sort order
|
* @param string $sortorder Sort order
|
||||||
* @param int $limit Limit for list
|
* @param int $limit Limit for list
|
||||||
@ -95,31 +95,31 @@ class Orders extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '') {
|
function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '') {
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
// case of external user, $thirdpartyid param is ignored and replaced by user's socid
|
// case of external user, $thirdpartyid param is ignored and replaced by user's socid
|
||||||
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
|
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
|
||||||
|
|
||||||
// If the internal user must only see his customers, force searching by him
|
// If the internal user must only see his customers, force searching by him
|
||||||
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
|
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
|
||||||
|
|
||||||
$sql = "SELECT s.rowid";
|
$sql = "SELECT s.rowid";
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande as s";
|
||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('commande', 1).')';
|
$sql.= ' WHERE s.entity IN ('.getEntity('commande', 1).')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
||||||
if ($socids) $sql.= " AND s.fk_soc IN (".$socids.")";
|
if ($socids) $sql.= " AND s.fk_soc IN (".$socids.")";
|
||||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|
||||||
// Insert sale filter
|
// Insert sale filter
|
||||||
if ($search_sale > 0)
|
if ($search_sale > 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nbtotalofrecords = 0;
|
$nbtotalofrecords = 0;
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
{
|
{
|
||||||
@ -139,7 +139,7 @@ class Orders extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
@ -190,7 +190,7 @@ class Orders extends DolibarrApi
|
|||||||
$errormsg = $this->commande->error;
|
$errormsg = $this->commande->error;
|
||||||
throw new RestException(500, $errormsg ? $errormsg : "Error while creating order");
|
throw new RestException(500, $errormsg ? $errormsg : "Error while creating order");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->commande->id;
|
return $this->commande->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,21 +198,21 @@ class Orders extends DolibarrApi
|
|||||||
* Get lines of an order
|
* Get lines of an order
|
||||||
*
|
*
|
||||||
* @param int $id Id of order
|
* @param int $id Id of order
|
||||||
*
|
*
|
||||||
* @url GET {id}/lines
|
* @url GET {id}/lines
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getLines($id) {
|
function getLines($id) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
if(! DolibarrApiAccess::$user->rights->commande->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -228,22 +228,22 @@ class Orders extends DolibarrApi
|
|||||||
* Add a line to given order
|
* Add a line to given order
|
||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param array $request_data Orderline data
|
* @param array $request_data Orderline data
|
||||||
*
|
*
|
||||||
* @url POST {id}/lines
|
* @url POST {id}/lines
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function postLine($id, $request_data = NULL) {
|
function postLine($id, $request_data = NULL) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -288,22 +288,22 @@ class Orders extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param int $lineid Id of line to update
|
* @param int $lineid Id of line to update
|
||||||
* @param array $request_data Orderline data
|
* @param array $request_data Orderline data
|
||||||
*
|
*
|
||||||
* @url PUT {id}/lines/{lineid}
|
* @url PUT {id}/lines/{lineid}
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function putLine($id, $lineid, $request_data = NULL) {
|
function putLine($id, $lineid, $request_data = NULL) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -346,26 +346,26 @@ class Orders extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param int $lineid Id of line to delete
|
* @param int $lineid Id of line to delete
|
||||||
*
|
*
|
||||||
* @url DELETE {id}/lines/{lineid}
|
* @url DELETE {id}/lines/{lineid}
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function delLine($id, $lineid) {
|
function delLine($id, $lineid) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
$request_data = (object) $request_data;
|
$request_data = (object) $request_data;
|
||||||
$updateRes = $this->commande->deleteline($lineid);
|
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
|
||||||
if ($updateRes == 1) {
|
if ($updateRes == 1) {
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
}
|
}
|
||||||
@ -376,38 +376,38 @@ class Orders extends DolibarrApi
|
|||||||
* Update order general fields (won't touch lines of order)
|
* Update order general fields (won't touch lines of order)
|
||||||
*
|
*
|
||||||
* @param int $id Id of commande to update
|
* @param int $id Id of commande to update
|
||||||
* @param array $request_data Datas
|
* @param array $request_data Datas
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function put($id, $request_data = NULL) {
|
function put($id, $request_data = NULL) {
|
||||||
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
$result = $this->commande->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Commande not found');
|
throw new RestException(404, 'Commande not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
foreach($request_data as $field => $value) {
|
foreach($request_data as $field => $value) {
|
||||||
$this->commande->$field = $value;
|
$this->commande->$field = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->commande->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
|
if($this->commande->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete order
|
* Delete order
|
||||||
*
|
*
|
||||||
* @param int $id Order ID
|
* @param int $id Order ID
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function delete($id)
|
function delete($id)
|
||||||
@ -419,33 +419,33 @@ class Orders extends DolibarrApi
|
|||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
|
if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
|
||||||
throw new RestException(500, 'Error when delete order : '.$this->commande->error);
|
throw new RestException(500, 'Error when delete order : '.$this->commande->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Order deleted'
|
'message' => 'Order deleted'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an order
|
* Validate an order
|
||||||
*
|
*
|
||||||
* @param int $id Order ID
|
* @param int $id Order ID
|
||||||
* @param int $idwarehouse Warehouse ID
|
* @param int $idwarehouse Warehouse ID
|
||||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||||
*
|
*
|
||||||
* @url POST {id}/validate
|
* @url POST {id}/validate
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* FIXME An error 403 is returned if the request has an empty body.
|
* FIXME An error 403 is returned if the request has an empty body.
|
||||||
* Error message: "Forbidden: Content type `text/plain` is not supported."
|
* Error message: "Forbidden: Content type `text/plain` is not supported."
|
||||||
@ -464,11 +464,11 @@ class Orders extends DolibarrApi
|
|||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
|
$result = $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
|
||||||
if ($result == 0) {
|
if ($result == 0) {
|
||||||
throw new RestException(500, 'Error nothing done. May be object is already validated');
|
throw new RestException(500, 'Error nothing done. May be object is already validated');
|
||||||
@ -476,7 +476,7 @@ class Orders extends DolibarrApi
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
throw new RestException(500, 'Error when validating Order: '.$this->commande->error);
|
throw new RestException(500, 'Error when validating Order: '.$this->commande->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
@ -484,12 +484,12 @@ class Orders extends DolibarrApi
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate fields before create or update object
|
* Validate fields before create or update object
|
||||||
*
|
*
|
||||||
* @param array $data Array with data to verify
|
* @param array $data Array with data to verify
|
||||||
* @return array
|
* @return array
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
function _validate($data)
|
function _validate($data)
|
||||||
@ -499,7 +499,7 @@ class Orders extends DolibarrApi
|
|||||||
if (!isset($data[$field]))
|
if (!isset($data[$field]))
|
||||||
throw new RestException(400, "$field field missing");
|
throw new RestException(400, "$field field missing");
|
||||||
$commande[$field] = $data[$field];
|
$commande[$field] = $data[$field];
|
||||||
|
|
||||||
}
|
}
|
||||||
return $commande;
|
return $commande;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class Commande extends CommonOrder
|
|||||||
public $fk_element = 'fk_commande';
|
public $fk_element = 'fk_commande';
|
||||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
public $picto = 'order';
|
public $picto = 'order';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -810,11 +810,11 @@ class Commande extends CommonOrder
|
|||||||
for ($i=0;$i<$num;$i++)
|
for ($i=0;$i<$num;$i++)
|
||||||
{
|
{
|
||||||
$line = $this->lines[$i];
|
$line = $this->lines[$i];
|
||||||
|
|
||||||
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
|
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
|
||||||
//if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object.
|
//if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object.
|
||||||
if (! is_object($line)) $line = (object) $line;
|
if (! is_object($line)) $line = (object) $line;
|
||||||
|
|
||||||
// Reset fk_parent_line for no child products and special product
|
// Reset fk_parent_line for no child products and special product
|
||||||
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
|
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
|
||||||
$fk_parent_line = 0;
|
$fk_parent_line = 0;
|
||||||
@ -906,10 +906,10 @@ class Commande extends CommonOrder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
||||||
$sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
|
$sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
|
||||||
|
|
||||||
$resqlcontact = $this->db->query($sqlcontact);
|
$resqlcontact = $this->db->query($sqlcontact);
|
||||||
if ($resqlcontact)
|
if ($resqlcontact)
|
||||||
{
|
{
|
||||||
@ -1220,7 +1220,7 @@ class Commande extends CommonOrder
|
|||||||
*/
|
*/
|
||||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
|
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
|
||||||
{
|
{
|
||||||
global $mysoc, $conf, $langs;
|
global $mysoc, $conf, $langs, $user;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit", LOG_DEBUG);
|
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit", LOG_DEBUG);
|
||||||
|
|
||||||
@ -1373,7 +1373,7 @@ class Commande extends CommonOrder
|
|||||||
$this->line->array_options=$array_options;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->insert();
|
$result=$this->line->insert($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Reorder if child line
|
// Reorder if child line
|
||||||
@ -1972,10 +1972,11 @@ class Commande extends CommonOrder
|
|||||||
/**
|
/**
|
||||||
* Delete an order line
|
* Delete an order line
|
||||||
*
|
*
|
||||||
|
* @param User $user User object
|
||||||
* @param int $lineid Id of line to delete
|
* @param int $lineid Id of line to delete
|
||||||
* @return int >0 if OK, 0 if nothing to do, <0 if KO
|
* @return int >0 if OK, 0 if nothing to do, <0 if KO
|
||||||
*/
|
*/
|
||||||
function deleteline($lineid)
|
function deleteline($user=null, $lineid=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->statut == self::STATUS_DRAFT)
|
if ($this->statut == self::STATUS_DRAFT)
|
||||||
@ -2002,7 +2003,7 @@ class Commande extends CommonOrder
|
|||||||
// For triggers
|
// For triggers
|
||||||
$line->fetch($lineid);
|
$line->fetch($lineid);
|
||||||
|
|
||||||
if ($line->delete() > 0)
|
if ($line->delete($user) > 0)
|
||||||
{
|
{
|
||||||
$result=$this->update_price(1);
|
$result=$this->update_price(1);
|
||||||
|
|
||||||
@ -2387,7 +2388,7 @@ class Commande extends CommonOrder
|
|||||||
function availability($availability_id, $notrigger=0)
|
function availability($availability_id, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
dol_syslog('Commande::availability('.$availability_id.')');
|
dol_syslog('Commande::availability('.$availability_id.')');
|
||||||
if ($this->statut >= self::STATUS_DRAFT)
|
if ($this->statut >= self::STATUS_DRAFT)
|
||||||
{
|
{
|
||||||
@ -2457,7 +2458,7 @@ class Commande extends CommonOrder
|
|||||||
function demand_reason($demand_reason_id, $notrigger=0)
|
function demand_reason($demand_reason_id, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
|
dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
|
||||||
if ($this->statut >= self::STATUS_DRAFT)
|
if ($this->statut >= self::STATUS_DRAFT)
|
||||||
{
|
{
|
||||||
@ -2740,7 +2741,7 @@ class Commande extends CommonOrder
|
|||||||
*/
|
*/
|
||||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
|
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
|
||||||
{
|
{
|
||||||
global $conf, $mysoc, $langs;
|
global $conf, $mysoc, $langs, $user;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
|
dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||||
@ -2885,7 +2886,7 @@ class Commande extends CommonOrder
|
|||||||
$this->line->array_options=$array_options;
|
$this->line->array_options=$array_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->line->update();
|
$result=$this->line->update($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Reorder if child line
|
// Reorder if child line
|
||||||
@ -3805,9 +3806,11 @@ class OrderLine extends CommonOrderLine
|
|||||||
/**
|
/**
|
||||||
* Delete line in database
|
* Delete line in database
|
||||||
*
|
*
|
||||||
|
* @param User $user User that modify
|
||||||
|
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||||
* @return int <0 si ko, >0 si ok
|
* @return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete($user=null, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
@ -3833,10 +3836,13 @@ class OrderLine extends CommonOrderLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call trigger
|
if (! $error && ! $notrigger)
|
||||||
$result=$this->call_trigger('LINEORDER_DELETE',$user);
|
{
|
||||||
if ($result < 0) $error++;
|
// Call trigger
|
||||||
// End call triggers
|
$result=$this->call_trigger('LINEORDER_DELETE',$user);
|
||||||
|
if ($result < 0) $error++;
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -3861,12 +3867,13 @@ class OrderLine extends CommonOrderLine
|
|||||||
/**
|
/**
|
||||||
* Insert line into database
|
* Insert line into database
|
||||||
*
|
*
|
||||||
|
* @param User $user User that modify
|
||||||
* @param int $notrigger 1 = disable triggers
|
* @param int $notrigger 1 = disable triggers
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function insert($notrigger=0)
|
function insert($user=null, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $langs, $conf, $user;
|
global $langs, $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -4004,12 +4011,13 @@ class OrderLine extends CommonOrderLine
|
|||||||
/**
|
/**
|
||||||
* Update the line object into db
|
* Update the line object into db
|
||||||
*
|
*
|
||||||
|
* @param User $user User that modify
|
||||||
* @param int $notrigger 1 = disable triggers
|
* @param int $notrigger 1 = disable triggers
|
||||||
* @return int <0 si ko, >0 si ok
|
* @return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function update($notrigger=0)
|
function update($user=null, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class modSalaries extends DolibarrModules
|
|||||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||||
// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
$this->description = "Employees salaries management";
|
$this->description = "Employees contracts and salaries management";
|
||||||
|
|
||||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||||
$this->version = 'dolibarr';
|
$this->version = 'dolibarr';
|
||||||
@ -97,8 +97,8 @@ class modSalaries extends DolibarrModules
|
|||||||
$r=0;
|
$r=0;
|
||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 510;
|
$this->rights[$r][0] = 511;
|
||||||
$this->rights[$r][1] = 'Read salaries';
|
$this->rights[$r][1] = 'Read employee contracts/salaries';
|
||||||
$this->rights[$r][2] = 'r';
|
$this->rights[$r][2] = 'r';
|
||||||
$this->rights[$r][3] = 0;
|
$this->rights[$r][3] = 0;
|
||||||
$this->rights[$r][4] = 'read';
|
$this->rights[$r][4] = 'read';
|
||||||
@ -106,15 +106,23 @@ class modSalaries extends DolibarrModules
|
|||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 512;
|
$this->rights[$r][0] = 512;
|
||||||
$this->rights[$r][1] = 'Create/modify salaries';
|
$this->rights[$r][1] = 'Create/modify employee contracts/salaries';
|
||||||
$this->rights[$r][2] = 'w';
|
$this->rights[$r][2] = 'w';
|
||||||
$this->rights[$r][3] = 0;
|
$this->rights[$r][3] = 0;
|
||||||
$this->rights[$r][4] = 'write';
|
$this->rights[$r][4] = 'write';
|
||||||
$this->rights[$r][5] = '';
|
$this->rights[$r][5] = '';
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->rights[$r][0] = 513;
|
||||||
|
$this->rights[$r][1] = 'Create/modify payment of salaries';
|
||||||
|
$this->rights[$r][2] = 'w';
|
||||||
|
$this->rights[$r][3] = 0;
|
||||||
|
$this->rights[$r][4] = 'write';
|
||||||
|
$this->rights[$r][5] = '';
|
||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 514;
|
$this->rights[$r][0] = 514;
|
||||||
$this->rights[$r][1] = 'Delete salaries';
|
$this->rights[$r][1] = 'Delete contracts/salaries';
|
||||||
$this->rights[$r][2] = 'd';
|
$this->rights[$r][2] = 'd';
|
||||||
$this->rights[$r][3] = 0;
|
$this->rights[$r][3] = 0;
|
||||||
$this->rights[$r][4] = 'delete';
|
$this->rights[$r][4] = 'delete';
|
||||||
@ -122,7 +130,7 @@ class modSalaries extends DolibarrModules
|
|||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 517;
|
$this->rights[$r][0] = 517;
|
||||||
$this->rights[$r][1] = 'Export salaries';
|
$this->rights[$r][1] = 'Export employee contracts and salaries payments';
|
||||||
$this->rights[$r][2] = 'r';
|
$this->rights[$r][2] = 'r';
|
||||||
$this->rights[$r][3] = 0;
|
$this->rights[$r][3] = 0;
|
||||||
$this->rights[$r][4] = 'export';
|
$this->rights[$r][4] = 'export';
|
||||||
|
|||||||
@ -33,6 +33,7 @@ DELETE FROM llx_menu where module='expensereport';
|
|||||||
|
|
||||||
ALTER TABLE llx_user DROP COLUMN phenix_login;
|
ALTER TABLE llx_user DROP COLUMN phenix_login;
|
||||||
ALTER TABLE llx_user DROP COLUMN phenix_pass;
|
ALTER TABLE llx_user DROP COLUMN phenix_pass;
|
||||||
|
ALTER TABLE llx_user ADD COLUMN dateemployment datetime;
|
||||||
|
|
||||||
ALTER TABLE llx_societe ADD COLUMN fk_account integer;
|
ALTER TABLE llx_societe ADD COLUMN fk_account integer;
|
||||||
|
|
||||||
|
|||||||
@ -78,7 +78,9 @@ create table llx_user
|
|||||||
nb_holiday integer DEFAULT 0,
|
nb_holiday integer DEFAULT 0,
|
||||||
thm double(24,8),
|
thm double(24,8),
|
||||||
tjm double(24,8),
|
tjm double(24,8),
|
||||||
|
|
||||||
salary double(24,8), -- denormalized value coming from llx_user_employment
|
salary double(24,8), -- denormalized value coming from llx_user_employment
|
||||||
salaryextra double(24,8), -- denormalized value coming from llx_user_employment
|
salaryextra double(24,8), -- denormalized value coming from llx_user_employment
|
||||||
|
dateemployment date, -- denormalized value coming from llx_user_employment
|
||||||
weeklyhours double(16,8) -- denormalized value coming from llx_user_employment
|
weeklyhours double(16,8) -- denormalized value coming from llx_user_employment
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -474,8 +474,8 @@ Module410Name=Webcalendar
|
|||||||
Module410Desc=Webcalendar integration
|
Module410Desc=Webcalendar integration
|
||||||
Module500Name=Special expenses
|
Module500Name=Special expenses
|
||||||
Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends)
|
Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends)
|
||||||
Module510Name=Salaries
|
Module510Name=Employee contracts and salaries
|
||||||
Module510Desc=Management of employees salaries and payments
|
Module510Desc=Management of employees contracts, salaries and payments
|
||||||
Module520Name=Loan
|
Module520Name=Loan
|
||||||
Module520Desc=Management of loans
|
Module520Desc=Management of loans
|
||||||
Module600Name=Notifications
|
Module600Name=Notifications
|
||||||
|
|||||||
@ -101,4 +101,5 @@ ColorUser=Color of the user
|
|||||||
DisabledInMonoUserMode=Disabled in maintenance mode
|
DisabledInMonoUserMode=Disabled in maintenance mode
|
||||||
UserAccountancyCode=User accountancy code
|
UserAccountancyCode=User accountancy code
|
||||||
UserLogoff=User logout
|
UserLogoff=User logout
|
||||||
UserLogged=User logged
|
UserLogged=User logged
|
||||||
|
DateEmployment=Date of Employment
|
||||||
@ -100,3 +100,4 @@ WeeklyHours=Heures de travail hebdomadaires
|
|||||||
ColorUser=Couleur de l'utilisateur
|
ColorUser=Couleur de l'utilisateur
|
||||||
DisabledInMonoUserMode=Désactivé en mode maintenance
|
DisabledInMonoUserMode=Désactivé en mode maintenance
|
||||||
UserAccountancyCode=Code comptable utilisateur
|
UserAccountancyCode=Code comptable utilisateur
|
||||||
|
DateEmployment=Date d'embauche
|
||||||
|
|||||||
@ -216,6 +216,8 @@ if (empty($reshook)) {
|
|||||||
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
|
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
|
||||||
|
|
||||||
$object->color = GETPOST("color") != '' ? GETPOST("color") : '';
|
$object->color = GETPOST("color") != '' ? GETPOST("color") : '';
|
||||||
|
$dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear'));
|
||||||
|
$object->dateemployment = $dateemployment;
|
||||||
|
|
||||||
// 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);
|
||||||
@ -357,6 +359,8 @@ if (empty($reshook)) {
|
|||||||
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
|
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
|
||||||
|
|
||||||
$object->color = GETPOST("color") != '' ? GETPOST("color") : '';
|
$object->color = GETPOST("color") != '' ? GETPOST("color") : '';
|
||||||
|
$dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear'));
|
||||||
|
$object->dateemployment = $dateemployment;
|
||||||
|
|
||||||
if (! empty($conf->multicompany->enabled))
|
if (! empty($conf->multicompany->enabled))
|
||||||
{
|
{
|
||||||
@ -1057,6 +1061,13 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
|||||||
print '<input size="8" type="text" name="weeklyhours" value="'.GETPOST('weeklyhours').'">';
|
print '<input size="8" type="text" name="weeklyhours" value="'.GETPOST('weeklyhours').'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Date employment
|
||||||
|
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
// Accountancy code
|
// Accountancy code
|
||||||
if ($conf->accounting->enabled)
|
if ($conf->accounting->enabled)
|
||||||
@ -1412,6 +1423,13 @@ else
|
|||||||
print '<td>'.$object->accountancy_code.'</td>';
|
print '<td>'.$object->accountancy_code.'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Date employment
|
||||||
|
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print dol_print_date($object->dateemployment);
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -2186,6 +2204,13 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Date employment
|
||||||
|
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
// Accountancy code
|
// Accountancy code
|
||||||
if ($conf->accounting->enabled)
|
if ($conf->accounting->enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -124,6 +124,8 @@ class User extends CommonObject
|
|||||||
var $weeklyhours; // Weekly hours - Denormalized value from llx_user_employment
|
var $weeklyhours; // Weekly hours - Denormalized value from llx_user_employment
|
||||||
|
|
||||||
var $color; // Define background color for user in agenda
|
var $color; // Define background color for user in agenda
|
||||||
|
|
||||||
|
var $dateemployment; // Define date of employment by company
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor de la classe
|
* Constructor de la classe
|
||||||
@ -189,6 +191,7 @@ class User extends CommonObject
|
|||||||
$sql.= " u.salaryextra,";
|
$sql.= " u.salaryextra,";
|
||||||
$sql.= " u.weeklyhours,";
|
$sql.= " u.weeklyhours,";
|
||||||
$sql.= " u.color,";
|
$sql.= " u.color,";
|
||||||
|
$sql.= " u.dateemployment,";
|
||||||
$sql.= " u.ref_int, u.ref_ext,";
|
$sql.= " u.ref_int, u.ref_ext,";
|
||||||
$sql.= " c.code as country_code, c.label as country,";
|
$sql.= " c.code as country_code, c.label as country,";
|
||||||
$sql.= " d.code_departement as state_code, d.nom as state";
|
$sql.= " d.code_departement as state_code, d.nom as state";
|
||||||
@ -288,6 +291,7 @@ class User extends CommonObject
|
|||||||
$this->salaryextra = $obj->salaryextra;
|
$this->salaryextra = $obj->salaryextra;
|
||||||
$this->weeklyhours = $obj->weeklyhours;
|
$this->weeklyhours = $obj->weeklyhours;
|
||||||
$this->color = $obj->color;
|
$this->color = $obj->color;
|
||||||
|
$this->dateemployment = $this->db->jdate($obj->dateemployment);
|
||||||
|
|
||||||
$this->datec = $this->db->jdate($obj->datec);
|
$this->datec = $this->db->jdate($obj->datec);
|
||||||
$this->datem = $this->db->jdate($obj->datem);
|
$this->datem = $this->db->jdate($obj->datem);
|
||||||
@ -1262,6 +1266,7 @@ class User extends CommonObject
|
|||||||
$this->town = empty($this->town)?'':$this->town;
|
$this->town = empty($this->town)?'':$this->town;
|
||||||
$this->accountancy_code = trim($this->accountancy_code);
|
$this->accountancy_code = trim($this->accountancy_code);
|
||||||
$this->color = empty($this->color)?'':$this->color;
|
$this->color = empty($this->color)?'':$this->color;
|
||||||
|
$this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email))
|
if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email))
|
||||||
@ -1302,6 +1307,7 @@ class User extends CommonObject
|
|||||||
$sql.= ", signature = '".$this->db->escape($this->signature)."'";
|
$sql.= ", signature = '".$this->db->escape($this->signature)."'";
|
||||||
$sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'";
|
$sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'";
|
||||||
$sql.= ", color = '".$this->db->escape($this->color)."'";
|
$sql.= ", color = '".$this->db->escape($this->color)."'";
|
||||||
|
$sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null');
|
||||||
$sql.= ", note = '".$this->db->escape($this->note)."'";
|
$sql.= ", note = '".$this->db->escape($this->note)."'";
|
||||||
$sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
|
$sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
|
||||||
$sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null");
|
$sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null");
|
||||||
@ -1313,7 +1319,7 @@ class User extends CommonObject
|
|||||||
$sql.= ", weeklyhours= ".($this->weeklyhours != ''?"'".$this->db->escape($this->weeklyhours)."'":"null");
|
$sql.= ", weeklyhours= ".($this->weeklyhours != ''?"'".$this->db->escape($this->weeklyhours)."'":"null");
|
||||||
$sql.= ", entity = '".$this->db->escape($this->entity)."'";
|
$sql.= ", entity = '".$this->db->escape($this->entity)."'";
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user