2
0
forked from Wavyzz/dolibarr
This commit is contained in:
Frédéric FRANCE
2020-12-30 21:41:44 +01:00
parent 42ca3bcdc7
commit 94e859bf6a
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 = '') public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{ {
global $db, $conf; global $conf;
$obj_ret = array(); $obj_ret = array();
@@ -183,7 +183,9 @@ class Subscriptions extends DolibarrApi
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') {
continue;
}
$subscription->$field = $value; $subscription->$field = $value;
} }
@@ -236,8 +238,9 @@ class Subscriptions extends DolibarrApi
{ {
$subscription = array(); $subscription = array();
foreach (Subscriptions::$FIELDS as $field) { foreach (Subscriptions::$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");
}
$subscription[$field] = $data[$field]; $subscription[$field] = $data[$field];
} }
return $subscription; return $subscription;

View File

@@ -84,8 +84,15 @@ class Subscription extends CommonObject
* @var int ID * @var int ID
*/ */
public $fk_type; public $fk_type;
/**
* @var int Member ID
*/
public $fk_adherent; public $fk_adherent;
/**
* @var double amount subscription
*/
public $amount; public $amount;
/** /**
@@ -140,7 +147,9 @@ class Subscription extends CommonObject
$this->error = $langs->trans("ErrorBadValueForDate"); $this->error = $langs->trans("ErrorBadValueForDate");
return -1; return -1;
} }
if (empty($this->datec)) $this->datec = $now; if (empty($this->datec)) {
$this->datec = $now;
}
$this->db->begin(); $this->db->begin();
@@ -177,7 +186,9 @@ class Subscription extends CommonObject
$this->context = array('member' => $member); $this->context = array('member' => $member);
// Call triggers // Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
} }
@@ -278,7 +289,9 @@ class Subscription extends CommonObject
$this->context = array('member'=>$member); $this->context = array('member'=>$member);
// Call triggers // Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); $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 // End call triggers
} }
} else { } else {
@@ -320,7 +333,9 @@ class Subscription extends CommonObject
if (!$notrigger) { if (!$notrigger) {
// Call triggers // Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); $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 // End call triggers
} }
} }
@@ -407,16 +422,24 @@ class Subscription extends CommonObject
if ($option != 'nolink') { if ($option != 'nolink') {
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $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 ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $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).'">'; $linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $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) {
if ($withpicto != 2) $result .= $this->ref; $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 .= $linkend;
return $result; return $result;