Merge pull request #15843 from frederic34/subscriptionclass

doxygen
This commit is contained in:
Laurent Destailleur 2020-12-30 23:53:03 +01:00 committed by GitHub
commit ba02ad5fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 11 deletions

View File

@ -87,7 +87,7 @@ class Subscriptions extends DolibarrApi
*/
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{
global $db, $conf;
global $conf;
$obj_ret = array();
@ -183,7 +183,9 @@ class Subscriptions extends DolibarrApi
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
if ($field == 'id') {
continue;
}
$subscription->$field = $value;
}
@ -236,8 +238,9 @@ class Subscriptions extends DolibarrApi
{
$subscription = array();
foreach (Subscriptions::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$subscription[$field] = $data[$field];
}
return $subscription;

View File

@ -84,8 +84,15 @@ class Subscription extends CommonObject
* @var int ID
*/
public $fk_type;
/**
* @var int Member ID
*/
public $fk_adherent;
/**
* @var double amount subscription
*/
public $amount;
/**
@ -140,7 +147,9 @@ class Subscription extends CommonObject
$this->error = $langs->trans("ErrorBadValueForDate");
return -1;
}
if (empty($this->datec)) $this->datec = $now;
if (empty($this->datec)) {
$this->datec = $now;
}
$this->db->begin();
@ -177,7 +186,9 @@ class Subscription extends CommonObject
$this->context = array('member' => $member);
// Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
@ -278,7 +289,9 @@ class Subscription extends CommonObject
$this->context = array('member'=>$member);
// 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
if ($result < 0) {
$error++;
} //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
} else {
@ -320,7 +333,9 @@ class Subscription extends CommonObject
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
if ($result < 0) {
$error++;
} // Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
@ -407,16 +422,24 @@ class Subscription extends CommonObject
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';
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>';
$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;
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;