47
47
public function __construct( $args,$request_remainder, $get = null,$post = null) {
48
48
parent::__construct( $args,$request_remainder,$get,$post);
49
49
$this->button_templates = array(
50
'button_save'=> 'button_save_only.html',
51
'button_save_only'=> 'button_save_only.html',
52
'button_save_return'=>'button_save_only.html',
53
'button_confirm'=> 'button_save_only.html' ,
54
'button_return_only'=> 'button_save_only.html'
50
'button_save'=> 'button_save_export.html',
51
'button_save_only'=> 'button_save_export.html',
52
'button_save_return'=>'button_save_export.html',
53
'button_confirm'=> 'button_save_export.html' ,
54
'button_return_only'=> 'button_save_export.html'
57
57
protected function loadObjects() {
132
132
protected function loadHTMLTemplatesBulk() {
133
133
$this->template->addHeaderLink('mootools-core.js');
135
return $this->loadBulk(true);
135
if ($this->request_exists( 'submit_type' ) && $this->request('submit_type') == "export") {
138
return $this->loadBulk($output);
140
143
*get all the establishments for the specified period and get all the posts.
141
144
* make sure that is an establishment period for each post
143
protected function loadBulk($do_templates) {
146
protected function loadBulk($output = false) {
147
if ($output == 'html') {
145
148
$this->template->addFile( "bulk_establishment_base.html" );
146
149
$append_node = $this->template->getElementByID('establishments');
147
150
if (!$append_node) {
153
156
I2CE::raiseError("Could not get line");
159
} else if ($output == 'csv') {
162
while (ob_get_level() > 0) {
163
$errors .= ob_get_contents();
167
I2CE::raiseError("Got errors:\n$errors");
169
$filename = $this->establishment_period->getField('establishment_type')->getDisplayValue() . ' ' . $this->establishment_period->getField('year')->getDisplayValue();
170
header("Content-disposition: attachment; filename=\"$filename\"");
171
if (preg_match('/\s+MSIE\s+\d\.\d;/',$_SERVER['HTTP_USER_AGENT'])) {
172
header("Content-type: application/vnd.ms-excel");
174
header("Content-type: text/csv; charset=UTF-8");
176
flush(); // Flush the headers so the download box appears fast
179
'No. of Posts Requested',
182
'Geographic Location',
183
'Brief Justification',
187
foreach ($line as &$l) {
188
$l = '"' . addslashes($l) . '"';
191
I2CE::raiseError(implode(",",$line));
192
echo implode(",",$line) . "\n"; flush();
157
194
$no_hidden = array(
158
195
'operator'=>'OR',
241
282
$estObj->populate();
242
283
$estObj->load( $this->post,false,false);
245
$e_node = $node->cloneNode(true);
246
$append_node->appendChild($e_node);
247
$this->template->setForm($estObj,$e_node);
286
if ($output == 'html') {
287
$e_node = $node->cloneNode(true);
288
$append_node->appendChild($e_node);
289
$this->template->setForm($estObj,$e_node);
248
291
if (!array_key_exists($post_id,$posts)) {
249
292
$postObj = $ff->createContainer(array('post', $post_id));
250
293
if ($postObj instanceof I2CE_Form) {
257
300
if ($postObj instanceof I2CE_Form) {
259
$this->template->setForm($postObj,$e_node);
302
if ($output == 'html') {
303
$this->template->setForm($postObj,$e_node);
260
305
if ( ($sgsFields =$postObj->getField('salary_grade')) instanceof I2CE_FormField_MAP_MULT) {
261
306
$grades = $sgsFields->getValue();
262
307
$grade = 'salary_grade|' . $grades[1];
329
373
if ($sgObj instanceof iHRIS_SalaryGrade) {
330
374
$sal = $sgObj->getField('start');
331
375
if ($sal instanceof iHRIS_FormField_Currency) {
332
376
$sval = $sal->getValue();
333
377
if (is_array($sval)) {
334
$val = max(0,$sval[1]);
378
$min_salary = max(0,$sval[1]);
338
$this->template->setDisplayDataImmediate('salary',$val,$e_node);
382
if ($output == 'html') {
383
$this->template->setDisplayDataImmediate('salary',$min_salary,$e_node);
387
if ($output == 'html') {
342
388
$this->setObject($estObj,I2CE_PageForm::EDIT_SECONDARY,$e_node);
389
} else if ($output == 'csv') {
391
if ($postObj instanceof I2CE_Form) {
392
$line[0] = $postObj->getField('name')->getDisplayValue() ;
393
$line[2] = $postObj->getField('salary_grade')->getDisplayValue() ;
394
$line[3] = $postObj->getField('post_group')->getDisplayValue() ;
400
if ($estObj instanceof I2CE_Form) {
401
$line[1] = $estObj->getField('amount')->getDisplayValue();
402
$line[4] = $estObj->getField('location')->getDisplayValue();
403
$line[5] = $estObj->getField('justification')->getDisplayValue();
404
$line[6] = $estObj->getField('notes')->getDisplayValue();
411
$line[7] = $min_salary;
413
foreach ($line as &$l) {
414
$l = '"' . addslashes($l) . '"';
417
I2CE::raiseError(implode(",",$line));
418
echo implode(",",$line) . "\n"; flush();
344
420
$this->setObject($estObj,I2CE_PageForm::EDIT_SECONDARY);
423
if ($output == 'csv') {
389
472
if ($this->post_exists('redirect')) {
390
473
$redirect = $this->post('redirect');
392
475
$redirect = 'bulkEstablishment?estab_id=' . $this->establishment_period->getNameId() . '&cs_id=' . $this->cs_dept->getNameID();
394
477
$this->setRedirect($redirect );