Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
a14aab5eb1
commit
50f55cac35
@ -28,180 +28,180 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
|||||||
*/
|
*/
|
||||||
class SupplierOrders extends DolibarrApi
|
class SupplierOrders 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'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var CommandeFournisseur $order {@type CommandeFournisseur}
|
* @var CommandeFournisseur $order {@type CommandeFournisseur}
|
||||||
*/
|
*/
|
||||||
public $order;
|
public $order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->order = new CommandeFournisseur($this->db);
|
$this->order = new CommandeFournisseur($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get properties of a supplier order object
|
* Get properties of a supplier order object
|
||||||
*
|
*
|
||||||
* Return an array with supplier order information
|
* Return an array with supplier order information
|
||||||
*
|
*
|
||||||
* @param int $id ID of supplier order
|
* @param int $id ID of supplier order
|
||||||
* @return array|mixed data without useless information
|
* @return array|mixed data without useless information
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
public function get($id)
|
public function get($id)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) {
|
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->order->fetch($id);
|
$result = $this->order->fetch($id);
|
||||||
if ( ! $result ) {
|
if ( ! $result ) {
|
||||||
throw new RestException(404, 'Supplier order not found');
|
throw new RestException(404, 'Supplier order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
||||||
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->order->fetchObjectLinked();
|
$this->order->fetchObjectLinked();
|
||||||
return $this->_cleanObjectDatas($this->order);
|
return $this->_cleanObjectDatas($this->order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List orders
|
* List orders
|
||||||
*
|
*
|
||||||
* Get a list of supplier orders
|
* Get a list of supplier 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
|
||||||
* @param int $page Page number
|
* @param int $page Page number
|
||||||
* @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
|
* @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
|
||||||
* @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused
|
* @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused
|
||||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
|
||||||
* @return array Array of order objects
|
* @return array Array of order objects
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
|
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
|
||||||
{
|
{
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
|
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
|
||||||
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
|
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $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
|
||||||
$search_sale = 0;
|
$search_sale = 0;
|
||||||
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 t.rowid";
|
$sql = "SELECT t.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_fournisseur as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t";
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||||
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
||||||
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
|
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
|
||||||
if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)";
|
if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)";
|
||||||
if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)";
|
if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)";
|
||||||
if ($status == 'running') $sql.= " AND t.fk_statut IN (3)";
|
if ($status == 'running') $sql.= " AND t.fk_statut IN (3)";
|
||||||
if ($status == 'received_start') $sql.= " AND t.fk_statut IN (4)";
|
if ($status == 'received_start') $sql.= " AND t.fk_statut IN (4)";
|
||||||
if ($status == 'received_end') $sql.= " AND t.fk_statut IN (5)";
|
if ($status == 'received_end') $sql.= " AND t.fk_statut IN (5)";
|
||||||
if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (6,7)";
|
if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (6,7)";
|
||||||
if ($status == 'refused') $sql.= " AND t.fk_statut IN (9)";
|
if ($status == 'refused') $sql.= " AND t.fk_statut IN (9)";
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters)
|
if ($sqlfilters)
|
||||||
{
|
{
|
||||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||||
{
|
{
|
||||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||||
}
|
}
|
||||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.= $db->order($sortfield, $sortorder);
|
$sql.= $db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0)
|
if ($page < 0)
|
||||||
{
|
{
|
||||||
$page = 0;
|
$page = 0;
|
||||||
}
|
}
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
|
|
||||||
$sql.= $db->plimit($limit + 1, $offset);
|
$sql.= $db->plimit($limit + 1, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||||
while ($i < $min)
|
while ($i < $min)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$order_static = new CommandeFournisseur($db);
|
$order_static = new CommandeFournisseur($db);
|
||||||
if($order_static->fetch($obj->rowid)) {
|
if($order_static->fetch($obj->rowid)) {
|
||||||
$obj_ret[] = $this->_cleanObjectDatas($order_static);
|
$obj_ret[] = $this->_cleanObjectDatas($order_static);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new RestException(503, 'Error when retrieve supplier order list : '.$db->lasterror());
|
throw new RestException(503, 'Error when retrieve supplier order list : '.$db->lasterror());
|
||||||
}
|
}
|
||||||
if( ! count($obj_ret)) {
|
if( ! count($obj_ret)) {
|
||||||
throw new RestException(404, 'No supplier order found');
|
throw new RestException(404, 'No supplier order found');
|
||||||
}
|
}
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create supplier order object
|
* Create supplier order object
|
||||||
*
|
*
|
||||||
* @param array $request_data Request datas
|
* @param array $request_data Request datas
|
||||||
* @return int ID of supplier order
|
* @return int ID of supplier order
|
||||||
*/
|
*/
|
||||||
public function post($request_data = null)
|
public function post($request_data = null)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
|
||||||
throw new RestException(401, "Insuffisant rights");
|
throw new RestException(401, "Insuffisant rights");
|
||||||
}
|
}
|
||||||
// Check mandatory fields
|
// Check mandatory fields
|
||||||
$result = $this->_validate($request_data);
|
$result = $this->_validate($request_data);
|
||||||
|
|
||||||
foreach($request_data as $field => $value) {
|
foreach($request_data as $field => $value) {
|
||||||
$this->order->$field = $value;
|
$this->order->$field = $value;
|
||||||
}
|
}
|
||||||
if(! array_keys($request_data, 'date')) {
|
if(! array_keys($request_data, 'date')) {
|
||||||
$this->order->date = dol_now();
|
$this->order->date = dol_now();
|
||||||
}
|
}
|
||||||
/* We keep lines as an array
|
/* We keep lines as an array
|
||||||
if (isset($request_data["lines"])) {
|
if (isset($request_data["lines"])) {
|
||||||
$lines = array();
|
$lines = array();
|
||||||
foreach ($request_data["lines"] as $line) {
|
foreach ($request_data["lines"] as $line) {
|
||||||
@ -210,163 +210,163 @@ class SupplierOrders extends DolibarrApi
|
|||||||
$this->order->lines = $lines;
|
$this->order->lines = $lines;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if ($this->order->create(DolibarrApiAccess::$user) < 0) {
|
if ($this->order->create(DolibarrApiAccess::$user) < 0) {
|
||||||
throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors));
|
throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors));
|
||||||
}
|
}
|
||||||
return $this->order->id;
|
return $this->order->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update supplier order
|
* Update supplier order
|
||||||
*
|
*
|
||||||
* @param int $id Id of supplier order to update
|
* @param int $id Id of supplier order to update
|
||||||
* @param array $request_data Datas
|
* @param array $request_data Datas
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function put($id, $request_data = null)
|
public function put($id, $request_data = null)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->order->fetch($id);
|
$result = $this->order->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Supplier order not found');
|
throw new RestException(404, 'Supplier order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
||||||
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) {
|
||||||
if ($field == 'id') continue;
|
if ($field == 'id') continue;
|
||||||
$this->order->$field = $value;
|
$this->order->$field = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->order->update($id, DolibarrApiAccess::$user))
|
if($this->order->update($id, DolibarrApiAccess::$user))
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete supplier order
|
* Delete supplier order
|
||||||
*
|
*
|
||||||
* @param int $id Supplier order ID
|
* @param int $id Supplier order ID
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) {
|
if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$result = $this->order->fetch($id);
|
$result = $this->order->fetch($id);
|
||||||
if ( ! $result) {
|
if ( ! $result) {
|
||||||
throw new RestException(404, 'Supplier order not found');
|
throw new RestException(404, 'Supplier order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
||||||
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->order->delete(DolibarrApiAccess::$user) < 0) {
|
if ( $this->order->delete(DolibarrApiAccess::$user) < 0) {
|
||||||
throw new RestException(500);
|
throw new RestException(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Supplier order deleted'
|
'message' => 'Supplier 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."
|
||||||
* Workaround: send this in the body
|
* Workaround: send this in the body
|
||||||
* {
|
* {
|
||||||
* "idwarehouse": 0,
|
* "idwarehouse": 0,
|
||||||
* "notrigger": 0
|
* "notrigger": 0
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public function validate($id, $idwarehouse = 0, $notrigger = 0)
|
public function validate($id, $idwarehouse = 0, $notrigger = 0)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
|
if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
$result = $this->order->fetch($id);
|
$result = $this->order->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
|
||||||
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->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
|
$result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
|
||||||
if ($result == 0) {
|
if ($result == 0) {
|
||||||
throw new RestException(304, 'Error nothing done. May be object is already validated');
|
throw new RestException(304, 'Error nothing done. May be object is already validated');
|
||||||
}
|
}
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
throw new RestException(500, 'Error when validating Order: '.$this->order->error);
|
throw new RestException(500, 'Error when validating Order: '.$this->order->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'Order validated (Ref='.$this->order->ref.')'
|
'message' => 'Order validated (Ref='.$this->order->ref.')'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||||
/**
|
/**
|
||||||
* Clean sensible object datas
|
* Clean sensible object datas
|
||||||
*
|
*
|
||||||
* @param Object $object Object to clean
|
* @param Object $object Object to clean
|
||||||
* @return array Array of cleaned object properties
|
* @return array Array of cleaned object properties
|
||||||
*/
|
*/
|
||||||
protected function _cleanObjectDatas($object)
|
protected function _cleanObjectDatas($object)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
$object = parent::_cleanObjectDatas($object);
|
$object = parent::_cleanObjectDatas($object);
|
||||||
|
|
||||||
unset($object->rowid);
|
unset($object->rowid);
|
||||||
unset($object->barcode_type);
|
unset($object->barcode_type);
|
||||||
unset($object->barcode_type_code);
|
unset($object->barcode_type_code);
|
||||||
unset($object->barcode_type_label);
|
unset($object->barcode_type_label);
|
||||||
unset($object->barcode_type_coder);
|
unset($object->barcode_type_coder);
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate fields before create or update object
|
* Validate fields before create or update object
|
||||||
*
|
*
|
||||||
* @param array $data Datas to validate
|
* @param array $data Datas to validate
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
private function _validate($data)
|
private function _validate($data)
|
||||||
{
|
{
|
||||||
$order = array();
|
$order = array();
|
||||||
foreach (SupplierOrders::$FIELDS as $field) {
|
foreach (SupplierOrders::$FIELDS as $field) {
|
||||||
if (!isset($data[$field]))
|
if (!isset($data[$field]))
|
||||||
throw new RestException(400, "$field field missing");
|
throw new RestException(400, "$field field missing");
|
||||||
$order[$field] = $data[$field];
|
$order[$field] = $data[$field];
|
||||||
}
|
}
|
||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,10 +38,10 @@ $hookmanager->initHooks(array('thirdpartiesindex'));
|
|||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
|
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid = $user->societe_id;
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$result=restrictedArea($user, 'societe', 0, '', '', '', '');
|
$result = restrictedArea($user, 'societe', 0, '', '', '', '');
|
||||||
|
|
||||||
$thirdparty_static = new Societe($db);
|
$thirdparty_static = new Societe($db);
|
||||||
|
|
||||||
@ -51,10 +51,10 @@ $thirdparty_static = new Societe($db);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$transAreaType = $langs->trans("ThirdPartiesArea");
|
$transAreaType = $langs->trans("ThirdPartiesArea");
|
||||||
$helpurl='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros';
|
$helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros';
|
||||||
|
|
||||||
llxHeader("", $langs->trans("ThirdParties"), $helpurl);
|
llxHeader("", $langs->trans("ThirdParties"), $helpurl);
|
||||||
$linkback='';
|
$linkback = '';
|
||||||
print load_fiche_titre($transAreaType, $linkback, 'companies');
|
print load_fiche_titre($transAreaType, $linkback, 'companies');
|
||||||
|
|
||||||
|
|
||||||
@ -73,26 +73,26 @@ $third = array(
|
|||||||
'supplier' => 0,
|
'supplier' => 0,
|
||||||
'other' =>0
|
'other' =>0
|
||||||
);
|
);
|
||||||
$total=0;
|
$total = 0;
|
||||||
|
|
||||||
$sql = "SELECT s.rowid, s.client, s.fournisseur";
|
$sql = "SELECT s.rowid, s.client, s.fournisseur";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
|
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql .= " AND s.rowid = ".$socid;
|
||||||
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
|
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
while ($objp = $db->fetch_object($result))
|
while ($objp = $db->fetch_object($result))
|
||||||
{
|
{
|
||||||
$found=0;
|
$found = 0;
|
||||||
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; }
|
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; }
|
||||||
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; }
|
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; }
|
||||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; }
|
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; }
|
||||||
if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; }
|
if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; }
|
||||||
if ($found) $total++;
|
if ($found) $total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,14 +101,14 @@ else dol_print_error($db);
|
|||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table class="noborder nohover" width="100%">'."\n";
|
print '<table class="noborder nohover" width="100%">'."\n";
|
||||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
||||||
if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2))
|
if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2))
|
||||||
{
|
{
|
||||||
print '<tr><td class="center" colspan="2">';
|
print '<tr><td class="center" colspan="2">';
|
||||||
$dataseries=array();
|
$dataseries = array();
|
||||||
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect']));
|
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
|
||||||
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer']));
|
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer']));
|
||||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier']));
|
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
|
||||||
if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other']));
|
if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other']));
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||||
$dolgraph = new DolGraph();
|
$dolgraph = new DolGraph();
|
||||||
$dolgraph->SetData($dataseries);
|
$dolgraph->SetData($dataseries);
|
||||||
@ -122,23 +122,23 @@ if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(rou
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
|
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
|
||||||
{
|
{
|
||||||
$statstring = "<tr>";
|
$statstring = "<tr>";
|
||||||
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>';
|
$statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>';
|
||||||
$statstring.= "</tr>";
|
$statstring .= "</tr>";
|
||||||
}
|
}
|
||||||
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
|
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
|
||||||
{
|
{
|
||||||
$statstring.= "<tr>";
|
$statstring .= "<tr>";
|
||||||
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>';
|
$statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>';
|
||||||
$statstring.= "</tr>";
|
$statstring .= "</tr>";
|
||||||
}
|
}
|
||||||
if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
|
if (!empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
|
||||||
{
|
{
|
||||||
$statstring2 = "<tr>";
|
$statstring2 = "<tr>";
|
||||||
$statstring2.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>';
|
$statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>';
|
||||||
$statstring2.= "</tr>";
|
$statstring2 .= "</tr>";
|
||||||
}
|
}
|
||||||
print $statstring;
|
print $statstring;
|
||||||
print $statstring2;
|
print $statstring2;
|
||||||
@ -149,7 +149,7 @@ print '</td></tr>';
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
|
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
$elementtype = 'societe';
|
$elementtype = 'societe';
|
||||||
@ -161,41 +161,41 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
|
|||||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
|
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
|
||||||
print '<tr><td class="center" colspan="2">';
|
print '<tr><td class="center" colspan="2">';
|
||||||
$sql = "SELECT c.label, count(*) as nb";
|
$sql = "SELECT c.label, count(*) as nb";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
|
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
||||||
$sql.= " WHERE c.type = 2";
|
$sql .= " WHERE c.type = 2";
|
||||||
if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
|
if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
|
||||||
$sql.= " AND c.entity IN (".getEntity('category').")";
|
$sql .= " AND c.entity IN (".getEntity('category').")";
|
||||||
$sql.= " GROUP BY c.label";
|
$sql .= " GROUP BY c.label";
|
||||||
$total=0;
|
$total = 0;
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i=0;
|
$i = 0;
|
||||||
if (! empty($conf->use_javascript_ajax) )
|
if (!empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
$dataseries=array();
|
$dataseries = array();
|
||||||
$rest=0;
|
$rest = 0;
|
||||||
$nbmax=10;
|
$nbmax = 10;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
if ($i < $nbmax)
|
if ($i < $nbmax)
|
||||||
{
|
{
|
||||||
$dataseries[]=array($obj->label, round($obj->nb));
|
$dataseries[] = array($obj->label, round($obj->nb));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$rest+=$obj->nb;
|
$rest += $obj->nb;
|
||||||
}
|
}
|
||||||
$total+=$obj->nb;
|
$total += $obj->nb;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if ($i > $nbmax)
|
if ($i > $nbmax)
|
||||||
{
|
{
|
||||||
$dataseries[]=array($langs->trans("Other"), round($rest));
|
$dataseries[] = array($langs->trans("Other"), round($rest));
|
||||||
}
|
}
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||||
$dolgraph = new DolGraph();
|
$dolgraph = new DolGraph();
|
||||||
@ -214,7 +214,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
|
|||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
|
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
|
||||||
$total+=$obj->nb;
|
$total += $obj->nb;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,20 +234,20 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
|||||||
/*
|
/*
|
||||||
* Latest modified third parties
|
* Latest modified third parties
|
||||||
*/
|
*/
|
||||||
$max=15;
|
$max = 15;
|
||||||
$sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
|
$sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
|
||||||
$sql.= ", s.code_client";
|
$sql .= ", s.code_client";
|
||||||
$sql.= ", s.code_fournisseur";
|
$sql .= ", s.code_fournisseur";
|
||||||
$sql.= ", s.logo";
|
$sql .= ", s.logo";
|
||||||
$sql.= ", s.canvas, s.tms as datem, s.status as status";
|
$sql .= ", s.canvas, s.tms as datem, s.status as status";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
|
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql .= " AND s.rowid = ".$socid;
|
||||||
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)";
|
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
|
||||||
$sql.= $db->order("s.tms", "DESC");
|
$sql .= $db->order("s.tms", "DESC");
|
||||||
$sql.= $db->plimit($max, 0);
|
$sql .= $db->plimit($max, 0);
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
@ -274,16 +274,16 @@ if ($result)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$thirdparty_static->id=$objp->rowid;
|
$thirdparty_static->id = $objp->rowid;
|
||||||
$thirdparty_static->name=$objp->name;
|
$thirdparty_static->name = $objp->name;
|
||||||
$thirdparty_static->client=$objp->client;
|
$thirdparty_static->client = $objp->client;
|
||||||
$thirdparty_static->fournisseur=$objp->fournisseur;
|
$thirdparty_static->fournisseur = $objp->fournisseur;
|
||||||
$thirdparty_static->logo = $objp->logo;
|
$thirdparty_static->logo = $objp->logo;
|
||||||
$thirdparty_static->datem=$db->jdate($objp->datem);
|
$thirdparty_static->datem = $db->jdate($objp->datem);
|
||||||
$thirdparty_static->status=$objp->status;
|
$thirdparty_static->status = $objp->status;
|
||||||
$thirdparty_static->code_client = $objp->code_client;
|
$thirdparty_static->code_client = $objp->code_client;
|
||||||
$thirdparty_static->code_fournisseur = $objp->code_fournisseur;
|
$thirdparty_static->code_fournisseur = $objp->code_fournisseur;
|
||||||
$thirdparty_static->canvas=$objp->canvas;
|
$thirdparty_static->canvas = $objp->canvas;
|
||||||
$thirdparty_static->email = $objp->email;
|
$thirdparty_static->email = $objp->email;
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -293,21 +293,21 @@ if ($result)
|
|||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
// Type
|
// Type
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($thirdparty_static->client==1 || $thirdparty_static->client==3)
|
if ($thirdparty_static->client == 1 || $thirdparty_static->client == 3)
|
||||||
{
|
{
|
||||||
$thirdparty_static->name=$langs->trans("Customer");
|
$thirdparty_static->name = $langs->trans("Customer");
|
||||||
print $thirdparty_static->getNomUrl(0, 'customer', 0, 1);
|
print $thirdparty_static->getNomUrl(0, 'customer', 0, 1);
|
||||||
}
|
}
|
||||||
if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / ";
|
if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / ";
|
||||||
if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
|
if (($thirdparty_static->client == 2 || $thirdparty_static->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
|
||||||
{
|
{
|
||||||
$thirdparty_static->name=$langs->trans("Prospect");
|
$thirdparty_static->name = $langs->trans("Prospect");
|
||||||
print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1);
|
print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1);
|
||||||
}
|
}
|
||||||
if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
|
if (!empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur)
|
||||||
{
|
{
|
||||||
if ($thirdparty_static->client) print " / ";
|
if ($thirdparty_static->client) print " / ";
|
||||||
$thirdparty_static->name=$langs->trans("Supplier");
|
$thirdparty_static->name = $langs->trans("Supplier");
|
||||||
print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1);
|
print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1);
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -46,13 +46,13 @@ $stripearrayofkeysbyenv = array(
|
|||||||
$stripearrayofkeys = array();
|
$stripearrayofkeys = array();
|
||||||
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
||||||
{
|
{
|
||||||
$stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test
|
$stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live
|
$stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live
|
||||||
}
|
}
|
||||||
|
|
||||||
\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
|
\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
|
||||||
\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
|
\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
|
||||||
\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION)?"2019-05-16":$conf->global->STRIPE_FORCE_VERSION); // force version API
|
\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION) ? "2019-05-16" : $conf->global->STRIPE_FORCE_VERSION); // force version API
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user