public function actionPercent() { $model = Percent::model()->find(array('order' => 't.percent_date DESC')); if ($_POST['percent']) { $transaction = Yii::app()->db->beginTransaction(); try { $messageType = 'warning'; $message = "There are some errors "; $model = new Percent(); $model->percent_date = date('Y-m-d H:i:s'); $model->percent = $_POST['percent']; if ($model->save()) { $transaction->commit(); Yii::app()->user->setFlash($messageType, $message); $this->redirect(array('site/index')); } } catch (Exception $e) { $transaction->rollBack(); Yii::app()->user->setFlash('error', "{$e->getMessage()}"); //$this->refresh(); } } $this->render('percent', array('model' => $model)); }
<th></th> <th>Дата и время</th> <th>Оплаченная дата</th> <th>Ответственный за заказ</th> <th>Стол №</th> <th>Сумма</th> <th>Процент обслуживания</th> <th>Сумма счета</th> <th>Комментарий</th> <th></th> </tr> </thead> <tbody> <?php foreach ($model as $value) { $procent = new Percent(); $percent = $procent->getPercent(date('Y-m-d', strtotime($value->getRelated('expense')->order_date))); ?> <?php if ($value->getRelated('expense')->getRelated('employee')->check_percent == 1) { $curPercent = $percent; } else { $curPercent = 0; } $temp = $expense->getExpenseSum($value->getRelated('expense')->expense_id, $value->getRelated('expense')->expense_id->order_date); ?> <tr> <td><?php echo $count; ?>
public function getPercent($dates) { $model = Percent::model()->find(array('condition' => 'percent_date <= "' . $dates . '"', 'order' => 't.percent_date DESC')); if (!empty($model)) { return $model->percent; } else { return 0; } }
public function actionAjaxEmpExpense() { $model = Expense::model()->with('employee')->findAll('date(t.order_date) = :dates AND t.employee_id = :empId', array(':dates' => $_POST['dates'], ':empId' => $_POST['empId'])); $percent = new Percent(); $this->renderPartial('ajaxEmpExpense', array('newModel' => $model, 'percent' => $percent->getPercent($_POST['dates']))); }
public function actionTodayOrder() { $dates = date('Y-m-d'); $model = Expense::model()->with('order', 'employee')->findAll('date(t.order_date) = :dates', array(':dates' => $dates)); $percent = new Percent(); $this->renderPartial('todayOrder', array('model' => $model, 'percent' => $percent->getPercent($dates))); }
public function getExpenseProcSum($id, $dates) { $percent = new Percent(); $summa = 0; $summaP = 0; $curPercent = 0; $summ = 0; $model = Expense::model()->with('employee')->findByPk($id); if (!empty($model)) { if ($model->getRelated('employee')->check_percent == 1) { $curPercent = $percent->getPercent(date('Y-m-d', strtotime($model->order_date))); } else { $curPercent = 0; } $summ = $summ + $this->getExpenseSum($model->expense_id, $dates); } $summaP = $summ / 100 * $curPercent + $summ + $summaP; $summa = $summ + $summa; return array(1 => $summaP, 2 => $summa); }
<tr> <th></th> <th>Дата и время</th> <th>Ответственный за заказ</th> <th>Стол №</th> <th>Сумма</th> <th>Процент обслуживания</th> <th>Сумма счета</th> <th>Комментарий</th> <th></th> </tr> </thead> <tbody> <?php foreach ($model as $value) { $procent = new Percent(); $percent = $procent->getPercent(date('Y-m-d', strtotime($value->order_date))); ?> <?php if ($value->getRelated('employee')->check_percent == 1) { $curPercent = $percent; } else { $curPercent = 0; } $temp = $expense->getExpenseSum($value->expense_id, $value->order_date); ?> <tr> <td><?php echo $count; ?>
<th>Сумма</th> <th>Процент на обслуживание</th> <th>Сумма счета</th> <th> </th> </tr> </thead> <tbody> <?php if (!empty($model)) { } ?> <?php foreach ($model as $value) { $curPercent = 0; $percent = new Percent(); if ($value->getRelated('employee')->check_percent == 1) { $curPercent = $percent->getPercent($value->order_date); } $temp = $expense->getExpenseSum($value->expense_id, $value->order_date); ?> <tr> <td><?php echo $counting; ?> </td> <td><?php echo $value->order_date; ?> </td> <td><?php