add visibility

This commit is contained in:
Frédéric FRANCE 2019-02-27 17:53:52 +01:00
parent 739d8f82a5
commit 089875b8a2
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
8 changed files with 411 additions and 407 deletions

View File

@ -411,7 +411,7 @@ class BookKeeping extends CommonObject
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
@ -1308,7 +1308,7 @@ class BookKeeping extends CommonObject
* @param string $importkey Import key
* @return int Result
*/
function deleteByImportkey($importkey)
public function deleteByImportkey($importkey)
{
$this->db->begin();
@ -1338,7 +1338,7 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
function deleteByYearAndJournal($delyear = '', $journal = '', $mode = '')
public function deleteByYearAndJournal($delyear = '', $journal = '', $mode = '')
{
global $conf;
@ -1378,7 +1378,7 @@ class BookKeeping extends CommonObject
* @param int $piecenum Piecenum to delete
* @return int Result
*/
function deleteMvtNum($piecenum)
public function deleteMvtNum($piecenum)
{
global $conf;
@ -1565,7 +1565,7 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
function fetchAllPerMvt($piecenum, $mode = '')
public function fetchAllPerMvt($piecenum, $mode = '')
{
global $conf;
@ -1618,14 +1618,14 @@ class BookKeeping extends CommonObject
return 1;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Export bookkeping
*
* @param string $model Model
* @return int Result
*/
function export_bookkeping($model = 'ebp')
public function export_bookkeping($model = 'ebp')
{
// phpcs:enable
global $conf;
@ -1771,7 +1771,7 @@ class BookKeeping extends CommonObject
*/
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounts with label by chart of accounts
*
@ -1784,7 +1784,7 @@ class BookKeeping extends CommonObject
* @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @return string String with HTML select
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
{
// phpcs:enable
global $conf;
@ -1843,14 +1843,14 @@ class BookKeeping extends CommonObject
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Description of a root accounting account
*
* @param string $account Accounting account
* @return string Root account
*/
function get_compte_racine($account = null)
public function get_compte_racine($account = null)
{
// phpcs:enable
global $conf;
@ -1884,15 +1884,15 @@ class BookKeeping extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Description of accounting account
*
* @param string $account Accounting account
* @return string Account desc
*/
function get_compte_desc($account = null)
{
public function get_compte_desc($account = null)
{
// phpcs:enable
global $conf;

View File

@ -32,15 +32,15 @@ abstract class ActionsAdherentCardCommon
*/
public $db;
var $dirmodule;
var $targetmodule;
var $canvas;
var $card;
public $dirmodule;
public $targetmodule;
public $canvas;
public $card;
//! Template container
var $tpl = array();
public $tpl = array();
//! Object container
var $object;
public $object;
/**
* @var string Error code (or message)
@ -59,7 +59,7 @@ abstract class ActionsAdherentCardCommon
* @param int $id Object id
* @return object Object loaded
*/
function getObject($id)
public function getObject($id)
{
//$ret = $this->getInstanceDao();
@ -75,7 +75,7 @@ abstract class ActionsAdherentCardCommon
//}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set content of ->tpl array, to use into template
*
@ -83,7 +83,7 @@ abstract class ActionsAdherentCardCommon
* @param int $id Id
* @return string HTML output
*/
function assign_values(&$action, $id)
public function assign_values(&$action, $id)
{
// phpcs:enable
global $conf, $langs, $user, $canvas;
@ -245,23 +245,23 @@ abstract class ActionsAdherentCardCommon
// phpcs:enable
global $langs, $mysoc;
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
$this->object->fk_soc = $_POST["fk_soc"];
$this->object->lastname = $_POST["lastname"];
$this->object->firstname = $_POST["firstname"];
$this->object->civility_id = $_POST["civility_id"];
$this->object->address = $_POST["address"];
$this->object->zip = $_POST["zipcode"];
$this->object->town = $_POST["town"];
$this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
$this->object->state_id = $_POST["state_id"];
$this->object->phone_perso = $_POST["phone_perso"];
$this->object->phone_mobile = $_POST["phone_mobile"];
$this->object->email = $_POST["email"];
$this->object->note = $_POST["note"];
$this->object->canvas = $_POST["canvas"];
$this->object->fk_soc = $_POST["fk_soc"];
$this->object->lastname = $_POST["lastname"];
$this->object->firstname = $_POST["firstname"];
$this->object->civility_id = $_POST["civility_id"];
$this->object->address = $_POST["address"];
$this->object->zip = $_POST["zipcode"];
$this->object->town = $_POST["town"];
$this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
$this->object->state_id = $_POST["state_id"];
$this->object->phone_perso = $_POST["phone_perso"];
$this->object->phone_mobile = $_POST["phone_mobile"];
$this->object->email = $_POST["email"];
$this->object->note = $_POST["note"];
$this->object->canvas = $_POST["canvas"];
// We set country_id, and country_code label of the chosen country
if ($this->object->country_id)
@ -272,8 +272,8 @@ abstract class ActionsAdherentCardCommon
{
$obj = $this->db->fetch_object($resql);
$this->object->country_code = $obj->code;
$this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
$this->object->country_code = $obj->code;
$this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
}
else
{

View File

@ -39,7 +39,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
* @param string $canvas Name of canvas
* @param string $card Name of tab (sub-canvas)
*/
function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
{
$this->db = $db;
$this->dirmodule = $dirmodule;
@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Assign custom values for canvas
*
@ -75,7 +75,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
* @param int $id Id
* @return void
*/
function assign_values(&$action, $id)
public function assign_values(&$action, $id)
{
// phpcs:enable
global $limit, $offset, $sortfield, $sortorder;
@ -122,7 +122,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
@ -132,7 +132,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @return void
*/
function LoadListDatas($limit, $offset, $sortfield, $sortorder)
public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
// phpcs:enable
global $conf, $langs;

View File

@ -41,7 +41,7 @@ class Members extends DolibarrApi
/**
* Constructor
*/
function __construct()
public function __construct()
{
global $db, $conf;
$this->db = $db;
@ -57,7 +57,7 @@ class Members extends DolibarrApi
*
* @throws RestException
*/
function get($id)
public function get($id)
{
if(! DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401);
@ -91,7 +91,7 @@ class Members extends DolibarrApi
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '')
{
global $db, $conf;
@ -162,7 +162,7 @@ class Members extends DolibarrApi
* @param array $request_data Request data
* @return int ID of member
*/
function post($request_data = null)
public function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
@ -187,7 +187,7 @@ class Members extends DolibarrApi
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = null)
public function put($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
@ -242,7 +242,7 @@ class Members extends DolibarrApi
* @param int $id member ID
* @return array
*/
function delete($id)
public function delete($id)
{
if(! DolibarrApiAccess::$user->rights->adherent->supprimer) {
throw new RestException(401);
@ -277,7 +277,7 @@ class Members extends DolibarrApi
*
* @throws RestException
*/
function _validate($data)
private function _validate($data)
{
$member = array();
foreach (Members::$FIELDS as $field) {
@ -294,7 +294,7 @@ class Members extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object)
private function _cleanObjectDatas($object)
{
$object = parent::_cleanObjectDatas($object);
@ -328,7 +328,7 @@ class Members extends DolibarrApi
*
* @url GET {id}/subscriptions
*/
function getSubscriptions($id)
public function getSubscriptions($id)
{
$obj_ret = array();
@ -361,7 +361,7 @@ class Members extends DolibarrApi
*
* @url POST {id}/subscriptions
*/
function createSubscription($id, $start_date, $end_date, $amount, $label = '')
public function createSubscription($id, $start_date, $end_date, $amount, $label = '')
{
if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
throw new RestException(401);
@ -389,7 +389,7 @@ class Members extends DolibarrApi
*
* @url GET {id}/categories
*/
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
{
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);

View File

@ -37,7 +37,7 @@ class MembersTypes extends DolibarrApi
/**
* Constructor
*/
function __construct()
public function __construct()
{
global $db, $conf;
$this->db = $db;
@ -53,7 +53,7 @@ class MembersTypes extends DolibarrApi
*
* @throws RestException
*/
function get($id)
public function get($id)
{
if(! DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401);
@ -86,7 +86,7 @@ class MembersTypes extends DolibarrApi
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{
global $db, $conf;
@ -154,7 +154,7 @@ class MembersTypes extends DolibarrApi
* @param array $request_data Request data
* @return int ID of member type
*/
function post($request_data = null)
public function post($request_data = null)
{
if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401);
@ -179,7 +179,7 @@ class MembersTypes extends DolibarrApi
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = null)
public function put($id, $request_data = null)
{
if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401);
@ -220,7 +220,7 @@ class MembersTypes extends DolibarrApi
* @param int $id member type ID
* @return array
*/
function delete($id)
public function delete($id)
{
if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401);
@ -255,7 +255,7 @@ class MembersTypes extends DolibarrApi
*
* @throws RestException
*/
function _validate($data)
private function _validate($data)
{
$membertype = array();
foreach (MembersTypes::$FIELDS as $field) {
@ -272,7 +272,7 @@ class MembersTypes extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object)
private function _cleanObjectDatas($object)
{
$object = parent::_cleanObjectDatas($object);

View File

@ -40,7 +40,7 @@ class Subscriptions extends DolibarrApi
/**
* Constructor
*/
function __construct()
public function __construct()
{
global $db, $conf;
$this->db = $db;
@ -56,7 +56,7 @@ class Subscriptions extends DolibarrApi
*
* @throws RestException
*/
function get($id)
public function get($id)
{
if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
throw new RestException(401);
@ -85,7 +85,7 @@ class Subscriptions extends DolibarrApi
*
* @throws RestException
*/
function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{
global $db, $conf;
@ -151,7 +151,7 @@ class Subscriptions extends DolibarrApi
* @param array $request_data Request data
* @return int ID of subscription
*/
function post($request_data = null)
public function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
throw new RestException(401);
@ -176,7 +176,7 @@ class Subscriptions extends DolibarrApi
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = null)
public function put($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401);
@ -209,7 +209,7 @@ class Subscriptions extends DolibarrApi
* @param int $id ID of subscription to delete
* @return array
*/
function delete($id)
public function delete($id)
{
// The right to delete a subscription comes with the right to create one.
if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
@ -241,7 +241,7 @@ class Subscriptions extends DolibarrApi
*
* @throws RestException
*/
function _validate($data)
private function _validate($data)
{
$subscription = array();
foreach (Subscriptions::$FIELDS as $field) {

View File

@ -32,78 +32,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class Subscription extends CommonObject
{
/**
* @var string ID to identify managed object
*/
public $element='subscription';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element='subscription';
/**
* @var string ID to identify managed object
*/
public $element='subscription';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
public $picto='payment';
* @var string Name of table without prefix where object is stored
*/
public $table_element='subscription';
public $datec; // Date creation
public $datem; // Date modification
public $dateh; // Subscription start date (date subscription)
public $datef; // Subscription end date
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
public $picto='payment';
/**
public $datec; // Date creation
public $datem; // Date modification
public $dateh; // Subscription start date (date subscription)
public $datef; // Subscription end date
/**
* @var int ID
*/
public $fk_type;
public $fk_adherent;
public $fk_type;
public $fk_adherent;
public $amount;
public $amount;
/**
/**
* @var int ID
*/
public $fk_bank;
public $fk_bank;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
}
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
/**
* Function who permitted cretaion of the subscription
*
* @param User $user User that create
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id subscription created if OK
*/
function create($user, $notrigger = false)
{
global $langs;
/**
* Function who permitted cretaion of the subscription
*
* @param User $user User that create
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id subscription created if OK
*/
public function create($user, $notrigger = false)
{
global $langs;
$error = 0;
$error = 0;
$now=dol_now();
$now=dol_now();
// Check parameters
if ($this->datef <= $this->dateh)
{
$this->error=$langs->trans("ErrorBadValueForDate");
return -1;
}
if (empty($this->datec)) $this->datec = $now;
// Check parameters
if ($this->datef <= $this->dateh)
{
$this->error=$langs->trans("ErrorBadValueForDate");
return -1;
}
if (empty($this->datec)) $this->datec = $now;
$this->db->begin();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
if ($this->fk_type == null) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
@ -113,338 +113,338 @@ class Subscription extends CommonObject
} else {
$type=$this->fk_type;
}
$sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
$sql.= " '".$this->db->idate($this->dateh)."',";
$sql.= " '".$this->db->idate($this->datef)."',";
$sql.= " ".$this->amount.",";
$sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')";
$sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
$sql.= " '".$this->db->idate($this->dateh)."',";
$sql.= " '".$this->db->idate($this->datef)."',";
$sql.= " ".$this->amount.",";
$sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')";
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror();
}
$resql = $this->db->query($sql);
if (! $resql) {
$error++;
$this->errors[] = $this->db->lasterror();
}
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
}
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Method to load a subscription
*
* @param int $rowid Id subscription
* @return int <0 if KO, =0 if not found, >0 if OK
*/
function fetch($rowid)
{
/**
* Method to load a subscription
*
* @param int $rowid Id subscription
* @return int <0 if KO, =0 if not found, >0 if OK
*/
public function fetch($rowid)
{
$sql ="SELECT rowid, fk_type, fk_adherent, datec,";
$sql.=" tms,";
$sql.=" dateadh as dateh,";
$sql.=" datef,";
$sql.=" subscription, note, fk_bank";
$sql.=" FROM ".MAIN_DB_PREFIX."subscription";
$sql.=" WHERE rowid=".$rowid;
$sql.=" tms,";
$sql.=" dateadh as dateh,";
$sql.=" datef,";
$sql.=" subscription, note, fk_bank";
$sql.=" FROM ".MAIN_DB_PREFIX."subscription";
$sql.=" WHERE rowid=".$rowid;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->fk_type = $obj->fk_type;
$this->fk_adherent = $obj->fk_adherent;
$this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->tms);
$this->dateh = $this->db->jdate($obj->dateh);
$this->datef = $this->db->jdate($obj->datef);
$this->amount = $obj->subscription;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
return 1;
}
else
{
return 0;
}
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
$this->fk_type = $obj->fk_type;
$this->fk_adherent = $obj->fk_adherent;
$this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->tms);
$this->dateh = $this->db->jdate($obj->dateh);
$this->datef = $this->db->jdate($obj->datef);
$this->amount = $obj->subscription;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
return 1;
}
else
{
return 0;
}
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/**
* Update subscription
*
* @param User $user User who updated
* @param int $notrigger 0=Disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user, $notrigger = 0)
{
$error = 0;
/**
* Update subscription
*
* @param User $user User who updated
* @param int $notrigger 0=Disable triggers
* @return int <0 if KO, >0 if OK
*/
public function update($user, $notrigger = 0)
{
$error = 0;
$this->db->begin();
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
$sql .= " fk_type = ".$this->fk_type.",";
$sql .= " fk_adherent = ".$this->fk_adherent.",";
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
$sql .= " subscription = '".price2num($this->amount)."',";
$sql .= " dateadh='".$this->db->idate($this->dateh)."',";
$sql .= " datef='".$this->db->idate($this->datef)."',";
$sql .= " datec='".$this->db->idate($this->datec)."',";
$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
$sql .= " WHERE rowid = ".$this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
$sql .= " fk_type = ".$this->fk_type.",";
$sql .= " fk_adherent = ".$this->fk_adherent.",";
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
$sql .= " subscription = '".price2num($this->amount)."',";
$sql .= " dateadh='".$this->db->idate($this->dateh)."',";
$sql .= " datef='".$this->db->idate($this->datef)."',";
$sql .= " datec='".$this->db->idate($this->datec)."',";
$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if (! $error && ! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
if (! $error && ! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Delete a subscription
*
* @param User $user User that delete
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function delete($user, $notrigger = false)
{
$error = 0;
/**
* Delete a subscription
*
* @param User $user User that delete
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function delete($user, $notrigger = false)
{
$error = 0;
// It subscription is linked to a bank transaction, we get it
if ($this->fk_bank > 0)
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$accountline=new AccountLine($this->db);
$result=$accountline->fetch($this->fk_bank);
}
// It subscription is linked to a bank transaction, we get it
if ($this->fk_bank > 0)
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$accountline=new AccountLine($this->db);
$result=$accountline->fetch($this->fk_bank);
}
$this->db->begin();
$this->db->begin();
if (! $error) {
if (! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
if (! $error) {
if (! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->affected_rows($resql);
if ($num)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->affected_rows($resql);
if ($num)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined)
{
$result=$accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$accountline->error;
$this->db->rollback();
return -1;
}
}
else
{
$this->db->commit();
return 1;
}
}
else
{
$this->db->commit();
return 0;
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
}
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined)
{
$result=$accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$accountline->error;
$this->db->rollback();
return -1;
}
}
else
{
$this->db->commit();
return 1;
}
}
else
{
$this->db->commit();
return 0;
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return 1;
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return 1;
}
}
/**
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
/**
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $notooltip 1=Disable tooltip
* @param string $option Page for link ('', 'nolink', ...)
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string Chaine avec URL
*/
function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1)
{
global $langs;
* @param string $option Page for link ('', 'nolink', ...)
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string Chaine avec URL
*/
public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1)
{
global $langs;
$result='';
$result='';
$langs->load("members");
$langs->load("members");
$label=$langs->trans("ShowSubscription").': '.$this->ref;
$url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id;
if ($option != 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
$linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
$linkend = '</a>';
$linkend = '</a>';
$picto='payment';
$picto='payment';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
$result .= $linkend;
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
$result .= $linkend;
return $result;
}
return $result;
}
/**
* Retourne le libelle du statut d'une adhesion
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label
*/
function getLibStatut($mode = 0)
{
return '';
}
/**
* Retourne le libelle du statut d'une adhesion
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label
*/
public function getLibStatut($mode = 0)
{
return '';
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
* @param int $statut Id statut
* @return string Label
*/
function LibStatut($statut)
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
* @param int $statut Id statut
* @return string Label
*/
public function LibStatut($statut)
{
// phpcs:enable
global $langs;
$langs->load("members");
return '';
}
global $langs;
$langs->load("members");
return '';
}
/**
* Load information of the subscription object
*
*
* @param int $id Id subscription
* @return void
*/
function info($id)
{
$sql = 'SELECT c.rowid, c.datec,';
$sql.= ' c.tms as datem';
$sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
$sql.= ' WHERE c.rowid = '.$id;
public function info($id)
{
$sql = 'SELECT c.rowid, c.datec,';
$sql.= ' c.tms as datem';
$sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
$sql.= ' WHERE c.rowid = '.$id;
$result=$this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$result=$this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datem);
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datem);
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
}

View File

@ -87,7 +87,7 @@ class DolibarrApi
);
}*/
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Clean sensible object datas
*
@ -96,7 +96,7 @@ class DolibarrApi
*/
protected function _cleanObjectDatas($object)
{
// phpcs:enable
// Remove $db object property for object
unset($object->db);
unset($object->isextrafieldmanaged);
@ -208,6 +208,7 @@ class DolibarrApi
return $object;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Check user access to a resource
*
@ -224,7 +225,7 @@ class DolibarrApi
*/
protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
{
// phpcs:enable
// Features/modules to check
$featuresarray = array($resource);
if (preg_match('/&/', $resource)) {
@ -242,6 +243,7 @@ class DolibarrApi
return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Return if a $sqlfilters parameter is valid
*
@ -250,6 +252,7 @@ class DolibarrApi
*/
protected function _checkFilters($sqlfilters)
{
// phpcs:enable
//$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
//$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
$tmp=$sqlfilters;
@ -272,6 +275,7 @@ class DolibarrApi
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Function to forge a SQL criteria
*