Example #1
0
<?php 
$box = $this->beginWidget('bootstrap.widgets.TbBox', array('title' => 'Заказы по датам', 'headerIcon' => 'icon- fa fa-list-ol', 'headerButtons' => array(array('class' => 'bootstrap.widgets.TbButtonGroup', 'type' => 'success'))));
/** $this->widget('bootstrap.widgets.TbListView',array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); **/
?>
		<?php 
$this->widget('bootstrap.widgets.TbAlert', array('block' => false, 'fade' => true, 'closeText' => '&times;', 'alerts' => array('success' => array('block' => true, 'fade' => true, 'closeText' => '&times;'), 'info' => array('block' => true, 'fade' => true, 'closeText' => '&times;'), 'warning' => array('block' => true, 'fade' => true, 'closeText' => '&times;'), 'error' => array('block' => true, 'fade' => true, 'closeText' => '&times;'), 'danger' => array('block' => true, 'fade' => true, 'closeText' => '&times;'))));
?>

<?php 
$count = 1;
$expense = new MBalance();
?>
<table class="table table-hover table-bordered">
    <thead>
        <tr>
            <th></th>
            <th>Дата и время</th>
            <th>Выручка с процентом обслуживания</th>
            <th>Выручка без процентом обслуживания</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <?php 
foreach ($newModel as $value) {
    ?>
            <tr>
 public function actionMbalanceRefresh()
 {
     if (!empty($_POST)) {
         $from = $_POST['from'];
         $to = $_POST['to'];
         $days = strtotime($to) - strtotime($from);
         $newModel = Expense::model()->findAll(array('condition' => 'kind = 0', 'group' => 'date(order_date)'));
         $count = 0;
         $expense = new Expense();
         $summ = array();
         $summP = array();
         $dateList = array();
         for ($i = 0; $i < $days / (3600 * 24); $i++) {
             $mBalance = MBalance::model()->find('t.b_date = :dates', array(':dates' => date('Y-m-d', strtotime($from) + 3600 * 24 * $i)));
             $temp = $expense->getSum(date('Y-m-d', strtotime($from) + 3600 * 24 * $i));
             if (!empty($mBalance)) {
                 $mBalance->procProceeds = $temp[1];
                 $mBalance->proceeds = $temp[2];
                 $mBalance->cost = 0;
                 $mBalance->save();
             } else {
                 $mBalance = new MBalance();
                 $mBalance->b_date = date('Y-m-d', strtotime($from) + 3600 * 24 * $i);
                 $mBalance->procProceeds = $temp[1];
                 $mBalance->proceeds = $temp[2];
                 $mBalance->cost = 0;
                 $mBalance->save();
             }
         }
         $this->redirect('/');
     }
     $this->render('interval', array());
 }
 public function sumMBalance($dates)
 {
     //расчет выручки
     //$stuff = new Halfstaff();
     $sumBalance = Expense::model()->findAll('date(t.order_date) = :dates AND t.status != :status AND t.debt != :debt', array(':dates' => $dates, ':status' => 1, 'debt' => 1));
     //$debt = Debt::model()->findAll('t.d_date = :dates',array(':dates'=>$dates));
     //$debts = array();
     $dayBalance = 0;
     $expense = new Expense();
     if (!empty($sumBalance)) {
         $dayBalance = $expense->getSum($dates);
     }
     $mBalance = MBalance::model()->find('t.b_date = :dates', array(':dates' => $dates));
     if (!empty($mBalance)) {
         $mBalance = $mBalance;
     } else {
         $mBalance = new MBalance();
     }
     $mBalance->procProceeds = $dayBalance[1];
     //+$debts[1];
     $mBalance->b_date = $dates;
     $mBalance->proceeds = $dayBalance[2];
     //+$debts[2];
     $mBalance->cost = 0;
     $mBalance->save();
 }