public function getProviderName($provider_id) { $provider = Provider::model()->findByPk($provider_id); if ($provider) { return $provider->provider_name; } return 'Medlatec'; }
public function actionGetAllResult() { $columns = array(0 => 'id', 1 => 'patient_name', 2 => 'service', 3 => 'time', 4 => 'status', 5 => 'created_at', 6 => 'action'); $request = Yii::app()->request; $start = $_REQUEST['start']; $length = $_REQUEST['length']; $column = $_REQUEST['order'][0]['column']; $order = $_REQUEST['order'][0]['dir']; $where = null; $criteria = new CDbCriteria(); $criteria->order = "{$columns[$column]} {$order}"; if (!empty($_REQUEST['search']['value'])) { $criteria->addSearchCondition("patient_name", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("service", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("time", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("status", $_REQUEST['search']['value'], 'true', 'OR'); $where = true; } if (!empty(Yii::app()->session['provider_id'])) { $criteria->condition = "status >= 1 AND provider_id = " . Yii::app()->session['provider_id']; } $count = ResultMedlatec::model()->count($criteria); $criteria->limit = $length; $criteria->offset = $start; // $criteria->condition = "provider_id = " . Yii::app()->session['provider_id']; $data = ResultMedlatec::model()->findAll($criteria); $returnArr = array(); $service_name = null; $patient_name = null; foreach ($data as $item) { $order = OrderMedlatec::model()->findByPk($item->order_id); if ($order) { $service = ServiceMedlatec::model()->findByPk($order->service_id); if ($service) { $service_name = $service->service_name; } $patient_name = $order->name; } $itemArr = array(); $itemArr['id'] = $item->id; $itemArr['patient_name'] = $patient_name; $itemArr['service'] = $service_name; $itemArr['time'] = Date('d-m-Y', $item->time); $itemArr['status'] = Util::getStatusLabel($item->status); $itemArr['created_at'] = Date('d-m-Y', $item->created_at); if (empty(Yii::app()->session['provider_id'])) { $itemArr['provider_name'] = Provider::model()->getProviderName($item->provider_id); } $edit_url = Yii::app()->createUrl('result/edit', array('result_id' => $item->id)); $order_url = Yii::app()->createUrl('result/order', array('oid' => $item->order_id)); $action = '<a data-toggle="modal" href="' . $edit_url . '" data-target="#edit-order-modal" onclick="loadInfoResult(' . $item->id . ')"><span class="label label-primary">Sửa</span></a>'; $action .= ' <a data-toggle="modal" href="' . $order_url . '" data-target="#edit-order-modal" onclick="loadInfo(' . $item->order_id . ')"><span class="label label-info">Xem order</span></a>'; $itemArr['action'] = $action; $returnArr[] = $itemArr; } //$all = ResultMedlatec::model()->findAll(); echo json_encode(array('data' => $returnArr, "recordsTotal" => $count, "recordsFiltered" => count($data))); }
public function actionRegisterStaff() { $image_preview = null; $post = StringHelper::filterArrayString($_POST); if ($_FILES['image']['error'] != 4) { $image_preview = UploadHelper::getUrlUploadSingleImage($_FILES['image'], 'service_image'); $post['avatar'] = $image_preview; } if (Provider::model()->registerStaff($post)) { ResponseHelper::JsonReturnSuccess('', 'Success'); } else { ResponseHelper::JsonReturnError('', 'Error'); } }
public function actionGetAllService() { $columns = array(0 => 'id', 1 => 'service_name', 2 => 'service_price', 3 => 'favorable', 4 => 'description', 5 => 'status', 6 => 'created_at', 7 => 'updated_at', 8 => 'action'); // $request = Yii::app()->request; $start = $_REQUEST['start']; $length = $_REQUEST['length']; $column = $_REQUEST['order'][0]['column']; $order = $_REQUEST['order'][0]['dir']; $where = null; $criteria = new CDbCriteria(); if (!empty($_REQUEST['search']['value'])) { $criteria->addSearchCondition("service_name", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("service_price", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("favorable", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("description", $_REQUEST['search']['value'], 'true', 'OR'); $where = true; } if (!empty(Yii::app()->session['provider_id'])) { $criteria->condition = "provider_id = " . Yii::app()->session['provider_id']; } $count = ServiceMedlatec::model()->count($criteria); $criteria->limit = $length; $criteria->offset = $start; $criteria->order = "{$columns[$column]} {$order}"; $data = ServiceMedlatec::model()->findAll($criteria); $returnArr = array(); foreach ($data as $item) { $itemArr = array(); $itemArr['id'] = $item->id; $itemArr['service_name'] = $item->service_name; $itemArr['service_price'] = $item->service_price; $itemArr['favorable'] = $item->favorable; $itemArr['description'] = $item->description; $itemArr['status'] = Util::getStatusLabel($item->status); $itemArr['created_at'] = Date('d-m-Y', $item->created_at); $itemArr['updated_at'] = Date('d-m-Y', $item->updated_at); if (empty(Yii::app()->session['provider_id'])) { $itemArr['provider_name'] = Provider::model()->getProviderName($item->provider_id); } $edit_url = Yii::app()->createUrl('service/edit', array('service_id' => $item->id)); $action = '<a data-toggle="modal" href="' . $edit_url . '" data-target="#edit-service-modal" onclick=loadInfoService(' . $item->id . ')><span class="label label-primary">Sửa</span></a>'; $itemArr['action'] = $action; $returnArr[] = $itemArr; } // $all = ServiceMedlatec::model()->findAll(); echo json_encode(array('data' => $returnArr, "recordsTotal" => $count, "recordsFiltered" => count($data))); }
<tr> <td colspan="6" style="font-size:14pt;font-weight:bold;padding:20px;text-align:center;"> FICHA DE PROVEEDORES </td> </tr> <tr> <td style="border: 1px solid #555;"><b>Proveedor</b></td> <td style="border: 1px solid #555;"><b>Direccion</b></td> <td style="border: 1px solid #555;"><b>Telefono</b></td> <td style="border: 1px solid #555;"><b>Persona contacto</b></td> <td style="border: 1px solid #555;"><b>NRGSEAA</b></td> <td style="border: 1px solid #555;"><b>Materia primas</b></td> </tr> <?php $modelProviders = Provider::model()->findAllByAttributes(array("UserID" => Yii::app()->user->ID)); foreach ($modelProviders as $Provider) { $modelRaws = Raw::model()->findAllByAttributes(array("ProviderID" => $Provider->ID, "UserID" => Yii::app()->user->ID)); $finalRaws = ""; foreach ($modelRaws as $Raw) { $finalRaws .= $Raw->Name . ", "; } ?> <tr> <td><?php echo $Provider->Name; ?> </td> <td><?php echo $Provider->Address; ?>
public function actionGetAllOrder() { $columns = array(0 => 'id', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'requirement', 5 => 'created_at', 6 => 'status', 7 => 'action'); // $request = Yii::app()->request; $start = $_REQUEST['start']; $length = $_REQUEST['length']; $column = $_REQUEST['order'][0]['column']; $order = $_REQUEST['order'][0]['dir']; $where = null; $criteria = new CDbCriteria(); if (!empty($_REQUEST['search']['value'])) { $criteria->addSearchCondition("name", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("phone", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("email", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("requirement", $_REQUEST['search']['value'], 'true', 'OR'); $where = true; } //echo $order; $count = OrderMedlatec::model()->count($criteria); $criteria->limit = $length; $criteria->offset = $start; $criteria->order = "{$columns[$column]} {$order}"; // var_dump($start); die; $data = OrderMedlatec::model()->findAll($criteria); $returnArr = array(); foreach ($data as $item) { $itemArr = array(); $itemArr['id'] = $item->id; $itemArr['name'] = $item->name; // $itemArr['service_id'] = $item->service_id; $itemArr['phone'] = $item->phone; $itemArr['email'] = $item->email; $itemArr['requirement'] = $item->requirement; $itemArr['created_at'] = Date('d-m-Y', $item->created_at); $itemArr['status'] = $item->status; if (empty(Yii::app()->session['provider_id'])) { $itemArr['provider_name'] = Provider::model()->getProviderName($item->provider_id); } $itemArr['status_name'] = Util::getStatusLabel($item->status); // $edit_url = Yii::app()->createUrl('order/edit', array('oid' => $item->id)); // $result_url = Yii::app()->createUrl('order/result', array('oid' => $item->id)); $action = '<a data-toggle="modal" data-target="#edit-order-modal" onclick=loadInfo(' . $item->id . ')><span class="label label-primary">Sửa</span></a>'; $action .= ' <a data-toggle="modal" data-target="#delete-order-modal" onclick=loadInfoDelete(' . $item->id . ')><span class="label label-danger">Xóa</span></a>'; $action .= ' <a data-toggle="modal" data-target="#edit-order-result-modal" onclick=loadInfoResult(' . $item->id . ')><span class="label label-info">Thêm kết quả</span></a>'; $itemArr['action'] = $action; $returnArr[] = $itemArr; } // $all = OrderMedlatec::model()->findAll(); echo json_encode(array('data' => $returnArr, "recordsTotal" => $count, "recordsFiltered" => $count)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Provider the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Provider::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
echo $form->labelEx($model, 'spare_parts_status_id'); ?> <?php echo $form->dropDownList($model, 'spare_parts_status_id', CHtml::listData(SparePartsStatus::model()->findAll(array('condition' => 'active = 1', 'order' => 'description')), 'id', 'description'), array('empty' => 'Seleccionar Estado', 'options' => array(4 => array('selected' => 'selected')))); ?> <?php echo $form->error($model, 'spare_parts_status_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'provider_id'); ?> <?php echo $form->dropDownList($model, 'provider_id', CHtml::listData(Provider::model()->findAll('active = 1'), 'id', 'name'), array('empty' => 'Seleccionar Proveedor')); ?> <?php echo $form->error($model, 'provider_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 100)); ?> <?php echo $form->error($model, 'name');
<?php echo $form->hiddenField($model, 'State'); ?> <?php echo $form->hiddenField($model, 'Temperature'); ?> <?php echo $form->hiddenField($model, 'Conditions'); ?> <div class="row"> <?php echo $form->labelEx($model, 'ProviderID'); ?> <?php echo $form->dropDownList($model, 'ProviderID', CHtml::listData(Provider::model()->findAll(), 'ID', 'Name'), array('empty' => '-- Selecciona el proveedor --', 'style' => 'width: 360px;')); ?> <?php echo $form->error($model, 'ProviderID'); ?> </div> <div class="row" style="float:left;"> <?php echo $form->labelEx($model, 'Date'); ?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'Date', 'value' => $model->Date, 'options' => array('changeYear' => true, 'yearRange' => '1930', 'language' => 'es', 'dateFormat' => 'yy-mm-dd', 'monthNames' => array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"), 'monthNamesShort' => array("Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"), 'dayNames' => array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"), 'dayNamesMin' => array('Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'), 'defaultDate' => $model->Date), 'htmlOptions' => array('placeholder' => date("Y-m-d")))); ?> <?php echo $form->error($model, 'Date');
public function actionGetProvider() { $columns = array(0 => 'provider_id', 1 => 'provider_name', 2 => 'phone', 3 => 'email', 4 => 'provider_address', 5 => 'provider_image', 6 => 'created_at', 7 => 'active', 8 => 'action'); // $request = Yii::app()->request; $start = $_REQUEST['start']; $length = $_REQUEST['length']; $column = $_REQUEST['order'][0]['column']; $order = $_REQUEST['order'][0]['dir']; $where = null; $criteria = new CDbCriteria(); if (!empty($_REQUEST['search']['value'])) { $criteria->addSearchCondition("provider_name", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("phone", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("email", $_REQUEST['search']['value'], 'true', 'OR'); $criteria->addSearchCondition("provider_address", $_REQUEST['search']['value'], 'true', 'OR'); $where = true; } //echo $order; $criteria->limit = $length; $criteria->offset = $start; $criteria->order = "{$columns[$column]} {$order}"; $criteria->condition = 'active = 1 AND provider_id = ' . Yii::app()->session['provider_id']; // var_dump($start); die; $data = OrderMedlatec::model()->findAll($criteria); $returnArr = array(); foreach ($data as $item) { $itemArr = array(); $itemArr['provider_id'] = $item->id; $itemArr['provider_name'] = $item->name; $itemArr['phone'] = $item->phone; $itemArr['email'] = $item->email; $itemArr['provider_address'] = $item->requirement; $itemArr['provider_image'] = $item->requirement; $itemArr['created_at'] = $item->created_at; $itemArr['active'] = $item->status; if (empty(Yii::app()->session['provider_id'])) { $itemArr['provider_name'] = Provider::model()->getProviderName($item->provider_id); } // $edit_url = Yii::app()->createUrl('order/edit', array('oid' => $item->id)); $action = '<a data-toggle="modal" data-target="#edit-provider-modal"><span class="label label-primary">Sửa</span></a>'; $action .= ''; $itemArr['action'] = $action; $returnArr[] = $itemArr; } echo json_encode(array('data' => $returnArr, "recordsTotal" => $count, "recordsFiltered" => $count)); }