ILIAS  Release_4_2_x_branch Revision 61807
 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  {
19  global $lng;
21  }
22 
23  public function insert($a_tpl)
24  {
25  global $lng;
26 
27  $subtpl = new ilTemplate("tpl.invoice_number_placeholders.html", false, false, "Services/Payment");
28 
29  $subtpl->setVariable('TXT_USE_PLACEHOLDERS', $lng->txt('placeholders'));
30  $subtpl->setVariable('TXT_PLACEHOLDERS_ADVICE', $lng->txt('inv_number_placeholder_advice'));
31 
32  $subtpl->setVariable('TXT_CURRENT_TIMESTAMP', $lng->txt('current_timestamp'));
33  $subtpl->setVariable('TXT_INSTALLATION_ID', $lng->txt('installation_id'));
34  $subtpl->setVariable('TXT_USER_ID', $lng->txt('user_id'));
35  $subtpl->setVariable('TXT_DAY', $lng->txt('day'));
36  $subtpl->setVariable('TXT_MONTH', $lng->txt('month'));
37  $subtpl->setVariable('TXT_YEAR', $lng->txt('year'));
38  $subtpl->setVariable('TXT_INCREMENTAL_NUMBER', $lng->txt('incremental_number'));
39 
40  $a_tpl->setCurrentBlock("prop_generic");
41  $a_tpl->setVariable("PROP_GENERIC", $subtpl->get());
42  $a_tpl->parseCurrentBlock();
43  }
44 
45  /*
46  * user_id only needed if admin adds selling process for users in administration manually
47  * @param integer a_user_id
48  */
49 
50  public static function _generateInvoiceNumber($a_user_id = 0)
51  {
52  global $lng, $ilSetting;
53 
54  if($a_user_id == 0)
55  {
56  global $ilUser;
57  $a_user_id = $ilUser->getId();
58  }
59 
60  $inst_id = $ilSetting->get('inst_id');
61  $cur_time = time();
62 
63  include_once './Services/Payment/classes/class.ilUserDefinedInvoiceNumber.php';
64  $invObj = new ilUserDefinedInvoiceNumber();
65 
66  if($invObj->getUDInvoiceNumberActive() == 1)
67  {
69 
70  $invoice_number = $invObj->getInvoiceNumberText();
71 
72  $invoice_number = str_replace('[CURRENT_TIMESTAMP]', $cur_time, $invoice_number);
73  $invoice_number = str_replace('[INSTALLATION_ID]', $inst_id, $invoice_number);
74  $invoice_number = str_replace('[USER_ID]', $a_user_id, $invoice_number);
75  $invoice_number = str_replace('[DAY]', date('d', $cur_time), $invoice_number);
76  $invoice_number = str_replace('[MONTH]', date('m', $cur_time), $invoice_number);
77  $invoice_number = str_replace('[YEAR]', date('Y', $cur_time), $invoice_number);
78  $invoice_number = str_replace('[INCREMENTAL_NUMBER]', $next_number, $invoice_number);
79  }
80  else
81  {
82  $inst_id_time = $inst_id.'_'.$a_user_id.'_'.substr((string) $cur_time,-3);
83  $invoice_number = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
84  }
85 
86  return $invoice_number;
87  }
88 }
89 
90 ?>