PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/magehelp/application/helpers/table_helper.php

https://bitbucket.org/jit_bec/shopifine
PHP | 344 lines | 260 code | 53 blank | 31 comment | 5 complexity | af62ac606ce9e1767ba7dc10cdb42f73 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /*
  3. Gets the html table to manage people.
  4. */
  5. function get_people_manage_table($people,$controller)
  6. {
  7. $CI =& get_instance();
  8. $table='<table class="tablesorter" id="sortable_table">';
  9. $headers = array('<input type="checkbox" id="select_all" />',
  10. $CI->lang->line('common_last_name'),
  11. $CI->lang->line('common_first_name'),
  12. $CI->lang->line('common_email'),
  13. $CI->lang->line('common_phone_number'),
  14. '&nbsp');
  15. $table.='<thead><tr>';
  16. foreach($headers as $header)
  17. {
  18. $table.="<th>$header</th>";
  19. }
  20. $table.='</tr></thead><tbody>';
  21. $table.=get_people_manage_table_data_rows($people,$controller);
  22. $table.='</tbody></table>';
  23. return $table;
  24. }
  25. /*
  26. Gets the html data rows for the people.
  27. */
  28. function get_people_manage_table_data_rows($people,$controller)
  29. {
  30. $CI =& get_instance();
  31. $table_data_rows='';
  32. foreach($people->result() as $person)
  33. {
  34. $table_data_rows.=get_person_data_row($person,$controller);
  35. }
  36. if($people->num_rows()==0)
  37. {
  38. $table_data_rows.="<tr><td colspan='6'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('common_no_persons_to_display')."</div></tr></tr>";
  39. }
  40. return $table_data_rows;
  41. }
  42. function get_person_data_row($person,$controller)
  43. {
  44. $CI =& get_instance();
  45. $controller_name=strtolower(get_class($CI));
  46. $width = $controller->get_form_width();
  47. $table_data_row='<tr>';
  48. $table_data_row.="<td width='5%'><input type='checkbox' id='person_$person->person_id' value='".$person->person_id."'/></td>";
  49. $table_data_row.='<td width="20%">'.character_limiter($person->last_name,13).'</td>';
  50. $table_data_row.='<td width="20%">'.character_limiter($person->first_name,13).'</td>';
  51. $table_data_row.='<td width="30%">'.mailto($person->email,character_limiter($person->email,22)).'</td>';
  52. $table_data_row.='<td width="20%">'.character_limiter($person->phone_number,13).'</td>';
  53. $table_data_row.='<td width="5%">'.anchor($controller_name."/view/$person->person_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
  54. $table_data_row.='</tr>';
  55. return $table_data_row;
  56. }
  57. /*
  58. Gets the html table to manage suppliers.
  59. */
  60. function get_supplier_manage_table($suppliers,$controller)
  61. {
  62. $CI =& get_instance();
  63. $table='<table class="tablesorter" id="sortable_table">';
  64. $headers = array('<input type="checkbox" id="select_all" />',
  65. $CI->lang->line('suppliers_company_name'),
  66. $CI->lang->line('common_last_name'),
  67. $CI->lang->line('common_first_name'),
  68. $CI->lang->line('common_email'),
  69. $CI->lang->line('common_phone_number'),
  70. '&nbsp');
  71. $table.='<thead><tr>';
  72. foreach($headers as $header)
  73. {
  74. $table.="<th>$header</th>";
  75. }
  76. $table.='</tr></thead><tbody>';
  77. $table.=get_supplier_manage_table_data_rows($suppliers,$controller);
  78. $table.='</tbody></table>';
  79. return $table;
  80. }
  81. /*
  82. Gets the html data rows for the supplier.
  83. */
  84. function get_supplier_manage_table_data_rows($suppliers,$controller)
  85. {
  86. $CI =& get_instance();
  87. $table_data_rows='';
  88. foreach($suppliers->result() as $supplier)
  89. {
  90. $table_data_rows.=get_supplier_data_row($supplier,$controller);
  91. }
  92. if($suppliers->num_rows()==0)
  93. {
  94. $table_data_rows.="<tr><td colspan='7'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('common_no_persons_to_display')."</div></tr></tr>";
  95. }
  96. return $table_data_rows;
  97. }
  98. function get_supplier_data_row($supplier,$controller)
  99. {
  100. $CI =& get_instance();
  101. $controller_name=strtolower(get_class($CI));
  102. $width = $controller->get_form_width();
  103. $table_data_row='<tr>';
  104. $table_data_row.="<td width='5%'><input type='checkbox' id='person_$supplier->person_id' value='".$supplier->person_id."'/></td>";
  105. $table_data_row.='<td width="17%">'.character_limiter($supplier->company_name,13).'</td>';
  106. $table_data_row.='<td width="17%">'.character_limiter($supplier->last_name,13).'</td>';
  107. $table_data_row.='<td width="17%">'.character_limiter($supplier->first_name,13).'</td>';
  108. $table_data_row.='<td width="22%">'.mailto($supplier->email,character_limiter($supplier->email,22)).'</td>';
  109. $table_data_row.='<td width="17%">'.character_limiter($supplier->phone_number,13).'</td>';
  110. $table_data_row.='<td width="5%">'.anchor($controller_name."/view/$supplier->person_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
  111. $table_data_row.='</tr>';
  112. return $table_data_row;
  113. }
  114. /*
  115. Gets the html table to manage items.
  116. */
  117. function get_items_manage_table($items,$controller)
  118. {
  119. $CI =& get_instance();
  120. $table='<table class="tablesorter" id="sortable_table">';
  121. $headers = array('<input type="checkbox" id="select_all" />',
  122. $CI->lang->line('items_item_number'),
  123. $CI->lang->line('items_name'),
  124. $CI->lang->line('items_category'),
  125. $CI->lang->line('items_cost_price'),
  126. $CI->lang->line('items_unit_price'),
  127. $CI->lang->line('items_tax_percents'),
  128. $CI->lang->line('items_quantity'),
  129. '&nbsp;',
  130. $CI->lang->line('items_inventory')
  131. );
  132. $table.='<thead><tr>';
  133. foreach($headers as $header)
  134. {
  135. $table.="<th>$header</th>";
  136. }
  137. $table.='</tr></thead><tbody>';
  138. $table.=get_items_manage_table_data_rows($items,$controller);
  139. $table.='</tbody></table>';
  140. return $table;
  141. }
  142. /*
  143. Gets the html data rows for the items.
  144. */
  145. function get_items_manage_table_data_rows($items,$controller)
  146. {
  147. $CI =& get_instance();
  148. $table_data_rows='';
  149. foreach($items->result() as $item)
  150. {
  151. $table_data_rows.=get_item_data_row($item,$controller);
  152. }
  153. if($items->num_rows()==0)
  154. {
  155. $table_data_rows.="<tr><td colspan='11'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('items_no_items_to_display')."</div></tr></tr>";
  156. }
  157. return $table_data_rows;
  158. }
  159. function get_item_data_row($item,$controller)
  160. {
  161. $CI =& get_instance();
  162. $item_tax_info=$CI->Item_taxes->get_info($item->item_id);
  163. $tax_percents = '';
  164. foreach($item_tax_info as $tax_info)
  165. {
  166. $tax_percents.=$tax_info['percent']. '%, ';
  167. }
  168. $tax_percents=substr($tax_percents, 0, -2);
  169. $controller_name=strtolower(get_class($CI));
  170. $width = $controller->get_form_width();
  171. $table_data_row='<tr>';
  172. $table_data_row.="<td width='3%'><input type='checkbox' id='item_$item->item_id' value='".$item->item_id."'/></td>";
  173. $table_data_row.='<td width="15%">'.$item->item_number.'</td>';
  174. $table_data_row.='<td width="20%">'.$item->name.'</td>';
  175. $table_data_row.='<td width="14%">'.$item->category.'</td>';
  176. $table_data_row.='<td width="14%">'.to_currency($item->cost_price).'</td>';
  177. $table_data_row.='<td width="14%">'.to_currency($item->unit_price).'</td>';
  178. $table_data_row.='<td width="14%">'.$tax_percents.'</td>';
  179. $table_data_row.='<td width="14%">'.$item->quantity.'</td>';
  180. $table_data_row.='<td width="5%">'.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
  181. //Ramel Inventory Tracking
  182. $table_data_row.='<td width="10%">'.anchor($controller_name."/inventory/$item->item_id/width:$width", $CI->lang->line('common_inv'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_count')))./*'</td>';//inventory count
  183. $table_data_row.='<td width="5%">'*/'&nbsp;&nbsp;&nbsp;&nbsp;'.anchor($controller_name."/count_details/$item->item_id/width:$width", $CI->lang->line('common_det'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_details_count'))).'</td>';//inventory details
  184. $table_data_row.='</tr>';
  185. return $table_data_row;
  186. }
  187. /*
  188. Gets the html table to manage giftcards.
  189. */
  190. function get_giftcards_manage_table( $giftcards, $controller )
  191. {
  192. $CI =& get_instance();
  193. $table='<table class="tablesorter" id="sortable_table">';
  194. $headers = array('<input type="checkbox" id="select_all" />',
  195. $CI->lang->line('giftcards_giftcard_number'),
  196. $CI->lang->line('giftcards_card_value'),
  197. '&nbsp',
  198. );
  199. $table.='<thead><tr>';
  200. foreach($headers as $header)
  201. {
  202. $table.="<th>$header</th>";
  203. }
  204. $table.='</tr></thead><tbody>';
  205. $table.=get_giftcards_manage_table_data_rows( $giftcards, $controller );
  206. $table.='</tbody></table>';
  207. return $table;
  208. }
  209. /*
  210. Gets the html data rows for the giftcard.
  211. */
  212. function get_giftcards_manage_table_data_rows( $giftcards, $controller )
  213. {
  214. $CI =& get_instance();
  215. $table_data_rows='';
  216. foreach($giftcards->result() as $giftcard)
  217. {
  218. $table_data_rows.=get_giftcard_data_row( $giftcard, $controller );
  219. }
  220. if($giftcards->num_rows()==0)
  221. {
  222. $table_data_rows.="<tr><td colspan='11'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('giftcards_no_giftcards_to_display')."</div></tr></tr>";
  223. }
  224. return $table_data_rows;
  225. }
  226. function get_giftcard_data_row($giftcard,$controller)
  227. {
  228. $CI =& get_instance();
  229. $controller_name=strtolower(get_class($CI));
  230. $width = $controller->get_form_width();
  231. $table_data_row='<tr>';
  232. $table_data_row.="<td width='3%'><input type='checkbox' id='giftcard_$giftcard->giftcard_id' value='".$giftcard->giftcard_id."'/></td>";
  233. $table_data_row.='<td width="15%">'.$giftcard->giftcard_number.'</td>';
  234. $table_data_row.='<td width="20%">'.to_currency($giftcard->value).'</td>';
  235. $table_data_row.='<td width="5%">'.anchor($controller_name."/view/$giftcard->giftcard_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
  236. $table_data_row.='</tr>';
  237. return $table_data_row;
  238. }
  239. /*
  240. Gets the html table to manage item kits.
  241. */
  242. function get_item_kits_manage_table( $item_kits, $controller )
  243. {
  244. $CI =& get_instance();
  245. $table='<table class="tablesorter" id="sortable_table">';
  246. $headers = array('<input type="checkbox" id="select_all" />',
  247. $CI->lang->line('item_kits_name'),
  248. $CI->lang->line('item_kits_description'),
  249. '&nbsp',
  250. );
  251. $table.='<thead><tr>';
  252. foreach($headers as $header)
  253. {
  254. $table.="<th>$header</th>";
  255. }
  256. $table.='</tr></thead><tbody>';
  257. $table.=get_item_kits_manage_table_data_rows( $item_kits, $controller );
  258. $table.='</tbody></table>';
  259. return $table;
  260. }
  261. /*
  262. Gets the html data rows for the item kits.
  263. */
  264. function get_item_kits_manage_table_data_rows( $item_kits, $controller )
  265. {
  266. $CI =& get_instance();
  267. $table_data_rows='';
  268. foreach($item_kits->result() as $item_kit)
  269. {
  270. $table_data_rows.=get_item_kit_data_row( $item_kit, $controller );
  271. }
  272. if($item_kits->num_rows()==0)
  273. {
  274. $table_data_rows.="<tr><td colspan='11'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('item_kits_no_item_kits_to_display')."</div></tr></tr>";
  275. }
  276. return $table_data_rows;
  277. }
  278. function get_item_kit_data_row($item_kit,$controller)
  279. {
  280. $CI =& get_instance();
  281. $controller_name=strtolower(get_class($CI));
  282. $width = $controller->get_form_width();
  283. $table_data_row='<tr>';
  284. $table_data_row.="<td width='3%'><input type='checkbox' id='item_kit_$item_kit->item_kit_id' value='".$item_kit->item_kit_id."'/></td>";
  285. $table_data_row.='<td width="15%">'.$item_kit->name.'</td>';
  286. $table_data_row.='<td width="20%">'.character_limiter($item_kit->description, 25).'</td>';
  287. $table_data_row.='<td width="5%">'.anchor($controller_name."/view/$item_kit->item_kit_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
  288. $table_data_row.='</tr>';
  289. return $table_data_row;
  290. }
  291. ?>