Esempio n. 1
0
<?php

$url = "../index.php?mod=dishes&act=list";
require_once "../model/Dishes.php";
$model = new Dishes();
$id = (int) $_POST['id'];
$name = $model->processData($_POST['name']);
$name_en = $model->processData($_POST['name_en']);
$price = $model->processData($_POST['price']);
$description = $_POST['description'];
$components = $_POST['components'];
$type = (int) $_POST['type'];
$image_url = str_replace("../", "", $model->processData($_POST['image_url']));
if ($id > 0) {
    $model->updateDishes($id, $name, $name_en, $price, $description, $components, $type, $image_url);
    header('location:' . $url);
} else {
    $model->insertDishes($name, $name_en, $price, $description, $components, $type, $image_url);
    header('location:' . $url);
}
Esempio n. 2
0
<style>
    thead{
        background-color:white;
    }
</style><?php 
$cnt = 1;
$dates = date('Y-m-d');
$dish = new Dishes();
$stuff = new Halfstaff();
$prod = new Products();
$prices = new Prices();
?>
<table class="table table-bordered table-hover" id="dataTable">
    <thead>
        <tr>
            <th></th>
            <th>Наименование блюд</th>
            <th>Себестоимость</th>
            <th>Установленная цена</th>
            <th>Установленная наценка</th>
            <th>Текущая наценка</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <?php 
foreach ($model as $value) {
    ?>
            <?php 
    $costPrice = $dish->getCostPrice($value->just_id, $dates);
Esempio n. 3
0
<?php

$cnt = 1;
$dish = new Dishes();
$stuff = new Halfstaff();
$prod = new Products();
$prices = new Prices();
?>
<style>
    .green{
        color: green;
    }
    .red{
        color: red;
    }
    .rait{
        padding: 0 8px!important;
    }
    thead{
        background-color: #ffffff;
    }
</style>
<table class="table table-bordered table-stripped" id="dataTable">
    <thead>
        <tr>
            <th></th>
            <th>Наимен. блюда</th>
            <th>Себестоимость (сум)</th>
            <th>Цена реализации (сум)</th>
            <th>наценка план (%)</th>
            <th>наценка факт (%)</th>
 public function actionDepForm()
 {
     $depId = $_POST['depId'];
     $model = new Products();
     $products = $model->getProdName($depId);
     $models = new Halfstaff();
     $products = $products + $models->getStuffProdName($depId);
     $model2 = Dishes::model()->with('stuff.products')->findAll('t.department_id = :depId', array(':depId' => $depId));
     if (!empty($model2)) {
         foreach ($model2 as $value) {
             foreach ($value->getRelated('stuff') as $values) {
                 foreach ($values->getRelated('products') as $val) {
                     $products[$val->product_id] = $val->name;
                 }
             }
         }
     }
     $stuffs = $models->getStuffName($depId);
     $curProdModel = DepStorage::model()->with('product.measure')->findAll('t.department_id = :depId AND t.type = :type', array('depId' => $depId, ':type' => 1));
     $curStuffModel = DepStorage::model()->with('stuff.halfstuffType')->findAll('t.department_id = :depId AND t.type = :type', array('depId' => $depId, ':type' => 2));
     $this->renderPartial('depForm', array('curProdModel' => $curProdModel, 'curStuffModel' => $curStuffModel, 'products' => $products, 'stuffs' => $stuffs));
 }
Esempio n. 5
0
 public function getProdName($depId)
 {
     $dish = new Dishes();
     $result = array();
     $stuff = new Halfstaff();
     $temp2 = explode(":", $stuff->getStuffProd($depId));
     foreach ($temp2 as $val) {
         $model = Products::model()->findByPk($val);
         if (!empty($model)) {
             $result[$model->product_id] = $model->name;
         }
     }
     $temp = explode(":", $dish->getDishProd($depId));
     foreach ($temp as $val) {
         $model = Products::model()->findByPk($val);
         if (!empty($model)) {
             $result[$model->product_id] = $model->name;
         }
     }
     foreach (Products::model()->findAll('t.department_id = :depId', array(':depId' => $depId)) as $val) {
         $result[$val->product_id] = $val->name;
     }
     return $result;
 }
Esempio n. 6
0
 public function actionAjaxDishIncome()
 {
     $prices = new Prices();
     $dishCnt = array();
     $dCount = array();
     $prodCnt = array();
     $pCount = array();
     $stuffCnt = array();
     $sCount = array();
     $dish = new Dishes();
     $stuff = new Halfstaff();
     $prod = new Products();
     $model = Expense::model()->with('order.dish')->findAll('date(t.order_date) BETWEEN :from AND :to', array(':from' => $_POST['from'], ':to' => $_POST['to']));
     if (!empty($model)) {
         foreach ($model as $value) {
             foreach ($value->getRelated('order') as $val) {
                 $dishes[$val->just_id] = $val->getRelated('dish')->name;
                 $dishCnt[$val->just_id] = $dishCnt[$val->just_id] + $val->count * $prices->getPrice($val->just_id, $value->mType, $val->type, $value->order_date) - $dish->getCostPrice($val->just_id, $value->order_date);
                 $dCount[$val->just_id] = $dCount[$val->just_id] + $val->count;
             }
         }
     }
     $model2 = Expense::model()->with('order.halfstuff')->findAll('date(t.order_date) BETWEEN :from AND :to', array(':from' => $_POST['from'], ':to' => $_POST['to']));
     if (!empty($model2)) {
         foreach ($model2 as $value) {
             foreach ($value->getRelated('order') as $val) {
                 $halfstuff[$val->just_id] = $val->getRelated('halfstuff')->name;
                 $stuffCnt[$val->just_id] = $stuffCnt[$val->just_id] + $val->count * $prices->getPrice($val->just_id, $value->mType, $val->type, $value->order_date) - $stuff->getCostPrice($val->just_id, $value->order_date);
                 $sCount[$val->just_id] = $sCount[$val->just_id] + $val->count;
             }
         }
     }
     $model3 = Expense::model()->with('order.products')->findAll('date(t.order_date) BETWEEN :from AND :to', array(':from' => $_POST['from'], ':to' => $_POST['to']));
     if (!empty($model3)) {
         foreach ($model3 as $value) {
             foreach ($value->getRelated('order') as $val) {
                 $products[$val->just_id] = $val->getRelated('products')->name;
                 $prodCnt[$val->just_id] = $prodCnt[$val->just_id] + $val->count * $prices->getPrice($val->just_id, $value->mType, $val->type, $value->order_date) - $prod->getCostPrice($val->just_id, $value->order_date);
                 $pCount[$val->just_id] = $pCount[$val->just_id] + $val->count;
             }
         }
     }
     $this->renderPartial('ajaxDishIncome', array('dishes' => $dishes, 'dishCnt' => $dishCnt, 'halfstuff' => $halfstuff, 'stuffCnt' => $stuffCnt, 'products' => $products, 'prodCnt' => $prodCnt, 'dCount' => $dCount, 'sCount' => $sCount, 'pCount' => $pCount));
 }
Esempio n. 7
0
 public function getStuff($id)
 {
     $result = array();
     $result2 = array();
     $model = Dishes::model()->with('halfstuff')->findByPk($id);
     foreach ($model->getRelated('halfstuff') as $val) {
         $result[$val->halfstuff_id] = $result[$val->halfstuff_id] + $val->amount;
         //$result = $stuff->sumArray($result,$result2);
     }
     return $result;
 }
Esempio n. 8
0
 public function addDish($id, $depId)
 {
     //Корневые продукты блюда выбранного отдела
     $dishProducts = Dishes::model()->with('products')->findByPk($id, 't.department_id = :depId', array(':depId' => $depId));
     if (!empty($dishProducts)) {
         foreach ($dishProducts->getRelated('products') as $val) {
             $this->addProd($val->product_id, $depId);
         }
     }
     //Корневые полуфабрикаты блюда выбранного отдела
     $DishStuff = Dishes::model()->with('stuff')->findByPk($id, 't.department_id = :depId', array(':depId' => $depId));
     if (!empty($DishStuff)) {
         foreach ($DishStuff->getRelated('stuff') as $val) {
             $this->addStuff($val->halfstuff_id, $depId);
         }
     }
 }
 public function actionListDish()
 {
     $depId = $_POST['depId'];
     $dishList = Dishes::model()->findAll('t.department_id = :depId', array(':depId' => $depId));
     $this->renderPartial('listDish', array('model' => $dishList));
 }
Esempio n. 10
0
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'inexpense-form', 'enableAjaxValidation' => false));
?>


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

<?php 
echo $form->dropDownList($model, 'department_id', CHtml::listData(Department::model()->findAll(), 'department_id', 'name'), array('empty' => '--Выберите отдел--', 'class' => 'span3'));
?>
 &nbsp;  &nbsp;
<?php 
echo CHtml::dropDownList('stuff', '', CHtml::listData(Dishes::model()->findAll(), 'dish_id', 'name'), array('empty' => '--Выберите блюда--', 'class' => 'span3'));
?>

<script src="<?php 
echo Yii::app()->request->baseUrl;
?>
/js/jquery.table2excel.js" type="text/javascript"></script>
<div id="data">
    <table id="structList" class="table table-striped table-hover ">
        <thead>
        <tr>
            <th style="text-align:center;">Название продукта</th>
            <th style="text-align:center;">Количество</th>
            <th style="text-align:center;">Удалить</th>
        </tr>
        </thead>
Esempio n. 11
0
 public function getDepCost($depId, $dates)
 {
     $summ = 0;
     $dish = new Dishes();
     $stuff = new Halfstaff();
     $prod = new Products();
     $model = Yii::app()->db->createCommand()->select('ord.just_id,sum(ord.count) as count')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('dishes d', 'd.dish_id = ord.just_id')->where('date(ex.order_date) = :dates AND ord.type = :types AND ex.status = :status AND d.department_id = :depId', array(':dates' => $dates, ':types' => 1, ':status' => 0, ':depId' => $depId))->group('ord.just_id')->queryAll();
     foreach ($model as $val) {
         $summ = $summ + $dish->getCostPrice($val['just_id'], $dates) * $val['count'];
     }
     $model2 = Yii::app()->db->createCommand()->select('ord.just_id,sum(ord.count) as count')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('halfstaff h', 'h.halfstuff_id = ord.just_id')->where('date(ex.order_date) = :dates AND ord.type = :types AND ex.status = :status AND h.department_id = :depId', array(':dates' => $dates, ':types' => 2, ':status' => 0, ':depId' => $depId))->group('ord.just_id')->queryAll();
     foreach ($model2 as $val) {
         $summ = $summ + $stuff->getCostPrice($val['just_id'], $dates) * $val['count'];
     }
     $model3 = Yii::app()->db->createCommand()->select('ord.just_id,sum(ord.count) as count')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('products p', 'p.product_id = ord.just_id')->where('date(ex.order_date) = :dates AND ord.type = :types AND ex.status = :status AND p.department_id = :depId', array(':dates' => $dates, ':types' => 3, ':status' => 0, ':depId' => $depId))->group('ord.just_id')->queryAll();
     foreach ($model3 as $val) {
         $summ = $summ + $prod->getCostPrice($val['just_id'], $dates) * $val['count'];
     }
     return $summ;
 }
Esempio n. 12
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionImport()
 {
     $model = new Dishes();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Dishes'])) {
         if (!empty($_FILES)) {
             $tempFile = $_FILES['Dishes']['tmp_name']['fileImport'];
             $fileTypes = array('xls', 'xlsx');
             // File extensions
             $fileParts = pathinfo($_FILES['Dishes']['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;
                     //$dish_id=  $sheetData[$baseRow]['A'];
                     $name = $sheetData[$baseRow]['B'];
                     $model2 = new Dishes();
                     //$model2->dish_id=  $dish_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));
     }
 }
Esempio n. 13
0
 /**
  * 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)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['dish']) or isset($_POST['stuff']) or isset($_POST['product'])) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $messageType = 'warning';
             $message = "There are some errors ";
             foreach ($_POST as $keys => $value) {
                 $message = "<strong>";
                 if ($keys == 'dish') {
                     foreach ($value['id'] as $key => $val) {
                         $newModel = new Menu();
                         $newModel->just_id = $val;
                         $newModel->type = 1;
                         $newModel->type_id = $value['type'][$key];
                         if ($newModel->save()) {
                             $messageType = 'success';
                         }
                         Dishes::model()->updateByPk($val, array('price' => $value['price'][$key]));
                         $message .= "Блюда";
                     }
                 }
                 /*if($keys == 'stuff'){
                       foreach($value['id'] as $key => $val){
                           echo $value['price'][$key]."<br />";
                           $newModel = new Menu;
                           $newModel->just_id = $val;
                           $newModel->type = 2;
                           if($newModel->save()) 
                     $messageType = 'success';
                           Halfstaff::model()->updateByPk($val,array('price'=>$value['price'][$key]));
                     $message .= ", Полуфабрикаты";
                       }
                   }*/
                 if ($keys == 'product') {
                     foreach ($value['id'] as $key => $val) {
                         $newModel = new Menu();
                         $newModel->just_id = $val;
                         $newModel->type = 3;
                         $newModel->type_id = $value['type'][$key];
                         if ($newModel->save()) {
                             $messageType = 'success';
                         }
                         Products::model()->updateByPk($val, array('price' => $value['price'][$key]));
                         $message .= ", Продукты ";
                     }
                 }
             }
             $message .= "Успешно добавлены</strong>";
             $transaction->commit();
             Yii::app()->user->setFlash($messageType, $message);
             //$uploadFile=CUploadedFile::getInstance($model,'filename');
             /*if($model->save()){
             			$messageType = 'success';
             			$message = "<strong>Well done!</strong> You successfully create data ";
             			/*
             			$model2 = Menu::model()->findByPk($model->menu_id);						
             			if(!empty($uploadFile)) {
             				$extUploadFile = substr($uploadFile, strrpos($uploadFile, '.')+1);
             				if(!empty($uploadFile)) {
             					if($uploadFile->saveAs(Yii::app()->basePath.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.'menu'.DIRECTORY_SEPARATOR.$model2->menu_id.DIRECTORY_SEPARATOR.$model2->menu_id.'.'.$extUploadFile)){
             						$model2->filename=$model2->menu_id.'.'.$extUploadFile;
             						$model2->save();
             						$message .= 'and file uploded';
             					}
             					else{
             						$messageType = 'warning';
             						$message .= 'but file not uploded';
             					}
             				}						
             			}
             			$transaction->commit();
             			Yii::app()->user->setFlash($messageType, $message);
             			$this->redirect(array('view','id'=>$model->menu_id));
             		}				*/
         } catch (Exception $e) {
             $transaction->rollBack();
             Yii::app()->user->setFlash('error', "{$e->getMessage()}");
             //$this->refresh();
         }
     }
     $this->render('update', array('model' => $model));
 }
Esempio n. 14
0
<?php

$dishes = new Dishes();
$measure = new Measurement();
$prod = new Products();
$stuff = new Halfstaff();
$count = 1;
$dates = date('Y-m-d');
?>
<br>
<script src="<?php 
echo Yii::app()->request->baseUrl;
?>
/js/jquery.table2excel.js" type="text/javascript"></script>

<script src="/js/jquery.printPage.js"></script>
<?php 
echo CHtml::link('<i class="fa fa-print"></i>  Печать', array('/settings/ajaxPrintCalculate?id=' . $id), array('class' => 'btn btnPrint'));
?>
 &nbsp;
<button class="btn btn-success" id="export">Экспорт в excel</button><br><br>
<table class="table" id="dataTable">
    <tr>
    <?php 
foreach ($model as $val) {
    $cnt = 1;
    $summ = 0;
    ?>
        <?php 
    if ($count % 4 + 1 == 0) {
        ?>
Esempio n. 15
0
 public function getStuffProdName($depId)
 {
     $models = Dishes::model()->with('stuff')->findAll('t.department_id = :depId', array(':depId' => $depId));
     $stuff = '';
     if (!empty($models)) {
         foreach ($models as $values) {
             foreach ($values->getRelated('stuff') as $value) {
                 $stuff .= $this->getProdId($value->halfstuff_id);
             }
         }
     }
     $model = Halfstaff::model()->findAll('t.department_id = :depId', array(':depId' => $depId));
     foreach ($model as $value) {
         $stuff .= $this->getProdId($value->halfstuff_id);
     }
     $temp = explode(':', $stuff);
     $result = array();
     foreach ($temp as $val) {
         $model = Products::model()->findByPk($val);
         if (!empty($model)) {
             $result[$model->product_id] = $model->name;
         }
     }
     return $result;
 }
Esempio n. 16
0
 public function actionProdRelList($id)
 {
     $model = Dishes::model()->with('products')->findAll('products.product_id = :prodId', array(':prodId' => $id));
     $model2 = Halfstaff::model()->with('products')->findAll('products.product_id = :prodId', array(':prodId' => $id));
     $this->renderPartial('prodRelList', array('model' => $model, 'model2' => $model2));
 }
Esempio n. 17
0
<?php

$cnt = 1;
$prod = new Products();
$stuff = new Halfstaff();
$price = new Prices();
$dish = new Dishes();
$sum = 0;
?>
<style>

    thead{
        background-color:white;
    }
</style>
<table id="dataTable" class="table table-bordered table-hover">
    <thead>
        <tr>
            <th></th>
            <th>Наименование</th>
            <th>Кол-во</th>
            <th>Сумма (сум) </th>
        </tr>
    </thead>
    <tbody>
        <?php 
if (!empty($model)) {
    foreach ($model as $val) {
        if ($val['count'] != 0) {
            ?>
                <tr>