Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
default_delivery_method_edit_fns.inc
1 <?php
18 require_once SQ_PACKAGES_PATH.'/ecommerce/delivery_methods/ecommerce_delivery_method/ecommerce_delivery_method_edit_fns.inc';
19 
20 
32 {
33 
34 
42  {
43  parent::__construct();
44  }//end constructor
45 
46 
57  function paintAvailableKeywords(&$asset, &$o, $prefix)
58  {
59  $write_access = $asset->writeAccess('attributes');
60 
61  if ($write_access) {
62  $tmp_form =& $asset->getForm();
63  $availableKeywords = $tmp_form->getQuestions();
64 
65  // print the response keyword
66  echo '<style type="text/css">#keyword_table td {border:1px solid #B3B3B3;} #keyword_table {border:1px solid #000}</style>';
67  echo '<table id="keyword_table"><tr><td><strong>Keyword</strong></td><td><strong>Description</strong></td></tr>';
68  foreach ($availableKeywords as $key => $value) {
69  $key_parts = explode(':', $key);
70  echo '<tr><td>%response_'.$key_parts[1].'%</td><td>print field value <strong>"'.$value['name'].'"</strong> </td></tr>';
71  }
72  echo '<tr><td>%customised_receipt%</td><td>print the customised receipt (if enabled via the checkout asset)</td></tr>';
73  echo '<tr><td>%order_receipt%</td><td>print the order receipt</td></tr>';
74  echo '<tr><td>%cart_summary%</td><td>print the cart summary</td></tr>';
75  echo '<tr><td>%cart_summary_text%</td><td>print the cart summary in a text format</td></tr>';
76  echo '<tr><td>%form_summary%</td><td>print the form summary</td></tr>';
77  echo '<tr><td>%form_summary_text%</td><td>print the form summary in a text format</td></tr>';
78  echo '<tr><td>%order_id%</td><td>print the order id</td></tr>';
79  echo '<tr><td>%transaction_id%</td><td>print the unique transaction reference id</td></tr>';
80  echo '<tr><td>%merchant_transaction_id%</td><td>print the unique merchant transaction reference id</td></tr>';
81  echo '<tr><td>%negative_quantity_product_list%</td><td>print products which have negative quantities after purchasing</td></tr>';
82  echo '<tr><td>%negative_quantity_message%</td><td>print negative quantity products message if there are any negative quantities</td></tr>';
83  echo '</table>';
84 
85  }
86 
87  return $write_access;
88 
89  }//end paintAvailableKeywords()
90 
91 
102  function processAvailableKeywords(&$asset, &$o, $prefix)
103  {
104  return TRUE;
105 
106  }//end processAvailableKeywords()
107 
108 
119  function paintPassthroughVarQuestionLinks(&$asset, &$o, $prefix)
120  {
121  $am =& $GLOBALS['SQ_SYSTEM']->am;
122  $write_access = $asset->writeAccess('attributes');
123 
124  $o->openRaw();
125 
126  echo '<table class="sq-backend-table">';
127  echo '<tr>';
128  echo '<th>Question Name</th>';
129  echo '<th>Enabled?</th>';
130  echo '<th>Key</th>';
131  echo '<th>Value Options</th>';
132  echo '</tr>';
133 
134  $form =& $asset->getForm();
135  $all_form_questions = $form->getQuestions();
136  $var_rules = $asset->attr('key_val_rules');
137 
138  foreach ($all_form_questions as $q_id => $question_data) {
139  if (!$asset->_isAllowedPassThroughQuestionType($question_data['type_code'])) {
140  continue;
141  }
142 
143  $var_enabled = isset($var_rules[$q_id]);
144 
145  echo '<tr>';
146  echo '<td>';
147  echo $question_data['name'];
148  echo '</td>';
149  echo '<td>';
150  $var_enabled_name = $prefix.'_var_enabled['.$q_id.']';
151  check_box($var_enabled_name, $q_id, $var_enabled);
152  echo '</td>';
153  echo '<td>';
154  if ($var_enabled) {
155  $pass_through_key_name = $prefix.'_pass_through_key['.$q_id.']';
156  text_box($pass_through_key_name, array_get_index($var_rules[$q_id], 'key', ''));
157  } else {
158  echo '<em style="color: grey;">None</em>';
159  }
160  echo '</td>';
161  echo '<td>';
162  if ($var_enabled) {
163  $question = $am->getAsset($q_id);
164  if (!($question instanceof Form_Question_Type_Country) && $question->isSelection()) {
165  echo '<table class="sq-backend-table">';
166  $options = $question->getOptions();
167  $var_value = array_get_index($var_rules[$q_id], 'value', Array());
168  $local_prefix = $prefix.'_pass_through_value['.$q_id.']';
169  foreach ($options as $key => $option_text) {
170  // if this option is not --leave empty--, print out the rule change table
171  if (!($question instanceof Form_question_type_select) || !$question->isEmptyOption($key)){
172  echo '<tr>';
173  $rule_value = array_get_index($var_value, $key, '');
174  echo '<td class="sq-backend-table-header" nowrap="nowrap">';
175  echo $option_text;
176  echo '</td>';
177  echo '<td class="sq-backend-table-cell" width="100%">';
178  text_box($local_prefix.'['.$key.']', $rule_value);
179  echo '</td>';
180  echo '</tr>';
181  }
182  }
183  echo '</table>';
184  } else {
185  echo 'The value supplied by the user will be passed through to the Payment Gateway.';
186  }
187 
188  $am->forgetAsset($question);
189  } else {
190  echo '<em style="color: grey;">Pass through variable is not enabled for this question</em>';
191  }
192  echo '</td>';
193  echo '</tr>';
194  }//end foreach
195 
196  echo '</table>';
197 
198  $o->closeRaw();
199 
200  return $write_access;
201 
202  }//end paintPassthroughVarQuestionLinks()
203 
204 
215  function processPassthroughVarQuestionLinks(&$asset, &$o, $prefix)
216  {
217  // process the new pass through variable rule list
218  $var_list = array_get_index($_REQUEST, $prefix.'_var_enabled', Array());
219 
220  $new_var_list = Array();
221  if (!empty($var_list)) {
222  $key_list = array_get_index($_REQUEST, $prefix.'_pass_through_key', Array());
223  $value_list = array_get_index($_REQUEST, $prefix.'_pass_through_value', Array());
224  foreach ($var_list as $id) {
225  // add the empty var to the new list
226  $new_var_list[$id] = Array(
227  'key' => array_get_index($key_list, $id, ''),
228  'value' => array_get_index($value_list, $id, Array()));
229  }
230  }
231 
232  $asset->setAttrValue('key_val_rules', $new_var_list);
233 
234  return TRUE;
235 
236  }//end processPassthroughVarQuestionLinks()
237 
238 
239 }//end class
240 
241 ?>