/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Products::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'number' => $this->number]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Products::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } //$query->joinWith('Categories'); $query->joinWith('pIdC0'); $query->andFilterWhere(['productCode' => $this->productCode, 'createdDate' => $this->createdDate, 'updatedDate' => $this->updatedDate]); $query->andFilterWhere(['like', 'productName', $this->productName])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'categories.categoryName', $this->categoryId]); return $dataProvider; }
/* @var $form yii\widgets\ActiveForm */ ?> <div class="dyim-inner"> <div class="add_sale_item_fields"> <div class="row"> <!--row 1--> <div class="col-md-4"> <div class="form-group"> <label class="control-label" for="vendorproducts-productid<?php echo $cnt; ?> ">Product Name</label> <?php echo Html::activeDropDownList($model, 'productId', ArrayHelper::map(Products::find()->all(), 'productCode', 'productName'), ['prompt' => 'Select Product', 'class' => 'form-control', 'id' => 'vendorproducts-productid' . $cnt]); ?> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="control-label" for="vendorproducts-brand<?php echo $cnt; ?> ">Brand</label> <?php echo Html::activeDropDownList($model, 'Brand', ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand', 'class' => 'form-control', 'id' => 'vendorproducts-brand' . $cnt]); ?> </div> </div>
?> </div></div> <div class="col-xs-6 col-sm-4 p5"> <div class="ml20"> <?php echo $form->field($model, 'sda_type_id', array('labelOptions' => array('class' => 'f18', 'label' => 'SDA Type')))->dropDownList(ArrayHelper::map(SdaTypes::find()->orderBy(['sda_name' => SORT_ASC])->asArray()->all(), 'id', 'sda_name'), ['class' => 'form-control intp', 'selection' => $model->sda_type_id]); ?> </div> </div> <div class="col-xs-6 col-sm-4 p5"> <div class="ml20"> <?php echo $form->field($model, 'product', array('labelOptions' => array('class' => 'f18', 'label' => 'Product')))->dropDownList(ArrayHelper::map(Products::find()->orderBy(['name' => SORT_ASC])->asArray()->all(), 'id', 'name'), ['class' => 'form-control intp', 'selection' => $model->product]); ?> </div> </div> <div class="col-xs-6 col-sm-4 p5"> <div class="ml20"> <?php echo $form->field($model, 'session', array('labelOptions' => array('class' => 'f18')))->textInput(['class' => 'form-control intp']); ?> </div></div> <div class="col-xs-6 col-sm-4 p5"> <div class="ml20"> <?php echo $form->field($model, 'poster_board_no', array('labelOptions' => array('class' => 'f18')))->textInput(['class' => 'form-control intp']);
public function actionProductItem($id) { header('Content-type: application/json'); $product = Products::find($id)->one(); $productItem = ['id' => $product->id, 'name' => $product->name, 'description' => $product->description, 'number' => $product->number]; echo json_encode($productItem); }
<input type="checkbox" class="chkcls" name="storeIds" id="chkcls<?php echo $model['Saleid']; ?> " value="<?php echo $model['Saleid']; ?> " > </label> </div></td> <td><?php echo $key; ?> </td> <?php $productName = Products::find()->select('productName')->where(['productCode' => $model['productId']])->one(); ?> <td><div class="actualvals acvals<?php echo $model['Saleid']; ?> " ><?php echo $productName['productName']; ?> </div></td> <td><div class="actualval acval<?php echo $model['Saleid']; ?> " ><?php echo $model['Brand']; ?> </div><div class="inpval inval<?php
use yii\widgets\ActiveForm; use backend\models\Brandsmaster; use backend\models\Products; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model backend\models\ProductsBrands */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="products-brands-form"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'productId')->dropDownList(ArrayHelper::map(Products::find()->all(), 'id', 'productName'), ['prompt' => 'Select Product']); ?> <?php echo $form->field($model, 'brandId')->dropDownList(ArrayHelper::map(Brandsmaster::find()->all(), 'brandId', 'brandName'), ['prompt' => 'Select Brand']); ?> <?php echo $form->field($model, 'file')->fileInput(); ?> <?php echo $form->field($model, 'productupdateImage')->hiddenInput(['value' => $model->productImage]); ?> <?php
/** * Import SDA in CSV format * @return mixed */ public function actionExcel() { $model = new Sda(); if ($model->load(Yii::$app->request->post())) { $row = 1; $congid = $_POST['Sda']['id']; $model->fileName = UploadedFile::getInstance($model, 'fileName'); $time = time(); $model->fileName->saveAs('csv/' . $time . '.' . $model->fileName->extension); $model->fileName = 'csv/' . $time . '.' . $model->fileName->extension; $requiredHeaders = array('Title', 'Abstract #', 'Priority', 'Abstract', 'Assigned to', 'Date', 'Product', 'Session Start Time', 'Session End Time', 'Presentation Start Time', 'Presentation End Time', 'Presenter', 'SDA type', 'Location', 'Category', 'Session id', 'Session #', 'Authors', 'Company', 'Team', 'Link to Poster', 'Poster Board Number', 'Presentation Number'); $f = fopen($model->fileName, 'r'); $firstLine = fgets($f); //get first line of csv file fclose($f); $foundHeaders = array_map('trim', str_getcsv(trim($firstLine), ',', '"')); //parse to array $result = array_diff_assoc($foundHeaders, $requiredHeaders); $csverrormessage = implode(",", $result); if ($foundHeaders !== $requiredHeaders) { \Yii::$app->getSession()->setFlash('error', 'CSV is in incorrect for ' . $csverrormessage . ' Column'); } else { $handle = fopen($model->fileName, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $row++; // Getting Product id $product = \backend\models\Products::find()->where(['name' => $data[6]])->one(); $product = isset($product['id']) ? $product['id'] : ''; // Getting Priority ID $priority_name = SdaPriority::find()->where(['priority_name' => $data[2]])->one(); $priority_name = isset($priority_name['id']) ? $priority_name['id'] : '3'; // Getting Sda Type ID $sdatype = SdaTypes::find()->where(['sda_name' => $data[12]])->one(); $sdatype = isset($sdatype['id']) ? $sdatype['id'] : '9'; $cmp = CompanyDetails::find()->where(['name' => $data[18]])->one(); $cmp = isset($cmp['id']) ? $cmp['id'] : '2'; if ($row == 2) { //ignoring } else { $title = Yii::$app->db->quoteValue($data[0]); $abstracthash = Yii::$app->db->quoteValue($data[1]); $abstract = Yii::$app->db->quoteValue($data[3]); $amgenatten = explode(',', $data[4]); $date = Yii::$app->db->quoteValue(date("Y-m-d H:i:s", strtotime($data[5]))); $prod = Yii::$app->db->quoteValue($product); if (!empty($data[7])) { $sessiostart = Yii::$app->db->quoteValue(date("H:i:s", strtotime($data[7]))); } else { $sessiostart = "null"; } if (!empty($data[8])) { $sessionend = Yii::$app->db->quoteValue(date("H:i:s", strtotime($data[8]))); } else { $sessionend = "null"; } if (!empty($data[9])) { $presentationstart = Yii::$app->db->quoteValue(date("H:i:s", strtotime($data[9]))); } else { $presentationstart = "null"; } if (!empty($data[10])) { $presentationend = Yii::$app->db->quoteValue(date("H:i:s", strtotime($data[10]))); } else { $presentationend = "null"; } $presenter = Yii::$app->db->quoteValue($data[11]); $location = Yii::$app->db->quoteValue($data[13]); $category = Yii::$app->db->quoteValue($data[14]); $session = Yii::$app->db->quoteValue($data[15]); $sessionhash = Yii::$app->db->quoteValue($data[16]); $authors = Yii::$app->db->quoteValue($data[17]); $team = Yii::$app->db->quoteValue($data[19]); $linktoposter = Yii::$app->db->quoteValue($data[20]); $posterboard = Yii::$app->db->quoteValue($data[21]); $presentationno = Yii::$app->db->quoteValue($data[22]); if ($title) { $sql = "insert into sda(\n congress_id,\n title,\n abstract_id,\n priority,\n abstract,\n date,\n session_start_time,\n session_end_time,\n presentation_start_time,\n presentation_end_time,\n presenter,\n sda_type_id,\n product,\n location,\n category,\n session_id,\n session,\n authors,\n company_id,\n team,\n link_to_poster,\n poster_board_no,\n presentation_no\n )" . " values (" . "'{$congid}'," . "{$title}," . "{$abstracthash}," . "'{$priority_name}'," . "{$abstract}," . "{$date}," . "{$sessiostart}," . "{$sessionend}," . "{$presentationstart}," . "{$presentationend}," . "{$presenter}," . "'{$sdatype}'," . "'{$product}'," . "{$location}," . "{$category}," . "{$session}," . "{$sessionhash}," . "{$authors}," . "'{$cmp}'," . "{$team}," . "{$linktoposter}," . "{$posterboard}," . "{$presentationno})"; //save the data Yii::$app->db->createCommand($sql)->execute(); $sdaId = Yii::$app->db->getLastInsertID(); if (count($amgenatten) > 0) { foreach ($amgenatten as $value) { $value = trim($value); $amgenattendee = explode(' ', $value); if (!empty($amgenattendee[0]) && !empty($amgenattendee[1])) { $attendeeexits = \backend\models\AmgenContactList::find()->where(['first_name' => $amgenattendee[0], 'last_name' => $amgenattendee[1]])->one(); if ($attendeeexits) { $modelSdaSchedule = new \backend\models\SdaSchedules(); $modelSdaSchedule->sda_id = $sdaId; $modelSdaSchedule->congress_id = $congid; $modelSdaSchedule->attendee_id = $attendeeexits->id; $modelSdaSchedule->assigned = 0; $modelSdaSchedule->save(false); } } } } } } } fclose($handle); Yii::$app->getSession()->setFlash('success', 'All SDA is Uploaded Successfully'); } } return $this->render('excel', ['model' => $model]); }
echo $form->field($model, 'sda_type_id', array('labelOptions' => array('class' => 'sr-only', 'label' => 'SDA Type')))->dropDownList(ArrayHelper::map(SdaTypes::find()->orderBy(['sda_name' => SORT_ASC])->asArray()->all(), 'id', 'sda_name'), ['class' => 'form-control', 'selection' => $model->sda_type_id, 'prompt' => 'Select SDA Type']); ?> <?php echo $form->field($model, 'presentation_no', ['labelOptions' => ['class' => 'sr-only']])->textInput(['maxlength' => '100', 'class' => 'form-control', 'placeholder' => $model->getAttributeLabel('presentation_no')]); ?> </div> </div> <div class="container"> <div class="row"> <?php echo $form->field($model, 'session_id', ['labelOptions' => ['class' => 'sr-only']])->textInput(['maxlength' => '100', 'class' => 'form-control', 'placeholder' => $model->getAttributeLabel('session_id')]); ?> <?php echo $form->field($model, 'product', array('labelOptions' => array('class' => 'sr-only', 'label' => 'Product')))->dropDownList(ArrayHelper::map(Products::find()->orderBy(['name' => SORT_ASC])->asArray()->all(), 'id', 'name'), ['maxlength' => '100', 'class' => 'form-control', 'selection' => $model->product, 'prompt' => 'Select Product']); ?> </div> </div> <div class="container"> <div class="row"> <?php echo $form->field($model, 'poster_board_no', ['labelOptions' => ['class' => 'sr-only']])->textInput(['maxlength' => '100', 'class' => 'form-control', 'placeholder' => $model->getAttributeLabel('poster_board_no')]); ?> <?php echo $form->field($model, 'priority', array('labelOptions' => array('class' => 'sr-only', 'label' => 'Product')))->dropDownList(ArrayHelper::map(SdaPriority::find()->asArray()->all(), 'id', 'priority_name'), ['id' => 'sda-priority', 'class' => 'form-control', 'selection' => $model->priority, 'prompt' => 'Select Priority']); ?> </div> </div>
public static function getProductId($name) { $productInfo = Products::find()->select(['id'])->where(['productName' => $name])->one(); return $productInfo; }