PageRenderTime 26ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/module/Supply/src/Supply/Form/SupplyForm.php

https://gitlab.com/mnomansheikh/ampuz
PHP | 363 lines | 324 code | 24 blank | 15 comment | 2 complexity | 0992805e2e8461cb5374cba1c39616a8 MD5 | raw file
  1. <?php
  2. namespace Supply\Form;
  3. use Zend\Form\Form;
  4. use zend\Db\Adapter\AdapterInterface;
  5. use zend\Db\ResultSet\ResultSet;
  6. class SupplyForm extends Form
  7. {
  8. // protected $dbAdapter;
  9. public function __construct($Companies = null,$Regions=null,$Countries= null,$Indicators=null,$Frequencies = null,$DateField=null)
  10. {
  11. // we want to ignore the name passed
  12. parent::__construct('supply');
  13. //$this->setAttribute("method", "post");
  14. /*supply detail form */
  15. $this->add(array(
  16. 'name' => 'employee_id',
  17. 'type' => 'Hidden',
  18. ));
  19. $this->add(array(
  20. 'name' => 'employee_name',
  21. 'type' => 'Hidden',
  22. ));
  23. $this->add(array(
  24. 'name' => 'travel_from',
  25. 'type' => 'Hidden',
  26. ));
  27. $this->add(array(
  28. 'name' => 'travel_to',
  29. 'type' => 'Hidden',
  30. ));
  31. $this->add(array(
  32. 'name' => 'travel_date',
  33. 'type' => 'Hidden',
  34. ));
  35. $this->add(array(
  36. 'name' => 'travel_distance',
  37. 'type' => 'Hidden',
  38. ));
  39. $this->add(array(
  40. 'name' => 'dob',
  41. 'type' => 'Hidden',
  42. ));
  43. $this->add(array(
  44. 'name' => 'nationality',
  45. 'type' => 'Hidden',
  46. ));
  47. $this->add(array(
  48. 'name' => 'gender',
  49. 'type' => 'Hidden',
  50. ));
  51. $this->add(array(
  52. 'name' => 'designation',
  53. 'type' => 'Hidden',
  54. ));
  55. $this->add(array(
  56. 'name' => 'date',
  57. 'type' => 'Hidden',
  58. ));
  59. $this->add(array(
  60. 'name' => 'file_name',
  61. 'type' => 'Hidden',
  62. ));
  63. $this->add(array(
  64. 'name' => 'org_name',
  65. 'type' => 'Hidden',
  66. ));
  67. /*supply detail form */
  68. $this->add(array(
  69. 'name' => 'supply_id',
  70. 'type' => 'Hidden',
  71. ));
  72. $this->add(array(
  73. 'name' => 'bulk_type',
  74. 'type' => 'Hidden',
  75. ));
  76. $this->add(array(
  77. 'name' => 'indicator_type',
  78. 'type' => 'Hidden',
  79. ));
  80. $this->add(array(
  81. 'name' => 'category',
  82. 'type' => 'text',
  83. 'attributes' => array(
  84. 'value' => 'environment'
  85. )
  86. ));
  87. $this->add(array(
  88. 'name' => 'area',
  89. 'type' => 'text',
  90. 'attributes' => array(
  91. 'value' => 'supply'
  92. )
  93. ));
  94. $this->add(array(
  95. 'type' => 'Zend\Form\Element\Select',
  96. 'name' => 'company_id',
  97. 'options' => array(
  98. 'label' => 'Company',
  99. //'value_options' => $this->getOptionsForSelect(),
  100. 'value_options' => $Companies,
  101. ),
  102. 'attributes' => array(
  103. // 'value' => '1', //set selected to '1'
  104. 'class' => 'form-control',
  105. 'id' => 'company_form_id',
  106. )
  107. ));
  108. $this->add(array(
  109. 'type' => 'Zend\Form\Element\Select',
  110. 'name' => 'region_id',
  111. 'options' => array(
  112. 'label' => 'Country',
  113. //'value_options' => $this->getOptionsForSelect(),
  114. 'value_options' => $Regions,
  115. ),
  116. 'attributes' => array(
  117. // 'value' => '1', //set selected to '1'
  118. 'class' => 'form-control',
  119. 'id' => 'region_form_id',
  120. )
  121. ));
  122. $this->add(array(
  123. 'type' => 'Zend\Form\Element\Select',
  124. 'name' => 'country_id',
  125. 'options' => array(
  126. 'label' => 'Country',
  127. //'value_options' => $this->getOptionsForSelect(),
  128. 'value_options' => $Countries,
  129. ),
  130. 'attributes' => array(
  131. // 'value' => '1', //set selected to '1'
  132. 'class' => 'form-control',
  133. 'id' => 'country_form_id',
  134. )
  135. ));
  136. $this->add(array(
  137. 'type' => 'Zend\Form\Element\Select',
  138. 'name' => 'frequency_ids',
  139. 'options' => array(
  140. 'label' => 'Frequency',
  141. //'value_options' => $this->getOptionsForSelect(),
  142. 'value_options' => $Frequencies,
  143. ),
  144. 'attributes' => array(
  145. // 'value' => '1', //set selected to '1'
  146. 'class' => 'form-control',
  147. 'id' => 'frequency_form_ids',
  148. )
  149. ));
  150. $this->add(array(
  151. 'name' => 'frequency_name',
  152. 'type' => 'text',
  153. 'attributes' => array(
  154. 'readonly' => 'readonly',
  155. 'class' => 'form-control',
  156. 'id' => 'frequency_form_name',
  157. )
  158. ));
  159. $this->add(array(
  160. 'name' => 'frequency_id',
  161. 'type' => 'Hidden',
  162. 'attributes' => array(
  163. 'id' => 'frequency_form_id',
  164. )
  165. ));
  166. if($DateField != null){
  167. $this->add(
  168. $DateField
  169. );
  170. }
  171. $this->add(array(
  172. 'name' => 'month',
  173. 'type' => 'Hidden',
  174. 'attributes' => array(
  175. 'id' => 'month',
  176. )
  177. ));
  178. $this->add(array(
  179. 'name' => 'year',
  180. 'type' => 'Hidden',
  181. 'attributes' => array(
  182. 'id' => 'year',
  183. )
  184. ));
  185. $this->add(array(
  186. 'name' => 'col',
  187. 'type' => 'Hidden',
  188. 'attributes' => array(
  189. 'id' => 'col',
  190. ),
  191. ));
  192. $this->add(array(
  193. 'name' => 'col1',
  194. 'type' => 'Hidden',
  195. 'attributes' => array(
  196. 'id' => 'col1',
  197. ),
  198. ));
  199. $this->add(array(
  200. 'name' => 'col2',
  201. 'type' => 'Hidden',
  202. 'attributes' => array(
  203. 'id' => 'col2',
  204. ),
  205. ));
  206. $this->add(array(
  207. 'name' => 'col3',
  208. 'type' => 'Hidden',
  209. 'attributes' => array(
  210. 'id' => 'col3',
  211. ),
  212. ));
  213. $this->add(array(
  214. 'name' => 'col4',
  215. 'type' => 'Hidden',
  216. 'attributes' => array(
  217. 'id' => 'col4',
  218. ),
  219. ));
  220. $this->add(array(
  221. 'name' => 'col5',
  222. 'type' => 'Hidden',
  223. 'attributes' => array(
  224. 'id' => 'col5',
  225. ),
  226. ));
  227. $this->add(array(
  228. 'name' => 'col6',
  229. 'type' => 'Hidden',
  230. 'attributes' => array(
  231. 'id' => 'col6',
  232. ),
  233. ));
  234. $this->add(array(
  235. 'name' => 'col7',
  236. 'type' => 'Hidden',
  237. 'attributes' => array(
  238. 'id' => 'col7',
  239. ),
  240. ));
  241. $this->add(array(
  242. 'name' => 'col8',
  243. 'type' => 'Hidden',
  244. 'attributes' => array(
  245. 'id' => 'col8',
  246. ),
  247. ));
  248. $this->add(array(
  249. 'name' => 'col9',
  250. 'type' => 'Hidden',
  251. 'attributes' => array(
  252. 'id' => 'col9',
  253. ),
  254. ));
  255. $this->add(array(
  256. 'name' => 'col10',
  257. 'type' => 'Hidden',
  258. 'attributes' => array(
  259. 'id' => 'col10',
  260. ),
  261. ));
  262. $this->add(array(
  263. 'type' => 'Zend\Form\Element\Select',
  264. 'name' => 'type',
  265. 'options' => array(
  266. 'label' => 'Type',
  267. //'value_options' => $this->getOptionsForSelect(),
  268. 'value_options' => $Indicators,
  269. ),
  270. 'attributes' => array(
  271. /* 'value' => '1', //set selected to '1'*/
  272. 'required' => 'required',
  273. 'class' => 'form-control',
  274. 'id' => 'indicator_form_id',
  275. )
  276. ));
  277. $this->add(array(
  278. 'name' => 'value',
  279. 'attributes' => array(
  280. 'class' => 'form-control',
  281. 'required' => 'required',
  282. 'id' => 'value',
  283. ),
  284. ));
  285. $this->add(array(
  286. 'name' => 'submit',
  287. 'type' => 'Submit',
  288. 'attributes' => array(
  289. 'value' => 'Go',
  290. 'id' => 'submitbutton',
  291. 'class' => 'btn8 btn-8f btn-8 pull-right',
  292. ),
  293. ));
  294. $this->add(array(
  295. 'name' => 'cancel',
  296. 'type' => 'button',
  297. 'options'=>array(
  298. 'label'=>'Cancel'
  299. ),
  300. 'attributes' => array(
  301. 'onclick' => 'javascript:window.location.href = "/'._PROJECT_NAME_.'/public/supply";',
  302. 'class' => 'btn8 btn-8 btn-8f pull-right',
  303. ),
  304. ));
  305. $this->add(array(
  306. 'name' => 'upload',
  307. 'type' => 'Submit',
  308. 'attributes' => array(
  309. 'value' => 'File Upload',
  310. 'id' => 'submitbutton1',
  311. 'class' => 'btn btn-primary btn-xs',
  312. ),
  313. ));
  314. $this->setAttribute('method', 'post');
  315. $this->setAttribute('enctype','multipart/form-data');
  316. $this->add(array(
  317. 'name' => 'fileupload',
  318. 'attributes' => array(
  319. 'type' => 'file',
  320. 'required' => 'required',
  321. 'accept' => ".jpg,.jpeg,.png,.pdf"
  322. ),
  323. 'options' => array(
  324. 'label' => '',
  325. 'class' => 'form-control',
  326. ),
  327. ));
  328. $this->add(array(
  329. 'name' => 'fileupload_attachment',
  330. 'attributes' => array(
  331. 'type' => 'file',
  332. ),
  333. 'options' => array(
  334. 'label' => '',
  335. 'class' => 'form-control',
  336. ),
  337. ));
  338. }
  339. }