Beispiel #1
0
        <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);
    $price = $prices->getPrice($value->just_id, $value->mType, $value->type, $dates);
    if ($costPrice == 0) {
        $costPrice = 1;
    }
    $percent = $price * 100 / $costPrice - 100;
    ?>
            <?php 
    if ($percent < 50) {
        ?>
            <tr class="error">
                <td><?php 
        echo $cnt;
        ?>
</td>
                <td><?php 
        <tr>
            <th></th>
            <th>Наимен. блюда</th>
            <th>Себестоимость (сум)</th>
            <th>Цена реализации (сум)</th>
            <th>наценка план (%)</th>
            <th>наценка факт (%)</th>
            <th>отклон (+,-)</th>
            <th>тренд ср.стат.</th>
        </tr>
    </thead>
    <tbody>
        <?php 
foreach ($model as $val) {
    $beforeDates = date('Y-m-d', strtotime($dates) - 86400);
    $costPrice = $dish->getCostPrice($val['just_id'], $dates);
    $price = $prices->getPrice($val['just_id'], $val['mType'], $val['type'], $dates);
    $beforeCostPrice = $dish->getCostPrice($val['just_id'], $beforeDates);
    $beorePrice = $prices->getPrice($val['just_id'], $val['mType'], $val['type'], $beforeDates);
    if ($costPrice == 0) {
        $margin = $price * 100 / 1 - 100;
    } elseif ($price == 0) {
        $margin = 1 * 100 / $costPrice - 100;
    } else {
        $margin = $price * 100 / $costPrice - 100;
    }
    if ($beforeCostPrice == 0) {
        $beforeMargin = $beorePrice * 100 / 1 - 100;
    } elseif ($beorePrice == 0) {
        $beforeMargin = 1 * 100 / $beforeCostPrice - 100;
    } else {
Beispiel #3
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;
 }
 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));
 }
Beispiel #5
0
</td>
                        <?php 
            if ($key == 'price') {
                ?>
                            <td><?php 
                echo number_format($price->getPrice($val['prod_id'], $val['mType'], $val['type'], $dates) * $val['count'], 0, ',', ' ');
                ?>
</td>
                            <?php 
                $sum = $sum + $price->getPrice($val['prod_id'], $val['mType'], $val['type'], $dates) * $val['count'];
                ?>
                        <?php 
            } else {
                ?>
                            <td><?php 
                echo number_format($dish->getCostPrice($val['prod_id'], $dates) * $val['count'], 0, ',', ' ');
                ?>
</td>
                            <?php 
                $sum = $sum + $dish->getCostPrice($val['prod_id'], $dates) * $val['count'];
                ?>
                        <?php 
            }
            ?>
                    </tr>
                    <?php 
            $cnt++;
        }
    }
}
?>