24 define (
'PAY_METHOD_NOT_SPECIFIED', 0);
25 define (
'PAY_METHOD_BILL', 1);
26 define (
'PAY_METHOD_BMF', 2);
27 define (
'PAY_METHOD_PAYPAL', 3);
55 $this->STATUS_NOT_BUYABLE = 0;
56 $this->STATUS_BUYABLE = 1;
57 $this->STATUS_EXPIRES = 2;
64 $this->pobject_id = $a_pobject_id;
75 $this->topic_id = $a_topic_id;
83 $this->ref_id = $a_ref_id;
91 $this->status = $a_status;
99 $this->pay_method = $a_method;
107 $this->vendor_id = $a_vendor_id;
116 $statement = $this->db->prepareManip(
117 'INSERT INTO payment_objects
124 array(
'integer',
'integer',
'integer',
'integer',
'integer'));
130 $this->db->execute($statement,
$data);
132 return (
int)$this->db->getLastInsertId();
135 public function delete()
139 include_once
'Services/Payment/classes/class.ilFileDataShop.php';
141 $oFileData->deassignFileFromPaymentObject();
143 $statement = $this->db->prepareManip(
'DELETE FROM payment_objects WHERE pobject_id = ?',
146 $this->db->execute($statement,
$data);
158 $statement = $this->db->prepareManip(
159 'UPDATE payment_objects
166 WHERE pobject_id = ?',
167 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'));
174 $this->db->execute($statement,
$data);
186 $query =
"SELECT * FROM payment_objects ".
187 "WHERE ref_id = '".$a_ref_id.
"'";
189 $res = $ilDB->query($query);
192 return $row->pobject_id;
201 static $cache = array();
202 if(isset($cache[$a_ref_id]))
204 return $cache[$a_ref_id];
207 $statement = $ilDB->prepare(
'SELECT pt_topic_fk FROM payment_objects WHERE ref_id = ?',
209 $result = $ilDB->execute($statement, array($a_ref_id));
212 $cache[$a_ref_id] = $row->pt_topic_fk;
213 return (
int)$cache[$a_ref_id];
241 $statement = $ilDB->prepare(
'SELECT COUNT(pay_method) AS pm FROM payment_objects WHERE pay_method = ?',
243 $result = $ilDB->execute($statement, array($pm));
246 return (
int)$row->pm;
257 include_once
'./payment/classes/class.ilPaymentTrustees.php';
258 include_once
'./payment/classes/class.ilPaymentVendors.php';
264 $vendors[] = $a_user_id;
272 $in .= implode(
"','",$vendors);
275 $query =
"SELECT * FROM payment_objects ".
276 "WHERE vendor_id ".$in;
278 $res = $ilDB->query($query);
281 $objects[$row->pobject_id][
'pobject_id'] = $row->pobject_id;
282 $objects[$row->pobject_id][
'ref_id'] = $row->ref_id;
283 $objects[$row->pobject_id][
'status'] = $row->status;
284 $objects[$row->pobject_id][
'pay_method'] = $row->pay_method;
285 $objects[$row->pobject_id][
'vendor_id'] = $row->vendor_id;
286 $objects[$row->pobject_id][
'topic_id'] = $row->pt_topic_fk;
288 return $objects ? $objects : array();
295 $query =
"SELECT * FROM payment_objects ";
297 if (
$_SESSION[
"pay_objects"][
"title_value"] !=
"")
299 $query .=
", object_reference AS obr ";
300 $query .=
", object_data AS od ";
303 if (
$_SESSION[
'pay_objects'][
'vendor'] !=
"")
305 $query .=
", usr_data AS ud ";
308 $query .=
" WHERE 1 ";
310 if (
$_SESSION[
"pay_objects"][
"title_value"])
312 $query .=
" AND obr.ref_id = payment_objects.ref_id AND od.obj_id = obr.obj_id ";
316 $title_search = explode(
" ", trim(
$_SESSION[
"pay_objects"][
"title_value"]));
317 for ($i = 0; $i < count($title_search); $i++)
319 $title_search[$i] = trim($title_search[$i]);
321 if ($title_search[$i] !=
"")
323 $search_string .=
" od.title LIKE ".$ilDB->quote(
"%".$title_search[$i].
"%").
" ";
325 switch (
$_SESSION[
"pay_objects"][
"title_type"])
328 if ($i < count($title_search) - 1) $search_string .=
" OR ";
331 if ($i < count($title_search) - 1) $search_string .=
" AND ";
337 if ($search_string !=
"")
339 $query .=
" AND (" . $search_string .
") ";
343 if (
$_SESSION[
'pay_objects'][
'vendor'] !=
"")
345 $query .=
" AND ud.usr_id = payment_objects.vendor_id AND login = ".$ilDB->quote(
$_SESSION[
"pay_objects"][
"vendor"]).
" ";
349 if (
$_SESSION[
"pay_objects"][
"pay_method"] ==
"1" ||
350 $_SESSION[
"pay_objects"][
"pay_method"] ==
"2" ||
351 $_SESSION[
"pay_objects"][
"pay_method"] ==
"3")
353 $query .=
" AND pay_method = '" .
$_SESSION[
"pay_objects"][
"pay_method"] .
"' ";
356 $res = $ilDB->query($query);
359 $objects[$row->pobject_id][
'pobject_id'] = $row->pobject_id;
360 $objects[$row->pobject_id][
'ref_id'] = $row->ref_id;
361 $objects[$row->pobject_id][
'status'] = $row->status;
362 $objects[$row->pobject_id][
'pay_method'] = $row->pay_method;
363 $objects[$row->pobject_id][
'vendor_id'] = $row->vendor_id;
364 $objects[$row->pobject_id][
'topic_id'] = $row->pt_topic_fk;
366 return $objects ? $objects : array();
373 $query =
"SELECT * FROM payment_objects ".
374 "WHERE pobject_id = '".$a_id.
"'";
376 $res = $ilDB->query($query);
391 $query =
"SELECT * FROM payment_objects ".
392 "WHERE ref_id = '".$a_ref_id.
"' ";
393 if ($a_vendor_id > 0)
395 $query .=
"AND vendor_id = '".$a_vendor_id.
"' ";
398 include_once
'./payment/classes/class.ilPaymentTrustees.php';
399 include_once
'./payment/classes/class.ilPaymentVendors.php';
404 $vendors[] = $a_user_id;
407 if(is_array($vendors) && count($vendors))
410 $in .= implode(
"','",$vendors);
413 $query .=
' OR vendor_id '.$in;
417 #"AND status = '1' OR status = '3' ";
419 $res = $ilDB->query($query);
421 return $res->numRows() ?
false :
true;
427 include_once
'./payment/classes/class.ilPaymentBookings.php';
429 global $rbacsystem,$ilDB;
432 if($rbacsystem->checkAccess(
'write', $a_ref_id))
437 include_once
'payment/classes/class.ilGeneralSettings.php';
443 $query =
"SELECT * FROM payment_objects ".
444 "WHERE ref_id = '".$a_ref_id.
"' ".
445 "AND (status = '1' OR status = '2')";
447 $res = $ilDB->query($query);
461 include_once
'./payment/classes/class.ilPaymentBookings.php';
463 global $rbacsystem,$ilDB;
465 $query =
"SELECT * FROM payment_objects ".
466 "WHERE ref_id = '".$a_ref_id.
"' ".
467 "AND (status = '1' OR status = '2')";
469 $res = $ilDB->query($query);
478 include_once
'payment/classes/class.ilGeneralSettings.php';
484 $statement = $ilDB->prepare(
'SELECT * FROM payment_objects
485 WHERE ref_id = ? AND (status = 1 or status = 2)',
487 $result = $ilDB->execute($statement, array($a_ref_id));
503 global $ilDB, $ilUser;
505 $statement = $ilDB->prepare(
'SELECT psc_id
506 FROM payment_objects AS po, payment_shopping_cart AS psc
507 WHERE ref_id = ? AND customer_id = ? AND po.pobject_id = psc.pobject_id',
508 array(
'integer',
'integer'));
509 $result = $ilDB->execute($statement, array($a_ref_id, $ilUser->getId()));
522 $statement = $this->db->prepare(
'SELECT * FROM payment_objects WHERE pobject_id = ?',