예제 #1
0
. <?php 
    echo $val['name'];
    ?>
</h4>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th></th>
                        <th>Наименование</th>
                        <th>Кол-во</th>
                        <th>цена</th>
                    </tr>
                </thead>
                <tbody>
                <?php 
    foreach ($dishes->getProd($val['dish_id']) as $key => $value) {
        ?>
                    <tr>
                        <td><?php 
        echo $cnt;
        ?>
</td>
                        <td><?php 
        echo $prod->getName($key);
        ?>
</td>
                        <td><?php 
        echo number_format($value, 2, ',', ' ');
        ?>
 <?php 
        echo $measure->getMeasure($key, 'prod');
예제 #2
0
 public function getDishProd($depId, $dates)
 {
     $dishProd = Expense::model()->with('order.dish')->findAll('date(order_date) = :dates AND dish.department_id = :department_id AND t.kind = :kind AND order.type =:types', array(':kind' => 0, ':dates' => $dates, ':department_id' => $depId, ':types' => 1));
     $dishes = new Dishes();
     $stuff = new Halfstaff();
     $result = array();
     $model = Yii::app()->db->createCommand()->select('ord.just_id,ord.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 d.department_id = :depId', array(':dates' => $dates, ':types' => 1, ':depId' => $depId))->queryAll();
     foreach ($model as $val) {
         $temp = $dishes->getProd($val['just_id']);
         $temporary = [$stuff->multiplyArray($temp, $val['count']), $val['count']];
         $result = $stuff->sumArray($result, $temporary);
     }
     $result = array();
     if (!empty($dishProd)) {
         foreach ($dishProd as $value) {
             foreach ($value->getRelated('order') as $val) {
                 $model = new Dishes();
                 $stuff = new Halfstaff();
                 $temp = $model->getProd($val->just_id);
                 $temp2 = $stuff->multiplyArray($temp, $val->count);
                 $result = $stuff->sumArray($result, $temp2);
             }
             //                $outProduct[$vals->prod_id] = $outProduct[$vals->prod_id] + $vals->amount / $val->getRelated('dish')->count * $val->count;
         }
     }
     $Prod = Expense::model()->with('order.products')->findAll('date(order_date) = :dates AND products.department_id = :department_id AND t.kind = :kind AND order.type', array(':kind' => 0, ':dates' => $dates, ':department_id' => $depId));
     if (!empty($Prod)) {
         foreach ($Prod as $value) {
             foreach ($value->getRelated('order') as $val) {
                 $result[$val->just_id] = $result[$val->just_id] + $val->count;
                 //$outProduct[$val->just_id] = $outProduct[$val->just_id] + $val->count;
             }
         }
     }
     $stuffProd = Expense::model()->with('order.halfstuff')->findAll('date(order_date) = :dates AND halfstuff.department_id = :department_id AND t.kind = :kind', array(':kind' => 0, ':dates' => $dates, ':department_id' => $depId));
     return $result;
 }