public static function graphMorrisJs() { //self::topJs(); JSFile(themeUrl('js/plugins/morris/raphael-min.js')); JSFile(themeUrl('js/plugins/morris/morris.min.js')); //self::bottomJs(); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { JSFile(themeUrl('js/plugins/smcalendar/smcalendar.js'), CClientScript::POS_HEAD); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['SchedulleForm'])) { $model->attributes = $_POST['SchedulleForm']; $model->save(); if ($model->save()) { $this->redirect(array('update', 'model' => $model)); } } else { // $model->employee_id = 1; $model->year = (int) date('Y'); $model->month = (int) date('m') - 1; } $employees = MastersEmployees::model()->findAllByAttributes(array('department_id' => $model->department_id)); $this->render('update', array('model' => $model, 'employees' => $employees)); }
public function actionIndex() { $delimiter = ";"; $textDelimiter = '"'; //publish css and js JSFile(themeUrl('js/aaa/ajaxupload.js')); JSFile(themeUrl('js/aaa/download.js')); Yii::app()->clientScript->registerScript('uploadActionPath', 'var uploadActionPath="' . $this->createUrl('default/upload') . '"', CClientScript::POS_BEGIN); //getting all tables from db $tables = Yii::app()->getDb()->getSchema()->getTableNames(); $tablesLength = sizeof($tables); $tablesArray = array(); for ($i = 0; $i < $tablesLength; $i++) { $tablesArray[$tables[$i]] = $tables[$i]; } if (Yii::app()->request->isAjaxRequest) { if ($_POST['thirdStep'] != 1) { //second step $delimiter = str_replace('"', '"', str_replace("'", "'", CHtml::encode(trim($_POST['delimiter'])))); $textDelimiter = str_replace('"', '"', str_replace("'", "'", CHtml::encode(trim($_POST['textDelimiter'])))); $table = CHtml::encode($_POST['table']); if ($_POST['delimiter'] == '') { $error = 1; $csvFirstLine = array(); $paramsArray = array(); } else { // get all columns from csv file $error = 0; $uploaddir = Yii::app()->controller->module->path; $uploadfile = $uploaddir . basename($_POST['fileName']); $file = fopen($uploadfile, "r"); $csvFirstLine = $textDelimiter ? fgetcsv($file, 0, $delimiter, $textDelimiter) : fgetcsv($file, 0, $delimiter); fclose($file); // checking file with earlier imports $paramsArray = $this->checkOldFile($uploadfile); } //get all columns from selected table $model = new ImportCsv(); $tableColumns = $model->tableColumns($table); $this->layout = 'clear'; $this->render('secondResult', array('error' => $error, 'tableColumns' => $tableColumns, 'delimiter' => $delimiter, 'textDelimiter' => $textDelimiter, 'table' => $table, 'fromCsv' => $csvFirstLine, 'paramsArray' => $paramsArray)); } else { //third step $delimiter = str_replace('"', '"', str_replace("'", "'", CHtml::encode(trim($_POST['thirdDelimiter'])))); $textDelimiter = str_replace('"', '"', str_replace("'", "'", CHtml::encode(trim($_POST['thirdTextDelimiter'])))); $table = CHtml::encode($_POST['thirdTable']); $uploadfile = CHtml::encode(trim($_POST['thirdFile'])); $columns = $_POST['Columns']; $perRequest = CHtml::encode($_POST['perRequest']); $tableKey = CHtml::encode($_POST['Tablekey']); $csvKey = CHtml::encode($_POST['CSVkey']); $mode = CHtml::encode($_POST['Mode']); $insertArray = array(); $error_array = array(); if (array_sum($_POST['Columns']) > 0) { if ($_POST['perRequest'] != '') { if (is_numeric($_POST['perRequest'])) { if (($mode == 2 || $mode == 3) && ($tableKey == '' || $csvKey == '')) { $error = 4; } else { $error = 0; //import from csv to db $model = new ImportCsv(); $tableColumns = $model->tableColumns($table); //select old rows from table if ($mode == 2 || $mode == 3) { $oldItems = $model->selectRows($table, $tableKey); } $filecontent = file($uploadfile); $lengthFile = sizeof($filecontent); $insertCounter = 0; $stepsOk = 0; // begin transaction $transaction = Yii::app()->db->beginTransaction(); try { // import to database for ($i = 0; $i < $lengthFile; $i++) { if ($i != 0 && $filecontent[$i] != '') { $csvLine = $textDelimiter ? str_getcsv($filecontent[$i], $delimiter, $textDelimiter) : str_getcsv($filecontent[$i], $delimiter); //Mode 1. insert All if ($mode == 1) { $insertArray[] = $csvLine; $insertCounter++; if ($insertCounter == $perRequest || $i == $lengthFile - 1) { $import = $model->InsertAll($table, $insertArray, $columns, $tableColumns); $insertCounter = 0; $insertArray = array(); if ($import != 1) { $arrays[] = $i; } } } // Mode 2. Insert new if ($mode == 2) { if ($csvLine[$csvKey - 1] == '' || !$this->searchInOld($oldItems, $csvLine[$csvKey - 1], $tableKey)) { $insertArray[] = $csvLine; $insertCounter++; if ($insertCounter == $perRequest || $i == $lengthFile - 1) { $import = $model->InsertAll($table, $insertArray, $columns, $tableColumns); $insertCounter = 0; $insertArray = array(); if ($import != 1) { $arrays[] = $i; } } } } // Mode 3. Insert new and replace old if ($mode == 3) { if ($csvLine[$csvKey - 1] == '' || !$this->searchInOld($oldItems, $csvLine[$csvKey - 1], $tableKey)) { // insert new $insertArray[] = $csvLine; $insertCounter++; if ($insertCounter == $perRequest || $i == $lengthFile - 1) { $import = $model->InsertAll($table, $insertArray, $columns, $tableColumns); $insertCounter = 0; $insertArray = array(); if ($import != 1) { $arrays[] = $i; } } } else { //replace old $import = $model->updateOld($table, $csvLine, $columns, $tableColumns, $csvLine[$csvKey - 1], $tableKey); if ($import != 1) { $arrays[] = $i; } } } } } if ($insertCounter != 0) { $model->InsertAll($table, $insertArray, $columns, $tableColumns); } // commit transaction if not exception $transaction->commit(); } catch (Exception $e) { // exception in transaction $transaction->rollBack(); } // save params in file $this->saveInFile($table, $delimiter, $mode, $perRequest, $csvKey, $tableKey, $tableColumns, $columns, $uploadfile, $textDelimiter); } } else { $error = 3; } } else { $error = 2; } } else { $error = 1; } $this->layout = 'clear'; $this->render('thirdResult', array('error' => $error, 'delimiter' => $delimiter, 'textDelimiter' => $textDelimiter, 'table' => $table, 'uploadfile' => $uploadfile, 'error_array' => $error_array)); } Yii::app()->end(); } else { // first loading $this->render('index', array('delimiter' => $delimiter, 'textDelimiter' => $textDelimiter, 'tablesArray' => $tablesArray)); } }
<?php CSSFile(themeUrl('js/plugins/bootstrap/bootstrap-duallistbox.css')); JSFile(themeUrl('js/plugins/bootstrap/bootstrap-duallistbox.js')); $outletA = array(1 => 'dewi', 2 => 'novi', 3 => 'vita', 4 => 'sari', 5 => 'gabe'); $outletB = array(11 => 'diah', 12 => 'nada', 13 => 'andi', 14 => 'parto', 15 => 'akri', 15 => 'dono', 15 => 'kasino'); echo CHtml::beginForm('', 'post', array('class' => 'form-horizontal', 'id' => 'demoform')); ?> <div class="row"> <div class="col-md-7"> <select multiple="multiple" size="10" name="duallistbox_outlets[]" class="demo2"> <?php foreach ($outletA as $key => $outlet) { echo '<option value="' . $key . '">' . $outlet . '</option>'; } foreach ($outletB as $key => $outlet) { echo '<option value="' . $key . '" selected="selected">' . $outlet . '</option>'; } ?> </select> </div> </div> <?php echo CHtml::submitButton('Submit', array('class' => 'btn btn-primary pull-right')); echo CHtml::endForm(); ?> <script type="text/javascript"> $(function(){ var demo2 = $('select[name="duallistbox_outlets[]"]').bootstrapDualListbox({ nonSelectedListLabel: 'Outlet A',
<?php JSFile('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js'); CSSFile('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css'); $publish = publish(Yii::getPathOfAlias('application.widgets.elfinder.assets')); CSSFile($publish . '/css/elfinder.full.css'); CSSFile($publish . '/css/theme.css'); $publish = publish(Yii::getPathOfAlias('application.widgets.elfinder.assets.js') . '/elfinder.min.js'); JSFile($publish); $script = "var elf = \$('" . $this->selector . "').elfinder({\n\t\t\t\t\turl : '" . $this->action . "' // connector URL (REQUIRED)\n\t\t\t\t}).elfinder('instance');"; JSCode('elfinder', $script, CClientScript::POS_READY);