ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilInvoiceNumberPlaceholdersPropertyGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 include_once 'Services/Form/classes/class.ilFormPropertyGUI.php';
13 
15 {
16 
17  public function __construct()
18  {
20  }
21 
22  public function insert($a_tpl)
23  {
24  global $lng;
25 
26  $subtpl = new ilTemplate("tpl.invoice_number_placeholders.html", false, false, "Services/Payment");
27 
28  $subtpl->setVariable('TXT_USE_PLACEHOLDERS', $lng->txt('placeholders'));
29  $subtpl->setVariable('TXT_PLACEHOLDERS_ADVICE', $lng->txt('inv_number_placeholder_advice'));
30 
31  $subtpl->setVariable('TXT_CURRENT_TIMESTAMP', $lng->txt('current_timestamp'));
32  $subtpl->setVariable('TXT_INSTALLATION_ID', $lng->txt('inst_id'));
33  $subtpl->setVariable('TXT_USER_ID', $lng->txt('user_id'));
34  $subtpl->setVariable('TXT_DAY', $lng->txt('day'));
35  $subtpl->setVariable('TXT_MONTH', $lng->txt('month'));
36  $subtpl->setVariable('TXT_YEAR', $lng->txt('year'));
37  $subtpl->setVariable('TXT_INCREMENTAL_NUMBER', $lng->txt('incremental_number'));
38 
39  $a_tpl->setCurrentBlock("prop_generic");
40  $a_tpl->setVariable("PROP_GENERIC", $subtpl->get());
41  $a_tpl->parseCurrentBlock();
42  }
43 
44  /*
45  * user_id only needed if admin adds selling process for users in administration manually
46  * @param integer a_user_id
47  */
48 
49  public static function _generateInvoiceNumber($a_user_id = 0)
50  {
51  global $ilSetting;
52 
53  if($a_user_id == 0)
54  {
55  global $ilUser;
56  $a_user_id = $ilUser->getId();
57  }
58 
59  $inst_id = $ilSetting->get('inst_id');
60  $cur_time = time();
61 
62  include_once './Services/Payment/classes/class.ilUserDefinedInvoiceNumber.php';
63  $invObj = new ilUserDefinedInvoiceNumber();
64 
65  if($invObj->getUDInvoiceNumberActive() == 1)
66  {
68 
69  $invoice_number = $invObj->getInvoiceNumberText();
70 
71  $invoice_number = str_replace('[CURRENT_TIMESTAMP]', $cur_time, $invoice_number);
72  $invoice_number = str_replace('[INSTALLATION_ID]', $inst_id, $invoice_number);
73  $invoice_number = str_replace('[USER_ID]', $a_user_id, $invoice_number);
74  $invoice_number = str_replace('[DAY]', date('d', $cur_time), $invoice_number);
75  $invoice_number = str_replace('[MONTH]', date('m', $cur_time), $invoice_number);
76  $invoice_number = str_replace('[YEAR]', date('Y', $cur_time), $invoice_number);
77  $invoice_number = str_replace('[INCREMENTAL_NUMBER]', $next_number, $invoice_number);
78  }
79  else
80  {
81  $inst_id_time = $inst_id.'_'.$a_user_id.'_'.substr((string) $cur_time,-3);
82  $invoice_number = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
83  }
84 
85  return $invoice_number;
86  }
87 }
88 
89 ?>