/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Groupaccess::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionUpload() { parent::actionUpload(); $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/'; // folder for uploaded files $file = $folder . basename($_FILES['uploadfile']['name']); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { $row = 0; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row > 0) { $model = Groupmenu::model()->findByPk((int) $data[0]); if ($model === null) { $model = new Groupmenu(); } $model->groupmenuid = (int) $data[0]; $groupaccess = Groupaccess::model()->findbyattributes(array('groupname' => $data[1])); if ($groupaccess !== null) { $model->groupaccessid = $groupaccess->groupaccessid; } $menuaccess = Menuaccess::model()->findbyattributes(array('menuname' => $data[2])); if ($menuaccess !== null) { $model->menuaccessid = $menuaccess->menuaccessid; } $model->isread = (int) $data[3]; $model->iswrite = (int) $data[4]; $model->ispost = (int) $data[5]; $model->isreject = (int) $data[6]; $model->isupload = (int) $data[7]; $model->isdownload = (int) $data[8]; $model->recordstatus = (int) $data[9]; try { if (!$model->save()) { $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]); } } catch (Exception $e) { $this->messages = $this->messages . $e->getMessage(); } } $row++; } } else { $this->messages = $this->messages . ' memory or harddisk full'; } fclose($handle); } else { $this->messages = $this->messages . ' check your directory permission'; } if ($this->messages == '') { $this->messages = 'success'; } echo $this->messages; }
<?php echo $form->error($model, 'useraccessid'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'groupaccessid'); ?> <?php echo $form->hiddenField($model, 'groupaccessid'); ?> <input type="text" name="groupname" id="groupname" readonly > <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'groupaccess_dialog', 'options' => array('title' => Yii::t('app', 'Group Access'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true))); $groupaccess = new Groupaccess('searchwstatus'); $groupaccess->unsetAttributes(); // clear any default values if (isset($_GET['Groupaccess'])) { $groupaccess->attributes = $_GET['Groupaccess']; } $this->widget('zii.widgets.grid.CGridView', array('id' => 'groupaccess-grid', 'dataProvider' => $groupaccess->Search(), 'filter' => $groupaccess, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+", array("name" => "send_absschedule", "id" => "send_absschedule", "onClick" => "$(\\"#groupaccess_dialog\\").dialog(\\"close\\"); $(\\"#groupname\\").val(\\"$data->groupname\\"); $(\\"#Usergroup_groupaccessid\\").val(\\"$data->groupaccessid\\"); "))'), array('name' => 'groupaccessid', 'visible' => false, 'value' => '$data->groupaccessid', 'htmlOptions' => array('width' => '1%')), 'groupname'))); $this->endWidget('zii.widgets.jui.CJuiDialog'); echo CHtml::Button('...', array('onclick' => '$.fn.yiiGridView.update("groupaccess-grid");$("#groupaccess_dialog").dialog("open"); return false;')); ?> <?php echo $form->error($model, 'groupaccessid');
public function actionDownload() { parent::actionDownload(); $pdf = new PDF(); $pdf->title = 'Group Menu List'; $pdf->AddPage('P'); $pdf->setFont('Arial', 'B', 12); // definisi font $pdf->setFont('Arial', 'B', 8); // menuliskan tabel $header = array('No', 'ID', 'Group Name', 'Menu Name', 'Is Read', 'Is Write', 'Is Post', 'Is Reject', 'Is Upload', 'Is Download'); $dataprovider = Groupmenuauth::model()->search(); $dataprovider->pagination = false; $data = $dataprovider->getData(); $cols = $dataprovider->getKeys(); $dataku = array(count($data)); //var_dump($dataku); $w = array(10, 15, 40, 30, 15, 15, 15, 15, 20, 20); $pdf->SetTableHeader(); //Header for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true); } $pdf->Ln(); $pdf->SetTableData(); //Data $fill = false; $i = 0; foreach ($data as $datas) { $i = $i + 1; $pdf->Cell($w[0], 6, $i, 'LR', 0, 'L', $fill); $pdf->Cell($w[1], 6, $datas['groupmenuid'], 'LR', 0, 'L', $fill); $pdf->Cell($w[2], 6, Groupaccess::model()->findbypk($datas['groupaccessid'])->groupname, 'LR', 0, 'L', $fill); $pdf->Cell($w[3], 6, Menuaccess::model()->findbypk($datas['menuaccessid'])->menuname, 'LR', 0, 'L', $fill); if ($datas['isread'] == '1') { $pdf->Cell($w[4], 6, 'V', 'LR', 0, 'C', $fill); } else { $pdf->Cell($w[4], 6, '', 'LR', 0, 'C', $fill); } if ($datas['iswrite'] == '1') { $pdf->Cell($w[5], 6, 'V', 'LR', 0, 'C', $fill); } else { $pdf->Cell($w[5], 6, '', 'LR', 0, 'C', $fill); } if ($datas['ispost'] == '1') { $pdf->Cell($w[6], 6, 'V', 'LR', 0, 'C', $fill); } else { $pdf->Cell($w[6], 6, '', 'LR', 0, 'C', $fill); } if ($datas['isreject'] == '1') { $pdf->Cell($w[7], 6, 'V', 'LR', 0, 'C', $fill); } else { $pdf->Cell($w[8], 6, '', 'LR', 0, 'C', $fill); } if ($datas['isupload'] == '1') { $pdf->Cell($w[8], 6, 'V', 'LR', 0, 'C', $fill); } else { $pdf->Cell($w[8], 6, '', 'LR', 0, 'C', $fill); } if ($datas['isdownload'] == '1') { $pdf->Cell($w[9], 6, 'V', 'LR', 0, 'C', $fill); } else { $pdf->Cell($w[9], 6, '', 'LR', 0, 'C', $fill); } $pdf->Ln(); $fill = !$fill; } $pdf->Cell(array_sum($w), 0, '', 'T'); // me-render ke browser $pdf->Output('groupmenu.pdf', 'D'); }