33 $this->STATUS_NOT_BUYABLE = 0;
34 $this->STATUS_BUYABLE = 1;
35 $this->STATUS_EXPIRES = 2;
37 $this->PAY_METHOD_NOT_SPECIFIED = 0;
38 include_once
'./Services/Payment/classes/class.ilPayMethods.php';
40 $tmp = $pmObj->readAll();
44 $tmp = strtoupper($pm[
'pm_title']);
45 $this->PAY_METHOD_.$tmp = $pm[
'pm_id'];
48 $this->pobject_id = $a_pobject_id;
60 $this->topic_id = $a_topic_id;
68 $this->ref_id = $a_ref_id;
76 $this->status = $a_status;
84 $this->pay_method = $a_method;
92 $this->vendor_id = $a_vendor_id;
104 $this->vat_id = $a_vat_id;
113 $val = (float)($a_amount - (round(($a_amount / (1 + ($oVAT->getRate() / 100))) * 100) / 100));
115 return number_format($val,
'2');
119 $val = (float)($a_amount - (round(($a_amount / (1 + ($oVAT->getRate() / 100))) * 100) / 100));
127 $next_id = $this->db->nextId(
'payment_objects');
129 $this->db->insert(
'payment_objects',array(
130 'pobject_id' => array(
'integer', $next_id),
131 'ref_id' => array(
'integer', $this->
getRefId()),
132 'status' => array(
'integer', $this->
getStatus()),
133 'pay_method' => array(
'integer', $this->
getPayMethod()),
134 'vendor_id' => array(
'integer', $this->
getVendorId()),
135 'pt_topic_fk' => array(
'integer', $this->
getTopicId()),
136 'vat_id' => array(
'integer', $this->
getVatId())
141 public function delete()
145 include_once
'Services/Payment/classes/class.ilFileDataShop.php';
147 $oFileData->deassignFileFromPaymentObject();
149 $statement = $this->db->manipulateF(
'DELETE FROM payment_objects WHERE pobject_id = %s',
163 $this->db->update(
'payment_objects',array(
164 'ref_id' => array(
'integer', $this->
getRefId()),
165 'status' => array(
'integer', $this->
getStatus()),
166 'pay_method' => array(
'integer', $this->
getPayMethod()),
167 'vendor_id' => array(
'integer', $this->
getVendorId()),
168 'pt_topic_fk' => array(
'integer', $this->
getTopicId()),
169 'vat_id' => array(
'integer', $this->
getVatId())
171 array(
'pobject_id' => array(
'integer', $this->
getPobjectId())));
183 $res = $ilDB->queryf(
'
184 SELECT * FROM payment_objects
191 return $row->pobject_id;
200 static $cache = array();
201 if(isset($cache[$a_ref_id]))
203 return $cache[$a_ref_id];
206 $result = $ilDB->queryf(
'SELECT pt_topic_fk FROM payment_objects WHERE ref_id = %s',
207 array(
'integer'),array($a_ref_id));
211 $cache[$a_ref_id] =
$row->pt_topic_fk;
212 return (
int)$cache[$a_ref_id];
223 $result = $ilDB->queryf(
'SELECT COUNT(pay_method) pm FROM payment_objects WHERE pay_method = %s',
224 array(
'integer'), array($a_id));
228 return (
int)
$row->pm;
239 include_once
'./Services/Payment/classes/class.ilPaymentTrustees.php';
240 include_once
'./Services/Payment/classes/class.ilPaymentVendors.php';
246 $vendors[] = $a_user_id;
254 $data_types = array();
255 $data_values = array();
256 $cnt_vendors = count($vendors);
258 $query =
'SELECT * FROM payment_objects WHERE vendor_id IN';
260 if (is_array($vendors) &&
267 array_push($data_values, $vendor);
268 array_push($data_types,
'integer');
270 if($counter > 0)
$in .=
',';
278 $res= $ilDB->queryf(
$query, $data_types, $data_values);
281 while(
$row = $ilDB->fetchObject(
$res))
283 $objects[
$row->pobject_id][
'pobject_id'] =
$row->pobject_id;
284 $objects[
$row->pobject_id][
'ref_id'] =
$row->ref_id;
285 $objects[
$row->pobject_id][
'status'] =
$row->status;
286 $objects[
$row->pobject_id][
'pay_method'] =
$row->pay_method;
287 $objects[
$row->pobject_id][
'vendor_id'] =
$row->vendor_id;
288 $objects[
$row->pobject_id][
'topic_id'] =
$row->pt_topic_fk;
289 $objects[
$row->pobject_id][
'vat_id'] =
$row->vat_id;
291 return $objects ? $objects : array();
298 $data_types = array();
299 $data_values = array();
301 $query =
'SELECT * FROM payment_objects ';
303 if (
$_SESSION[
'pay_objects'][
'title_value'] !=
'')
305 $query .=
', object_reference obr, object_data od ';
308 if (
$_SESSION[
'pay_objects'][
'vendor'] !=
'')
310 $query .=
', usr_data ud ';
313 $query .=
' WHERE 1 = 1 ';
315 if (
$_SESSION[
'pay_objects'][
'title_value'])
317 $query .=
' AND obr.ref_id = payment_objects.ref_id AND od.obj_id = obr.obj_id ';
321 $title_search = explode(
' ', trim(
$_SESSION[
'pay_objects'][
'title_value']));
322 for ($i = 0; $i < count($title_search); $i++)
324 $title_search[$i] = trim($title_search[$i]);
326 if ($title_search[$i] !=
'')
329 $search_string .=
' od.title LIKE %s ';
330 array_push($data_types,
'text');
331 array_push($data_values,
'%'.$title_search[$i].
'%');
333 switch (
$_SESSION[
'pay_objects'][
'title_type'])
336 if ($i < count($title_search) - 1)
338 $search_string .=
' OR ';
342 if ($i < count($title_search) - 1)
344 $search_string .=
' AND ';
351 if ($search_string !=
'')
353 $query .=
' AND (' . $search_string .
') ';
357 if (
$_SESSION[
'pay_objects'][
'vendor'] !=
'')
359 $query .=
' AND ud.usr_id = payment_objects.vendor_id AND login = %s';
360 array_push($data_types,
'text');
361 array_push($data_values,
$_SESSION[
'pay_objects'][
'vendor']);
364 if(
$_SESSION[
'pay_objects'][
'pay_method'] > 0)
366 $query .=
' AND pay_method = %s';
367 array_push($data_types,
'integer');
368 array_push($data_values,
$_SESSION[
'pay_objects'][
'pay_method']);
371 $res = $ilDB->queryf(
$query, $data_types, $data_values);
373 while(
$row = $ilDB->fetchObject(
$res))
375 $objects[
$row->pobject_id][
'pobject_id'] =
$row->pobject_id;
376 $objects[
$row->pobject_id][
'ref_id'] =
$row->ref_id;
377 $objects[
$row->pobject_id][
'status'] =
$row->status;
378 $objects[
$row->pobject_id][
'pay_method'] =
$row->pay_method;
379 $objects[
$row->pobject_id][
'vendor_id'] =
$row->vendor_id;
380 $objects[
$row->pobject_id][
'topic_id'] =
$row->pt_topic_fk;
381 $objects[
$row->pobject_id][
'vat_id'] =
$row->vat_id;
383 return $objects ? $objects : array();
390 $res = $ilDB->queryf(
'
391 SELECT * FROM payment_objects
392 WHERE pobject_id = %s',
393 array(
'integer'), array($a_id));
397 return $ilDB->fetchAssoc(
$res);
404 function _isPurchasable($a_ref_id, $a_vendor_id = 0, $a_check_trustee =
false, $a_check_status =
false)
411 $data_types = array();
414 $query =
'SELECT * FROM payment_objects WHERE ref_id = %s ';
415 $data_types[] =
'integer';
421 $query .=
'AND status > %s ';
422 $data_types[] =
'integer';
426 if ($a_vendor_id > 0)
428 $query .=
'AND vendor_id = %s';
429 $data_types[] =
'integer';
430 $data[] = $a_vendor_id;
434 include_once
'./Services/Payment/classes/class.ilPaymentTrustees.php';
435 include_once
'./Services/Payment/classes/class.ilPaymentVendors.php';
440 $vendors[] = $a_user_id;
443 if(is_array($vendors) && count($vendors))
445 $query .=
' OR '.$ilDB->in(
'vendor_id', $vendors,
false,
'integer');
451 $rows = $ilDB->numRows(
$res);
453 return $rows ?
true :
false;
460 include_once
'./Services/Payment/classes/class.ilPaymentBookings.php';
461 include_once
'./Services/Payment/classes/class.ilPaymentTrustees.php';
462 include_once
'./Services/Payment/classes/class.ilPaymentVendors.php';
464 global $rbacsystem,
$ilDB, $ilUser;
467 if($rbacsystem->checkAccess(
'write', $a_ref_id))
474 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
480 $result = $ilDB->queryf(
'
481 SELECT * FROM payment_objects
483 AND (status = %s OR status = %s)
484 OR (vendor_id = %s)',
485 array(
'integer',
'integer',
'integer',
'integer'),
486 array($a_ref_id,
'1',
'2',$ilUser->getId()));
487 while(
$row = $ilDB->fetchObject($result))
489 if(
$row->vendor_id == $ilUser->getId() || in_array(
$row->vendor_id, $vendors_of_trustee))
505 include_once
'./Services/Payment/classes/class.ilPaymentBookings.php';
507 global $rbacsystem,
$ilDB;
509 $res = $ilDB->queryf(
'
510 SELECT * FROM payment_objects
512 AND (status = %s OR status = %s)',
513 array(
'integer',
'integer',
'integer'),
514 array($a_ref_id,
'1',
'2'));
524 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
530 $result = $ilDB->queryf(
'
531 SELECT * FROM payment_objects
532 WHERE ref_id = %s AND (status = %s or status = %s)',
533 array(
'integer',
'integer',
'integer'),
534 array($a_ref_id,
'1',
'2'));
536 while(
$row = $ilDB->fetchObject($result))
548 $res = $ilDB->queryF(
'SELECT * FROM payment_objects WHERE ref_id = %s',
549 array(
'integer'), array($a_ref_id));
551 $rows = $ilDB->numRows(
$res);
553 return $rows ?
false :
true;
563 global
$ilDB, $ilUser;
565 if(ANONYMOUS_USER_ID == $ilUser->getId())
567 $result = $ilDB->queryf(
'
568 SELECT psc_id FROM payment_objects po, payment_shopping_cart psc
571 AND po.pobject_id = psc.pobject_id',
572 array(
'integer',
'text'),
573 array($a_ref_id, session_id()));
577 $result = $ilDB->queryf(
'
578 SELECT psc_id FROM payment_objects po, payment_shopping_cart psc
581 AND po.pobject_id = psc.pobject_id',
582 array(
'integer',
'integer'),
583 array($a_ref_id, $ilUser->getId()));
585 while(
$row = $ilDB->fetchObject($result))
597 $result = $this->db->queryf(
'SELECT * FROM payment_objects WHERE pobject_id = %s',
600 while(
$row = $this->db->fetchObject($result))