/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionImport()
 {
     $model = new Dishtype();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dishtype'])) {
         if (!empty($_FILES)) {
             $tempFile = $_FILES['Dishtype']['tmp_name']['fileImport'];
             $fileTypes = array('xls', 'xlsx');
             // File extensions
             $fileParts = pathinfo($_FILES['Dishtype']['name']['fileImport']);
             if (in_array(@$fileParts['extension'], $fileTypes)) {
                 Yii::import('ext.heart.excel.EHeartExcel', true);
                 EHeartExcel::init();
                 $inputFileType = PHPExcel_IOFactory::identify($tempFile);
                 $objReader = PHPExcel_IOFactory::createReader($inputFileType);
                 $objPHPExcel = $objReader->load($tempFile);
                 $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
                 $baseRow = 2;
                 $inserted = 0;
                 $read_status = false;
                 while (!empty($sheetData[$baseRow]['A'])) {
                     $read_status = true;
                     //$type_id=  $sheetData[$baseRow]['A'];
                     $name = $sheetData[$baseRow]['B'];
                     $model2 = new Dishtype();
                     //$model2->type_id=  $type_id;
                     $model2->name = $name;
                     try {
                         if ($model2->save()) {
                             $inserted++;
                         }
                     } catch (Exception $e) {
                         Yii::app()->user->setFlash('error', "{$e->getMessage()}");
                         //$this->refresh();
                     }
                     $baseRow++;
                 }
                 Yii::app()->user->setFlash('success', $inserted . ' row inserted');
             } else {
                 Yii::app()->user->setFlash('warning', 'Wrong file type (xlsx, xls, and ods only)');
             }
         }
         $this->render('admin', array('model' => $model));
     } else {
         $this->render('admin', array('model' => $model));
     }
 }
 public function actionCreate()
 {
     $menuModel = Dishtype::model()->findAll('t.parent = :parent', array(':parent' => 0));
     $model = new Expense();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Expense'])) {
         $_POST['Expense']['order_date'] = date('Y-m-d H:i:s');
         $_POST['Expense']['status'] = 1;
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $messageType = 'warning';
             $message = "There are some errors ";
             $model->attributes = $_POST['Expense'];
             if ($model->save()) {
                 $messageType = 'success';
                 $message = "<strong>Well done!</strong> You successfully create data ";
                 if (isset($_POST['dish'])) {
                     foreach ($_POST['dish']['id'] as $key => $val) {
                         $prodModel = new Orders();
                         $prodModel->expense_id = $model->expense_id;
                         $prodModel->just_id = $val;
                         $prodModel->type = 1;
                         $prodModel->count = $this->changeToFloat($_POST['dish']['count'][$key]);
                         $prodModel->save();
                     }
                 }
                 if (isset($_POST['stuff'])) {
                     foreach ($_POST['stuff']['id'] as $key => $val) {
                         $prodModel = new Orders();
                         $prodModel->expense_id = $model->expense_id;
                         $prodModel->just_id = $val;
                         $prodModel->type = 2;
                         $prodModel->count = $this->changeToFloat($_POST['stuff']['count'][$key]);
                         $prodModel->save();
                     }
                 }
                 if (isset($_POST['product'])) {
                     foreach ($_POST['product']['id'] as $key => $val) {
                         $prodModel = new Orders();
                         $prodModel->expense_id = $model->expense_id;
                         $prodModel->just_id = $val;
                         $prodModel->type = 3;
                         $prodModel->count = $this->changeToFloat($_POST['product']['count'][$key]);
                         $prodModel->save();
                     }
                 }
                 $transaction->commit();
                 Yii::app()->user->setFlash($messageType, $message);
                 //$this->redirect(array('view','id'=>$model->expense_id));
             }
         } catch (Exception $e) {
             $transaction->rollBack();
             Yii::app()->user->setFlash('error', "{$e->getMessage()}");
             //$this->refresh();
         }
     }
     $this->render('create', array('model' => $model, 'menuModel' => $menuModel));
 }
Example #3
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'dishtype-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Поля с <span class="required">*</span> объязательны.</p>

	<?php 
echo $form->errorSummary($model);
?>

<?php 
echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 50));
?>
<br />
<label>Родитель</label>
<?php 
echo $form->dropDownList($model, 'parent', CHtml::listData(Dishtype::model()->findAll(), 'type_id', 'name'), array('empty' => '--Выберите тип--', 'class' => 'span5', 'maxlength' => 50));
?>


<div class="form-actions">
	<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Добавить' : 'Сохранить'));
?>
</div>

<?php 
$this->endWidget();
 public function actionUpdate($id)
 {
     $menuModel = Dishtype::model()->findAll('t.parent = :parent', array(':parent' => 0));
     $updateDish = Expense::model()->with('order.dish', 'employee')->findByPk($id);
     $updateStuff = Expense::model()->with('order.halfstuff', 'employee')->findByPk($id);
     $updateProd = Expense::model()->with('order.products', 'employee')->findByPk($id);
     if (!empty($updateDish)) {
         $empId = $updateDish->employee_id;
         $table = $updateDish->table;
         $status = $updateDish->debt;
     }
     if (!empty($updateStuff)) {
         $empId = $updateStuff->employee_id;
         $table = $updateStuff->table;
         $status = $updateStuff->debt;
     }
     if (!empty($updateProd)) {
         $empId = $updateProd->employee_id;
         $table = $updateProd->table;
         $status = $updateProd->debt;
     }
     $orders = new Orders();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['expense_id'])) {
         $model = Expense::model()->findByPk($_POST['expense_id']);
         $_POST['Expense']['order_date'] = date('Y-m-d H:i:s');
         if (isset($_POST['debt'])) {
             if ($_POST['debt'] == 1) {
                 $_POST['status'] = 1;
             }
         } else {
             $_POST['debt'] = 0;
             $_POST['status'] = 0;
         }
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $archive = new ArchiveOrder();
             $archive_message = '';
             $messageType = 'warning';
             $message = "There are some errors ";
             $model->table = $_POST['table'];
             $model->employee_id = $_POST['employee_id'];
             $model->status = $_POST['status'];
             $model->debt = $_POST['debt'];
             $model->comment = $_POST['comment'];
             if ($model->save()) {
                 $orders->model()->deleteAll('expense_id = :expId', array(':expId' => $_POST['expense_id']));
                 $messageType = 'success';
                 $message = "<strong>Well done!</strong> You successfully create data ";
                 if (isset($_POST['dish'])) {
                     $archive_message .= '*dish=>';
                     foreach ($_POST['dish']['id'] as $key => $val) {
                         $prodModel = new Orders();
                         $prodModel->expense_id = $_POST['expense_id'];
                         $prodModel->just_id = $val;
                         $prodModel->type = 1;
                         $prodModel->count = $this->changeToFloat($_POST['dish']['count'][$key]);
                         $prodModel->save();
                         $archive_message .= $val . ":" . $this->changeToFloat($_POST['dish']['count'][$key]) . ",";
                     }
                 }
                 if (isset($_POST['stuff'])) {
                     $archive_message .= '*stuff=>';
                     foreach ($_POST['stuff']['id'] as $key => $val) {
                         $prodModel = new Orders();
                         $prodModel->expense_id = $_POST['expense_id'];
                         $prodModel->just_id = $val;
                         $prodModel->type = 2;
                         $prodModel->count = $this->changeToFloat($_POST['stuff']['count'][$key]);
                         $prodModel->save();
                         $archive_message .= $val . ":" . $this->changeToFloat($_POST['stuff']['count'][$key]) . ",";
                     }
                 }
                 if (isset($_POST['product'])) {
                     $archive_message .= '*prod=>';
                     foreach ($_POST['product']['id'] as $key => $val) {
                         $prodModel = new Orders();
                         $prodModel->expense_id = $_POST['expense_id'];
                         $prodModel->just_id = $val;
                         $prodModel->type = 3;
                         $prodModel->count = $this->changeToFloat($_POST['product']['count'][$key]);
                         $prodModel->save();
                         $archive_message .= $val . ":" . $this->changeToFloat($_POST['product']['count'][$key]) . ",";
                     }
                 }
                 $archive->setArchive('update', $model->expense_id, $archive_message);
                 $transaction->commit();
                 Yii::app()->user->setFlash($messageType, $message);
                 //$this->redirect(array('view','id'=>$model->expense_id));
             }
         } catch (Exception $e) {
             $transaction->rollBack();
             Yii::app()->user->setFlash('error', "{$e->getMessage()}");
             //$this->refresh();
         }
     }
     $this->render('update', array('model' => $model, 'menuModel' => $menuModel, 'updateDish' => $updateDish, 'updateStuff' => $updateStuff, 'updateProd' => $updateProd, 'empId' => $empId, 'table' => $table, 'debt' => $status, 'expense_id' => $id));
 }
Example #5
0
    #updataTable .btn{
        padding: 0;
    }
    #menuList a{
        padding: 0 4px;
    }

</style>

<!-- /.navbar-top-links -->
<div class="navbar-default sidebar" style="margin-top: 0;" role="navigation">
    <div class="sidebar-nav tab-box">
        <ul class="nav nav-pills nav-stacked tab-nav" id="menuList">
            <?php 
foreach ($menuModel as $key => $value) {
    $subMenu = Dishtype::model()->findAll('t.parent = :parent', array(':parent' => $value->type_id));
    ?>
                <li id="<?php 
    echo $value->type_id;
    ?>
">
                    <a href="javascript:;" class="types"><?php 
    echo $value->name;
    ?>
<span style="float: right;" class="fa fa-angle-right"></span></a>
                    <ul><?php 
    foreach ($subMenu as $val) {
        ?>
                            <li class="liStyle" id="<?php 
        echo $val->type_id;
        ?>
Example #6
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $dishModel = Dishtype::model()->with('menu.dish')->findAll();
     //Dishes::model()->findAllByPk(CHtml::listData(Menu::model()->findAll('type = :type',array(':type'=>1)),'menu_id','just_id'));
     $stuffModel = Dishtype::model()->with('menu.halfstuff')->findAll();
     $prodModel = Dishtype::model()->with('menu.products')->findAll();
     /*
     $dataProvider=new CActiveDataProvider('Menu');
     $this->render('index',array(
     	'dataProvider'=>$dataProvider,
     ));
     */
     $model = new Menu('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Menu'])) {
         $model->attributes = $_GET['Menu'];
     }
     $this->render('index', array('model' => $model, 'dishModel' => $dishModel, 'prodModel' => $prodModel, 'stuffModel' => $stuffModel));
 }
Example #7
0
<div class="form-group">
    <span>
        <?php 
echo CHtml::dropDownList('type_id', '', CHtml::listData(Dishtype::model()->findAll('t.parent = :parent', array(':parent' => 0)), 'type_id', 'name'), array('empty' => '--Выберите раздел--', 'class' => '', 'id' => 'type'));
?>
&nbsp; &nbsp;
    </span>
    <span id="child"></span>
</div>
<div id="data">

</div>
<script>
    var ID;
    var trId;
    var optionData = '';


    $("#type").change(function(){

        var typeId = $(this).val();
        $.ajax({
            type: "POST",
            url: "<?php 
echo Yii::app()->createUrl('menu/checkParent');
?>
",
            data: "type_id="+typeId+'&mType='+<?php 
echo $mType;
?>
Example #8
0
echo $form->textFieldRow($model, 'status', array('class' => '', 'value' => 1, 'style' => 'display:none'));
?>
<br /><br />

<table>
    <table class="table table-hover table-bordered" data-click-to-select="true">
        <thead>
        <tr>
            <th data-checkbox="true" style="text-align: center;">Название</th>
            <th style="text-align: center;">Цена</th>
            <th style="text-align: center;">Количество</th>
        </tr>
        </thead>
        <tbody>
        <?php 
foreach (Dishtype::model()->findAll() as $val) {
    ?>
            <tr id="<?php 
    echo $val['name'];
    ?>
">
                <th colspan="3"><?php 
    echo $val['name'];
    ?>
</th>
            </tr>
            <?php 
    if (!empty($dishModel)) {
    }
    ?>
            <?php