예제 #1
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>
예제 #2
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;
 }
예제 #3
0
 public function actionAjaxDetail($depId, $key, $dates)
 {
     $model = array();
     $model2 = array();
     $model3 = array();
     $expense = new Expense();
     $prod = new Products();
     $stuff = new Halfstaff();
     $measure = new Measurement();
     if ($key == 'begin') {
         $model = Yii::app()->db->createCommand()->select('db.startCount as count,db.prod_id,p.name as name,m.name as Mname')->from('dep_balance db')->join('products p', 'p.product_id = db.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll();
         $model2 = Yii::app()->db->createCommand()->select('db.startCount as count,db.prod_id,h.name as name, m.name as Mname')->from('dep_balance db')->join('halfstaff h', 'h.halfstuff_id = db.prod_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll();
     }
     if ($key == 'end') {
         $model = Yii::app()->db->createCommand()->select('db.endCount as count,db.prod_id,p.name as name,m.name as Mname')->from('dep_balance db')->join('products p', 'p.product_id = db.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll();
         $model2 = Yii::app()->db->createCommand()->select('db.endCount as count,db.prod_id,h.name as name, m.name as Mname')->from('dep_balance db')->join('halfstaff h', 'h.halfstuff_id = db.prod_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll();
     }
     if ($key == 'curEnd') {
         $model = Yii::app()->db->createCommand()->select('db.CurEndCount as count,db.prod_id,p.name as name,m.name as Mname')->from('dep_balance db')->join('products p', 'p.product_id = db.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll();
         $model2 = Yii::app()->db->createCommand()->select('db.CurEndCount as count,db.prod_id,h.name as name, m.name as Mname')->from('dep_balance db')->join('halfstaff h', 'h.halfstuff_id = db.prod_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll();
     }
     if ($key == 'realize') {
         $model = Yii::app()->db->createCommand()->select('dr.count as count,dr.prod_id,p.name as name,m.name as Mname')->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->join('products p', 'p.product_id = dr.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('date(df.real_date) = :dates AND df.department_id = :depId AND df.fromDepId = :fromDepId ', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0))->queryAll();
     }
     if ($key == 'price') {
         $model = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,p.name as name,ex.mType,ord.type')->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 p.department_id = :DepId AND ord.type = :type', array(':dates' => $dates, ':DepId' => $depId, ':type' => 3))->group('ord.just_id')->queryAll();
         $model2 = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,h.name as name,ex.mType,ord.type')->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 h.department_id = :DepId AND ord.type = :type', array(':dates' => $dates, ':DepId' => $depId, ':type' => 2))->group('ord.just_id')->queryAll();
         $model3 = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,d.name as name,ex.mType,ord.type')->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 d.department_id = :DepId AND ord.type = :type', array(':dates' => $dates, ':DepId' => $depId, ':type' => 1))->group('ord.just_id')->queryAll();
     }
     if ($key == 'other') {
         $model = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,p.name as name')->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 ex.kind  = :kind AND ord.type = :type', array(':dates' => $dates, ':kind' => 1, ':type' => 3))->group('ord.just_id')->queryAll();
     }
     if ($key == 'costPrice') {
         $temp = $expense->getDishProd($depId, $dates);
         $count = 0;
         foreach ($temp as $key => $val) {
             $model[$count]['count'] = $val;
             $model[$count]['prod_id'] = $key;
             $model[$count]['name'] = $prod->getName($key);
             $model[$count]['Mname'] = $measure->getMeasure($key, 'prod');
             $count++;
         }
         $temp2 = $expense->getDishStuff($depId, $dates);
         $count = 0;
         foreach ($temp2 as $key => $val) {
             $model2[$count]['count'] = $val;
             $model2[$count]['prod_id'] = $key;
             $model2[$count]['name'] = $stuff->getName($key);
             $model2[$count]['Mname'] = $measure->getMeasure($key, 'stuff');
             $count++;
         }
         /*$model = Yii::app()->db->createCommand()
               ->select('sum(ord.count) as count,ord.just_id as prod_id,p.name as name,ex.mType,ord.type')
               ->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 p.department_id = :DepId AND ord.type = :type',
                   array(':dates'=>$dates,':DepId'=>$depId,':type'=>3))
               ->group('ord.just_id')
               ->queryAll();
           $model2 = Yii::app()->db->createCommand()
               ->select('sum(ord.count) as count,ord.just_id as prod_id,h.name as name,ex.mType,ord.type')
               ->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 h.department_id = :DepId AND ord.type = :type',
                   array(':dates'=>$dates,':DepId'=>$depId,':type'=>2))
               ->group('ord.just_id')
               ->queryAll();
           $model3 = Yii::app()->db->createCommand()
               ->select('sum(ord.count) as count,ord.just_id as prod_id,d.name as name,ex.mType,ord.type')
               ->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 d.department_id = :DepId AND ord.type = :type',
                   array(':dates'=>$dates,':DepId'=>$depId,':type'=>1))
               ->group('ord.just_id')
               ->queryAll();*/
     }
     if ($key == 'inRealize') {
         $model = Yii::app()->db->createCommand()->select('dr.count as count,dr.prod_id,p.name as name,m.name as Mname')->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->join('products p', 'p.product_id = dr.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('date(df.real_date) = :dates AND df.department_id = :depId AND df.fromDepId != :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0))->queryAll();
         $model2 = Yii::app()->db->createCommand()->select('inord.count as count,inord.stuff_id as prod_id,h.name as name,m.name as Mname')->from('inexpense inexp')->join('inorder inord', 'inord.inexpense_id = inexp.inexpense_id')->join('halfstaff h', 'h.halfstuff_id = inord.stuff_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('date(inexp.inexp_date) = :dates AND inexp.department_id = :depId AND inexp.fromDepId != :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0))->queryAll();
     }
     if ($key == 'inExp') {
         $model = Yii::app()->db->createCommand()->select('dr.count as count,dr.prod_id,p.name as name,m.name as Mname')->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->join('products p', 'p.product_id = dr.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('date(df.real_date) = :dates AND df.department_id != :depId AND df.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId))->queryAll();
         $model2 = Yii::app()->db->createCommand()->select('inord.count as count,inord.stuff_id as prod_id,h.name as name,m.name as Mname')->from('inexpense inexp')->join('inorder inord', 'inord.inexpense_id = inexp.inexpense_id')->join('halfstaff h', 'h.halfstuff_id = inord.stuff_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('date(inexp.inexp_date) = :dates AND inexp.department_id != :depId AND inexp.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId))->queryAll();
     }
     $this->renderPartial('ajaxDetail', array('dates' => $dates, 'model' => $model, 'model2' => $model2, 'model3' => $model3, 'key' => $key));
 }
예제 #4
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) {
        ?>
예제 #5
0
 public function getDepInExp($dates, $depId)
 {
     $prod = new Products();
     $stuff = new Halfstaff();
     $summ = 0;
     $model = Yii::app()->db->createCommand()->select()->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->where('date(df.real_date) = :dates AND df.department_id != :depId AND df.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId))->queryAll();
     foreach ($model as $val) {
         $summ = $summ + $val['count'] * $prod->getCostPrice($val['prod_id'], $dates);
     }
     $model2 = Yii::app()->db->createCommand()->select()->from('inexpense inexp')->join('inorder inord', 'inord.inexpense_id = inexp.inexpense_id')->where('date(inexp.inexp_date) = :dates AND inexp.department_id != :depId AND inexp.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId))->queryAll();
     foreach ($model2 as $val) {
         $summ = $summ + $val['count'] * $stuff->getCostPrice($val['stuff_id'], $dates);
     }
     return $summ;
 }
예제 #6
0
 public function endDepBalance($dates)
 {
     $stuff = new Halfstaff();
     //Количественный расчет по отделам
     $department = Department::model()->findAll();
     foreach ($department as $v) {
         $depId = $v->department_id;
         $depIn = array();
         $depOut = array();
         $inProduct = array();
         $instuff = array();
         $endProduct = array();
         $endStuff = array();
         $outProduct = array();
         $outStuff = array();
         $outStuffProd = array();
         $prodModel = Products::model()->findAll();
         foreach ($prodModel as $value) {
             $outProduct[$value->product_id] = 0;
         }
         //расход продуктов в другой отдел
         $departMoveOut = DepFaktura::model()->with('realizedProd')->findAll('date(t.real_date) = :dates AND t.department_id != :depId AND t.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId));
         foreach ($departMoveOut as $key => $val) {
             foreach ($val->getRelated('realizedProd') as $value) {
                 $depOut[$value->prod_id] = $depOut[$value->prod_id] + $value->count;
             }
         }
         //приход продуктов из других отделов
         $departMoveIn = DepFaktura::model()->with('realizedProd')->findAll('date(t.real_date) = :dates AND t.department_id = :depId AND t.fromDepId != :fromDepId ', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0));
         foreach ($departMoveIn as $value) {
             foreach ($value->getRelated('realizedProd') as $val) {
                 $depIn[$val->prod_id] = $depIn[$val->prod_id] + $val->count;
             }
         }
         $dish = new Expense();
         $outProduct = $dish->getDishProd($depId, $dates);
         $outDishStuff = $dish->getDishStuff($depId, $dates);
         $model = DepFaktura::model()->with('realizedProd')->findAll('date(t.real_date) = :dates AND t.department_id = :depId AND t.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0));
         foreach ($model as $key => $val) {
             foreach ($val->getRelated('realizedProd') as $value) {
                 $inProduct[$value->prod_id] = $inProduct[$value->prod_id] + $value->count;
             }
         }
         //Приход загатовок в отдел и расход их продуктов
         $models2 = Inexpense::model()->with('inorder.stuffs.stuffStruct')->findAll('date(t.inexp_date) = :dates AND t.department_id = :depId AND stuffStruct.types = :types AND t.fromDepId = :fromDepId', array(':dates' => $dates, 'depId' => $depId, ':types' => 1, ':fromDepId' => 0));
         foreach ($models2 as $val) {
             foreach ($val->getRelated('inorder') as $value) {
                 $instuff[$value->stuff_id] = $instuff[$value->stuff_id] + $value->count;
                 foreach ($value->getRelated('stuffs')->getRelated('stuffStruct') as $values) {
                     $outStuffProd[$values->prod_id] = $outStuffProd[$values->prod_id] + $values->amount / $value->getRelated('stuffs')->count * $value->count;
                 }
             }
         }
         //Приход и расход загатовок в отдел, расход их продуктов
         $model3 = Inexpense::model()->with('inorder.stuffs.stuffStruct.podstuff.podstuffStruct.Struct')->findAll('date(t.inexp_date) = :dates AND t.department_id = :depId AND stuffStruct.types = :types AND t.fromDepId = :fromDepId', array(':dates' => $dates, 'depId' => $depId, ':types' => 2, ':fromDepId' => 0));
         foreach ($model3 as $val) {
             foreach ($val->getRelated('inorder') as $value) {
                 $instuff[$value->stuff_id] = $instuff[$value->stuff_id] + $value->count;
                 foreach ($value->getRelated('stuffs')->getRelated('stuffStruct') as $values) {
                     $outStuff[$values->prod_id] = $outStuff[$values->prod_id] + $values->amount / $value->getRelated('stuffs')->count * $value->count;
                     foreach ($values->getRelated('podstuff')->getRelated('podstuffStruct') as $vals) {
                         $outStuffProd[$values->prod_id] = $outStuffProd[$values->prod_id] + $vals->amount / $values->getRelated('podstuff')->count * $values->amount / $value->getRelated('stuffs')->count * $value->count;
                     }
                 }
             }
         }
         $outStuff = $stuff->sumArray($outDishStuff, $outStuff);
         $inexpense = new Inexpense();
         $depStuffIn = $inexpense->getDepIn($depId, $dates);
         $depStuffOut = $inexpense->getDepOut($depId, $dates);
         $curProd = DepBalance::model()->with('products')->findAll('t.b_date = :dates AND t.department_id = :depId AND t.type = :type', array(':dates' => $dates, ':depId' => $depId, ':type' => 1));
         foreach ($curProd as $value) {
             //echo 'id -> '.$value->prod_id.' '.$value->getRelated('products')->name.'|| Начальный =>'.$value->startCount.'|| Приход =>'.$inProduct[$value->prod_id].'|| Расход =>'.$outProduct[$value->prod_id].'|| перемещ in =>'.$depIn[$value->prod_id].'|| перемещ out =>'.$depOut[$value->prod_id]."<br />";
             $endProduct[$value->prod_id] = +($value->startCount + $inProduct[$value->prod_id] - $outProduct[$value->prod_id] - $outStuffProd[$value->prod_id] + $depIn[$value->prod_id] - $depOut[$value->prod_id]);
             $Models = DepBalance::model()->find('prod_id = :prod_id AND department_id = :depId AND b_date = :dates AND t.type = :type', array(':prod_id' => $value->prod_id, ':depId' => $v->department_id, ':dates' => $dates, ':type' => 1));
             $Models->endCount = $endProduct[$value->prod_id];
             $Models->update(array('endCount'));
         }
         $curStuff = DepBalance::model()->findAll('t.b_date = :dates AND t.department_id = :depId AND t.type = :type', array(':dates' => $dates, ':depId' => $depId, ':type' => 2));
         foreach ($curStuff as $value) {
             $endStuff[$value->prod_id] = $value->startCount + $instuff[$value->prod_id] + $depStuffIn[$value->prod_id] - $outStuff[$value->prod_id] - $depStuffOut[$value->prod_id];
             $Models = DepBalance::model()->find('prod_id = :prod_id AND department_id = :depId AND b_date = :dates AND t.type = :type', array(':prod_id' => $value->prod_id, ':depId' => $v->department_id, ':dates' => $dates, ':type' => 2));
             $Models->endCount = $endStuff[$value->prod_id];
             $Models->update(array('endCount'));
         }
     }
     //конец
 }
예제 #7
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);
예제 #8
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;
 }
예제 #9
0
 public function actionCount()
 {
     $prodVal = $_POST['prodVal'];
     $stuffId = $_POST['stuffId'];
     $prodId = $_POST['prodId'];
     $result = 0;
     $model = Halfstaff::model()->with('stuffStruct.Struct.measure')->findByPk($stuffId);
     foreach ($model->getRelated('stuffStruct') as $val) {
         if ($val->prod_id == $prodId) {
             $result = $prodVal * $model->count / $val->amount;
         }
     }
     echo $result;
 }
예제 #10
0
 public function actionRefreshAdd()
 {
     $prod = new Products();
     $prodList = $prod->getUseProdList();
     $stuff = new Halfstaff();
     $stuffList = $stuff->getUseStuffList();
     $this->renderPartial('refreshAdd', array('stuffList' => $stuffList, 'prodList' => $prodList, 'form' => $_POST['form']));
 }
예제 #11
0
   </table>
</div>
<div class="">
    <label>Полуфабрикаты</label>
    <table class="table table-bordered">
        <thead>
            <th>название</th>
            <th>кол</th>
            <th>ед.изм</th>
            <th>цена</th>
        </thead>
        <tbody>
        <?php 
$sum = array();
$DishSumm = 0;
$stuff = new Halfstaff();
if ($HalfstuffProd) {
    foreach ($HalfstuffProd->getRelated('halfstuff') as $keys => $value) {
        $price = $stuff->getCostPrice($value->getRelated('Structs')->halfstuff_id, $dates);
        ?>
                <tr>
                    <td><?php 
        echo $value->getRelated('Structs')->name;
        ?>
</td>
                    <td><?php 
        echo $value->amount;
        ?>
</td>
                    <td><?php 
        echo $value->getRelated('Structs')->getRelated('halfstuffType')->name;
예제 #12
0
        echo $val->getRelated('Struct')->getRelated('measure')->name;
        ?>
</td>
                <td><?php 
        echo number_format($price * $val->amount, 2);
        ?>
</td>
              </tr>  
                            
            <?php 
        $sum = $sum + $price * $val->amount;
    }
}
if ($Stuff) {
    $stuffSum = 0;
    $stuff = new Halfstaff();
    foreach ($Stuff->getRelated('stuffStruct') as $value) {
        $price = $stuff->getCostPrice($value->prod_id, $dates);
        //$stuffSum = $countStuff/$value->getRelated('stuff')->count;
        ?>
 <tr>
                    <td><?php 
        echo $value->getRelated('stuff')->name;
        ?>
</td>
                    <td><?php 
        echo $value->amount;
        ?>
</td>
                    <td><?php 
        echo $value->getRelated('stuff')->getRelated('halfstuffType')->name;
예제 #13
0
 public function addStuff($id, $depId)
 {
     if ($this->checkStuff($id, $depId) != true) {
         $max_date = DepBalance::model()->find(array('select' => 'MAX(b_date) as b_date'));
         $model = new DepBalance();
         $model->b_date = $max_date->b_date;
         $model->prod_id = $id;
         $model->startCount = 0;
         $model->endCount = 0;
         $model->department_id = $depId;
         $model->type = 2;
         $model->save();
         //Список полуфабрикатов и их продуктов
         $dishStruct = Halfstaff::model()->with('stuffStruct.Struct')->findByPk($id, 'stuffStruct.types = :types', array(':types' => 1));
         if (!empty($dishStruct)) {
             foreach ($dishStruct->getRelated('stuffStruct') as $val) {
                 $this->addProd($val->getRelated('Struct')->product_id, $depId);
             }
         }
         //Список подполуфабрикатов и их продуктов
         $stuffStructs = Halfstaff::model()->with('stuffStruct.podstuff.podstuffStruct.Struct')->findByPk($id, 'stuffStruct.types = :types', array(':types' => 2));
         if (!empty($stuffStructs)) {
             foreach ($stuffStructs->getRelated('stuffStruct') as $val) {
                 $this->addStuff($val->prod_id, $depId);
                 foreach ($val->getRelated('podstuff')->getRelated('podstuffStruct') as $vals) {
                     $this->addProd($vals->prod_id, $depId);
                 }
             }
         }
     }
 }
예제 #14
0
 public function addStuff($id, $depId)
 {
     if ($this->checkStuff($id, $depId) != true) {
         $max_date = DepBalance::model()->find(array('select' => 'MAX(b_date) as b_date'));
         $model = new DepBalance();
         $model->b_date = $max_date->b_date;
         $model->prod_id = $id;
         $model->startCount = 0;
         $model->endCount = 0;
         $model->department_id = $depId;
         $model->type = 2;
         $model->save();
     }
     //Список полуфабрикатов и их продуктов
     //$dishStruct = Halfstaff::model()->with('stuffStruct.Struct')->findByPk($id,'stuffStruct.types = :types',array(':types'=>1));
     $model = Halfstaff::model()->with('stuffStruct')->findByPk($id);
     $prod = '';
     foreach ($model->getRelated('stuffStruct') as $val) {
         if ($val->types == 2) {
             $this->addStuff($val->prod_id, $depId);
         } else {
             $this->addProd($val->prod_id, $depId);
         }
     }
     return $prod;
 }
예제 #15
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(Halfstaff::model()->findAll(), 'halfstuff_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></th>
                <th style="text-align:center;">Удалить</th>
            </tr>
예제 #16
0
 public function getCostPrice($id, $order_date)
 {
     $log = new Logs();
     $stuffSum = 0;
     $prodSum = 0;
     $model = $log->getStructure($order_date, $id, $this->tableName());
     if (!empty($model['prod']) && !empty($model['stuff']) && !empty($model['count'])) {
         if ($model['count'] == 0) {
             $dish = Yii::app()->db->createCommand()->select('count')->from('dishes')->where('dish_id = :id', array(':id' => $id))->queryRow();
             $model['count'] = $dish['count'];
         }
     } else {
         $model = $this->getStruct($id);
     }
     $stuff = new Halfstaff();
     $costPrice = array();
     $products = new Products();
     if (!empty($model)) {
         if (!empty($model['prod'])) {
             foreach ($model['prod'] as $key => $value) {
                 $costPrice['prod'][$key] = $products->getCostPrice($key, $order_date) * $value / $model['count'];
             }
         }
         if (!empty($model['stuff'])) {
             foreach ($model['stuff'] as $key => $value) {
                 $costPrice['stuff'][$key] = $stuff->getCostPrice($key, $order_date) * $value / $model['count'];
             }
         }
     }
     if (!empty($costPrice['prod'])) {
         $prodSum = array_sum($costPrice['prod']);
     }
     if (!empty($costPrice['stuff'])) {
         $stuffSum = array_sum($costPrice['stuff']);
     }
     return $prodSum + $stuffSum;
 }
예제 #17
0
 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));
 }
예제 #18
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionImport()
 {
     $model = new Halfstaff();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Halfstaff'])) {
         if (!empty($_FILES)) {
             $tempFile = $_FILES['Halfstaff']['tmp_name']['fileImport'];
             $fileTypes = array('xls', 'xlsx');
             // File extensions
             $fileParts = pathinfo($_FILES['Halfstaff']['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;
                     //$halfstuff_id=  $sheetData[$baseRow]['A'];
                     $name = $sheetData[$baseRow]['B'];
                     $stuff_type = $sheetData[$baseRow]['C'];
                     $model2 = new Halfstaff();
                     //$model2->halfstuff_id=  $halfstuff_id;
                     $model2->name = $name;
                     $model2->stuff_type = $stuff_type;
                     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));
     }
 }
예제 #19
0
 public function getDepBalanceSumm($dates, $depId)
 {
     $summ = array();
     $prod = new Products();
     $stuff = new Halfstaff();
     $model = Yii::app()->db->createCommand()->select('')->from('dep_balance b')->where('b_date = :dates AND b.department_id = :depId AND b.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll();
     foreach ($model as $val) {
         $summ[0] = $summ[0] + $val['startCount'] * $prod->getCostPrice($val['prod_id'], $dates);
         $summ[1] = $summ[1] + $val['endCount'] * $prod->getCostPrice($val['prod_id'], $dates);
         $summ[2] = $summ[2] + $val['CurEndCount'] * $prod->getCostPrice($val['prod_id'], $dates);
     }
     $model2 = Yii::app()->db->createCommand()->select('')->from('dep_balance b')->where('b_date = :dates AND b.department_id = :depId AND b.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll();
     foreach ($model2 as $val) {
         $summ[0] = $summ[0] + $val['startCount'] * $stuff->getCostPrice($val['prod_id'], $dates);
         $summ[1] = $summ[1] + $val['endCount'] * $stuff->getCostPrice($val['prod_id'], $dates);
         $summ[2] = $summ[2] + $val['CurEndCount'] * $stuff->getCostPrice($val['prod_id'], $dates);
     }
     return $summ;
 }
예제 #20
0
 public function actionOut()
 {
     $dates = $_POST['dates'];
     $outProduct = array();
     $dish = new Expense();
     $stuff = new Halfstaff();
     foreach (Department::model()->findAll() as $val) {
         $outProduct = $stuff->sumArray($outProduct, $dish->getDishProd($val->department_id, $dates));
         $outDishStuff = $dish->getDishStuff($val->department_id, $dates);
     }
     $Products = Products::model()->findAll();
     $this->renderPartial('out', array('outProduct' => $outProduct, 'product' => $Products, 'dates' => $dates));
 }
예제 #21
0
<script src="<?php 
echo Yii::app()->request->baseUrl;
?>
/js/jquery.table2excel.js" type="text/javascript"></script>
</div> &nbsp; <button type="button" id="export" class="btn btn-success">Экспорт</button>
<table class="table table-bordered" id="dataTable">
    <thead>
        <tr>
            <th></th>
            <th>Название</th>
        </tr>
    </thead>
    <tbody>
<?php 
$product = new Products();
$stuff = new Halfstaff();
foreach ($department as $val) {
    $count = 1;
    ?>
    <tr>
        <th colspan="2" style="text-align: center"><?php 
    echo $val->name;
    ?>
</th>
    </tr>
    <?php 
    $prodList = $product->getProdName($val->department_id);
    $prod = $stuff->getStuffProdName($val->department_id);
    $stuffList = $stuff->getStuffName($val->department_id);
    ?>
    <tr>
예제 #22
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;
 }
예제 #23
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));
 }
예제 #24
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>