/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new EntrySheetPaidAmount(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['EntrySheetPaidAmount'])) { $model->attributes = $_POST['EntrySheetPaidAmount']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionEntrySheetMain() { if (isset($_POST['EntrySheetBulk'])) { foreach ($_POST['EntrySheetBulk'] as $i => $item) { $model = new EntrySheetBulk(); $model->attributes = $_POST['EntrySheetBulk'][$i]; if ($model->selected && $model->quantity > 0) { CVarDumper::dump($_POST['EntrySheetBulk'][0]['date'], 10, true); $model->date = date("Y-m-d", strtotime($_POST['EntrySheetBulk'][0]['date'])); $modelEntrySheet = new EntrySheet(); $entrySheet = new EntrySheet(); $entrySheet->customer_id = $_POST['customer_id']; $entrySheet->product_id = $model->product_id; $entrySheet->quantity = $model->quantity; $entrySheet->price = $model->price; $entrySheet->added_on = $model->date; $entrySheet->save(); } if (isset($_POST['EntrySheetPaidAmount'])) { $entrySheetAmountPaid = new EntrySheetPaidAmount(); $entrySheetAmountPaid->attributes = $_POST['EntrySheetPaidAmount']; $entrySheetAmountPaid->customer_id = $_POST['customer_id']; $entrySheetAmountPaid->added_on = $model->date; $entrySheetAmountPaid->save(); } } $this->redirect(array('entrySheet/admin')); } $this->render('entrySheetMain'); }