Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into dev…
Browse files Browse the repository at this point in the history
…elop-work-on-warehouse-status
  • Loading branch information
fappels committed Dec 5, 2016
2 parents 3ca9664 + 1a842d8 commit c3b43e1
Show file tree
Hide file tree
Showing 36 changed files with 478 additions and 120 deletions.
5 changes: 1 addition & 4 deletions htdocs/adherents/class/api_members.class.php
Expand Up @@ -143,7 +143,7 @@ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0
}
}
else {
throw new RestException(503, 'Error when retrieve member list : '.$member->error);
throw new RestException(503, 'Error when retrieve member list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No member found');
Expand Down Expand Up @@ -289,9 +289,6 @@ function _validate($data)
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/
function _cleanObjectDatas($object) {

Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/class/api_subscriptions.class.php
Expand Up @@ -135,7 +135,7 @@ function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 0, $page = 0
}
}
else {
throw new RestException(503, 'Error when retrieve subscription list : '.$subscription->error);
throw new RestException(503, 'Error when retrieve subscription list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No Subscription found');
Expand Down
3 changes: 0 additions & 3 deletions htdocs/api/class/api.class.php
Expand Up @@ -81,9 +81,6 @@ function index()
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/
function _cleanObjectDatas($object) {

Expand Down
2 changes: 1 addition & 1 deletion htdocs/api/class/api_dictionnarycountries.class.php
Expand Up @@ -54,7 +54,7 @@ function __construct()
* @param int $page Page number (starting from zero)
* @param string $filter To filter the countries by name
* @param string $lang Code of the language the label of the countries must be translated to
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of countries
*
* @throws RestException
Expand Down
2 changes: 1 addition & 1 deletion htdocs/api/class/api_dictionnarytowns.class.php
Expand Up @@ -47,7 +47,7 @@ function __construct()
* @param int $page Page number (starting from zero)
* @param string $zipcode To filter on zipcode
* @param string $town To filter on city name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of towns
*
* @throws RestException
Expand Down
19 changes: 17 additions & 2 deletions htdocs/api/index.php
Expand Up @@ -115,6 +115,10 @@
elseif ($module == 'stock') {
$moduledirforclass = 'product/stock';
}
elseif ($module == 'fournisseur') {
$moduledirforclass = 'fourn';
}
//dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass);

// Defined if module is enabled
$enabled=true;
Expand All @@ -137,26 +141,37 @@
{
while (($file_searched = readdir($handle_part))!==false)
{
if ($file_searched == 'api_access.class.php') continue;

// Support of the deprecated API.
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg))
{
$classname = ucwords($reg[1]).'Api';
require_once $dir_part.$file_searched;
if (class_exists($classname))
{
dol_syslog("Found deprecated API by index.php: classname=".$classname." into ".$dir." - ".$dir_part.$file_searched);
//dol_syslog("Found deprecated API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
$api->r->addAPIClass($classname, '/');
}
else
{
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
}
}
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg))
{
$classname = ucwords($reg[1]);
$classname = str_replace('_', '', $classname);
require_once $dir_part.$file_searched;
if (class_exists($classname))
{
dol_syslog("Found API by index.php: classname=".$classname." into ".$dir." - ".$dir_part.$file_searched);
//dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
$listofapis[] = $classname;
}
else
{
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
}
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions htdocs/categories/class/api_categories.class.php
Expand Up @@ -157,7 +157,7 @@ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0
}
}
else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error);
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No category found');
Expand Down Expand Up @@ -243,7 +243,7 @@ function getListForItem($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0,
}
}
else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error);
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No category found');
Expand Down Expand Up @@ -346,9 +346,6 @@ function delete($id)
*
* @param Categorie $object Object to clean
* @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/
function _cleanObjectDatas($object) {

Expand Down
8 changes: 4 additions & 4 deletions htdocs/categories/class/api_deprecated_category.class.php
Expand Up @@ -152,13 +152,13 @@ function getList($type='product', $sortfield = "s.rowid", $sortorder = 'ASC', $l
$obj = $db->fetch_object($result);
$category_static = new Categorie($db);
if($category_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($category_static);
$obj_ret[] = $this->_cleanObjectDatas($category_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error);
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No category found');
Expand Down Expand Up @@ -233,13 +233,13 @@ function getListForItem($type='product', $sortfield = "s.rowid", $sortorder = 'A
$obj = $db->fetch_object($result);
$category_static = new Categorie($db);
if($category_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($category_static);
$obj_ret[] = $this->_cleanObjectDatas($category_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error);
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No category found');
Expand Down
4 changes: 2 additions & 2 deletions htdocs/comm/action/class/api_agendaevents.class.php
Expand Up @@ -146,13 +146,13 @@ function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 0, $page = 0, $
$obj = $db->fetch_object($result);
$actioncomm_static = new ActionComm($db);
if($actioncomm_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($actioncomm_static);
$obj_ret[] = $this->_cleanObjectDatas($actioncomm_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve Agenda Event list');
throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No Agenda Event found');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/index.php
Expand Up @@ -385,7 +385,7 @@
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.fk_soc = s.rowid";
$sql.= " AND cf.fk_statut = 0";
$sql.= " AND cf.entity IN (".getEntity('commande_fournisseur', 1).")";
$sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND cf.fk_soc = ".$socid;

Expand Down
6 changes: 3 additions & 3 deletions htdocs/comm/propal/class/api_proposals.class.php
Expand Up @@ -90,7 +90,7 @@ function get($id)
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'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
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
Expand Down Expand Up @@ -150,13 +150,13 @@ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0
$obj = $db->fetch_object($result);
$propal_static = new Propal($db);
if($propal_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($propal_static);
$obj_ret[] = $this->_cleanObjectDatas($propal_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve propal list');
throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No order found');
Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/class/api_deprecated_commande.class.php
Expand Up @@ -167,13 +167,13 @@ function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page =
$obj = $db->fetch_object($result);
$commande_static = new Commande($db);
if($commande_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($commande_static);
$obj_ret[] = $this->_cleanObjectDatas($commande_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve commande list');
throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No commande found');
Expand Down
6 changes: 4 additions & 2 deletions htdocs/commande/class/api_orders.class.php
Expand Up @@ -94,6 +94,8 @@ function get($id)
* @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of order objects
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf;
Expand Down Expand Up @@ -153,13 +155,13 @@ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page =
$obj = $db->fetch_object($result);
$commande_static = new Commande($db);
if($commande_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($commande_static);
$obj_ret[] = $this->_cleanObjectDatas($commande_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve commande list');
throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No order found');
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/facture/class/api_deprecated_invoice.class.php
Expand Up @@ -165,13 +165,13 @@ function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page =
$obj = $db->fetch_object($result);
$invoice_static = new Facture($db);
if($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($invoice_static);
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve invoice list');
throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No invoice found');
Expand Down
32 changes: 16 additions & 16 deletions htdocs/compta/facture/class/api_invoices.class.php
Expand Up @@ -83,23 +83,23 @@ function get($id)
*
* Get a list of invoices
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param int $socid Filter list with thirdparty ID
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of invoice objects
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @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 $status Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of invoice objects
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid=0, $status='', $sqlfilters = '') {
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
global $db, $conf;

$obj_ret = array();

$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $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;

// 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;
Expand All @@ -112,7 +112,7 @@ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0

$sql.= ' WHERE t.entity IN ('.getEntity('facture', 1).')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socid) $sql.= " AND t.fk_soc = ".$socid;
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

// Filter by status
Expand Down Expand Up @@ -156,13 +156,13 @@ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0
$obj = $db->fetch_object($result);
$invoice_static = new Facture($db);
if($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($invoice_static);
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve invoice list');
throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No invoice found');
Expand Down Expand Up @@ -255,7 +255,7 @@ function delete($id)
throw new RestException(404, 'Invoice not found');
}

if( ! DolibarrApi::_checkAccessToResource('facture',$this->facture->id)) {
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}

Expand All @@ -267,7 +267,7 @@ function delete($id)
return array(
'success' => array(
'code' => 200,
'message' => 'Facture deleted'
'message' => 'Invoice deleted'
)
);
}
Expand Down
6 changes: 3 additions & 3 deletions htdocs/contact/card.php
Expand Up @@ -1183,10 +1183,10 @@
print '</td></tr>';

print '<tr><td>';
print $langs->trans("ExportCardToFormat").'</td><td colspan="3">';
print $langs->trans("VCard").'</td><td colspan="3">';
print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'">';
print img_picto($langs->trans("VCard"),'vcard.png').' ';
print $langs->trans("VCard");
print img_picto($langs->trans("Download"),'vcard.png').' ';
print $langs->trans("Download");
print '</a>';
print '</td></tr>';

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/company.lib.php
Expand Up @@ -1390,7 +1390,7 @@ function show_subsidiaries($conf,$langs,$db,$object)
{
$socstatic = new Societe($db);

print load_fiche_titre($langs->trans("Subsidiaries"));
print load_fiche_titre($langs->trans("Subsidiaries"), '', '');
print "\n".'<table class="noborder" width="100%">'."\n";

print '<tr class="liste_titre"><td>'.$langs->trans("Company").'</td>';
Expand Down

0 comments on commit c3b43e1

Please sign in to comment.