Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Information();
     //                $model->scenario = 'information';
     if (isset($_POST['Information'])) {
         $model->attributes = $_POST['Information'];
         $rnd = rand(0, 9999);
         // generate random number between 0-9999
         $uploadedFile = CUploadedFile::getInstance($model, 'image');
         if ($uploadedFile) {
             $fileName = "{$rnd}-{$uploadedFile}";
             // random number + file name
             $model->image = $fileName;
         }
         //                    var_dump($_POST['Information']['description']);exit;
         $model->user_id = yii::app()->user->id;
         $phone = Phone::model()->findByPk($_POST['phone']);
         $model->phone = $phone->phone;
         $user = Users::model()->findByPk(yii::app()->user->id);
         //            var_dump($user->email);exit;
         $model->email = $user->email;
         $location = Location::model()->findByPk($_POST['location']);
         $model->location = $location->location;
         $model->normal = "Normal";
         $model->description = str_replace("\r\n", "<br />", $_POST['Information']['description']);
         $t = time();
         $model->time = date("Y-m-d", $t);
         if ($model->save()) {
             if ($uploadedFile) {
                 $uploadedFile->saveAs(Yii::app()->basePath . '/../banner/' . $fileName);
                 // image will uplode to rootDirectory/banner/
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #2
0
<!--	<div class="row">
		<?php 
// echo $form->label($model,'phone');
?>
		<?php 
// echo $form->textField($model,'phone',array('size'=>60,'maxlength'=>256));
?>
	</div>-->
    <div class="form-group row">
        <?php 
echo $form->label($model, 'phone', array('class' => 'control-label'));
?>
        <div class="leb">
    <?php 
$records = Phone::model()->findAll(array('order' => 'phone'));
echo $form->dropDownList($model, 'phone', CHtml::listData($records, 'phone', 'phone'), array('empty' => 'Select Model', 'class' => 'form-control-drop'));
?>
        </div>
    </div>
	<div class="row buttons">
		<?php 
echo CHtml::submitButton('Որոնել', array('class' => 'btn btn-success'));
?>
	</div>

<?php 
$this->endWidget();
?>

</div><!-- search-form -->
Example #3
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Manage'));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('vendor-mobile-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2));
?>
</h1>

<p>
You may optionally enter a comparison operator (&lt;, &lt;=, &gt;, &gt;=, &lt;&gt; or =) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php 
echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'vendor-mobile-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'subdistribution_id', 'value' => 'GxHtml::valueEx($data->subdistribution)', 'filter' => GxHtml::listDataEx(Subdistribution::model()->findAllAttributes(null, true))), array('name' => 'vendor_id', 'value' => 'GxHtml::valueEx($data->vendor)', 'filter' => GxHtml::listDataEx(Vendor::model()->findAllAttributes(null, true))), array('name' => 'phone_id', 'value' => 'GxHtml::valueEx($data->phone)', 'filter' => GxHtml::listDataEx(Phone::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn'))));
Example #4
0
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'vendor_id');
?>
		<?php 
echo $form->dropDownList($model, 'vendor_id', GxHtml::listDataEx(Vendor::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'vendor_id');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'phone_id');
?>
		<?php 
echo $form->dropDownList($model, 'phone_id', GxHtml::listDataEx(Phone::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'phone_id');
?>
		</div><!-- row -->


<?php 
echo GxHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
</div><!-- form -->
 /**
  * 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 Phone the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Phone::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #6
0
	<div class="row">
		<?php 
echo $form->label($model, 'vendor_id');
?>
		<?php 
echo $form->dropDownList($model, 'vendor_id', GxHtml::listDataEx(Vendor::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'phone_id');
?>
		<?php 
echo $form->dropDownList($model, 'phone_id', GxHtml::listDataEx(Phone::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row buttons">
		<?php 
echo GxHtml::submitButton(Yii::t('app', 'Search'));
?>
	</div>

<?php 
$this->endWidget();
?>

</div><!-- search-form -->
Example #7
0
 public function actionsync()
 {
     $this->layout = false;
     $return = [];
     $error = 0;
     $lang = 'en';
     $error_count = 0;
     $sync_count = 0;
     $in_array = array('en', 'ar', 'tr');
     $history_intry = new VoucherHistory();
     $history_intry->action = VoucherAction::model()->find("name = 'SYNC'")->id;
     if (isset($_POST) && !empty($_POST)) {
         // IMPORT MOBILE DATA
         $post = "";
         //foreach ($_POST as $key => $value) {
         //    $post .= $key . " => " . $value . "/";
         //}
         $history_intry->parameters = $post;
         if (isset($_POST['lang']) && !empty($_POST['lang']) && in_array($_POST['lang'], $in_array)) {
             $lang = filter_input(INPUT_GET, "lang", FILTER_SANITIZE_STRING);
         }
         if (!isset($_POST['redeemed_voucher']) || empty($_POST['redeemed_voucher'])) {
             $this->respond('ERR_INVALID_REEQUEST', [], $lang, $history_intry);
         }
         if (!isset($_POST['imei']) || empty($_POST['imei'])) {
             $this->respond('ERR_INVALID_REEQUEST', [], $lang, $history_intry);
         }
         $voucher_codes = $_POST['redeemed_voucher'];
         $redeem_redeemed_status = VoucherStatus::model()->find("name = :name", array(":name" => "REDEEMED"));
         foreach ($voucher_codes as $voucher_code) {
             $voucher = Voucher::model()->find("code = :code", array(":code" => $voucher_code));
             if (!$voucher) {
                 $error_count += 1;
                 $error .= $voucher_code . ", ";
             } else {
                 $voucher->status_id = $redeem_redeemed_status->id;
                 $voucher->sync_date = new CDbExpression('NOW()');
                 $voucher->update();
                 $voucher->save();
                 $sync_count += 1;
             }
         }
         if ($error_count > 0) {
             $err_arr = [];
             $err_arr['count'] = $error_count;
             $err_arr['vouchers'] = $error;
             $this->respond("NOT_ALL_SYNCED", $err_arr, $lang, $history_intry);
         } else {
             $this->respond(NULL, $sync_count, $lang, $history_intry);
         }
     } elseif (isset($_GET) && !empty($_GET)) {
         // SEND NEW DATA
         $get = "";
         foreach ($_GET as $key => $value) {
             $get .= $key . " => " . $value . "/";
         }
         $history_intry->parameters = $get;
         if (!isset($_GET['imei']) || empty($_GET['imei'])) {
             $this->respond('ERR_INVALID_REEQUEST', [], $lang, $history_intry);
         }
         if (isset($_GET['lang']) && !empty($_GET['lang']) && in_array($_GET['lang'], $in_array)) {
             $lang = filter_input(INPUT_GET, "lang", FILTER_SANITIZE_STRING);
         }
         $imei = $_GET['imei'];
         $phone = Phone::model()->find("imei = :imei", array(":imei" => $imei));
         if (!$phone) {
             $this->respond('ERR_INVALID_REEQUEST', [], $lang, $history_intry);
         }
         $vendor_mobiles = VendorMobile::model()->findAll("phone_id = :phone_id", array(":phone_id" => $phone->id));
         $export_list = [];
         $update_list = [];
         foreach ($vendor_mobiles as $vendor_mobile) {
             $voucher_status = VoucherStatus::model()->find("name = :name", array(":name" => "PENDING"));
             $vouchers = Voucher::model()->findAll("status_id = :status_id and vendor_id = :vendor_id", array(":status_id" => $voucher_status->id, ":vendor_id" => $vendor_mobile->vendor_id));
             //print_r($vouchers);
             foreach ($vouchers as $voucher) {
                 $obj = new stdClass();
                 if ($voucher->distributionVoucher->subdistribution->distribution->id == $vendor_mobile->distribution_id) {
                     foreach ($voucher as $key => $value) {
                         $obj->{$key} = $value;
                     }
                     $beneficiary = Beneficiary::model()->findByPk($voucher->ben_id);
                     if ($beneficiary->registration_code) {
                         $obj->registration_code = $beneficiary->registration_code;
                     }
                     $subdistribution = $voucher->distributionVoucher->subdistribution;
                     $obj->start_date = $subdistribution->start_date;
                     $obj->expiration_date = $subdistribution->end_date;
                     $obj->status_name = $voucher->status->name;
                     array_push($export_list, $obj);
                     array_push($update_list, $voucher);
                 }
             }
         }
         $this->respond(NULL, $export_list, $lang, $history_intry, false);
         foreach ($update_list as $item) {
             $in_mobile_status = VoucherStatus::model()->find("name = 'IN_MOBILE'");
             $item->status_id = $in_mobile_status->id;
             $item->update();
             $item->save();
         }
         Yii::app()->end();
     } else {
         $this->respond('ERR_INVALID_REEQUEST', [], $lang, NULL);
     }
 }