Example #1
0
 public function actionAdmin()
 {
     $model = new VendorMobile('search');
     $model->unsetAttributes();
     if (isset($_GET['VendorMobile'])) {
         $model->setAttributes($_GET['VendorMobile']);
     }
     $this->render('admin', array('model' => $model));
 }
Example #2
0
echo $form->labelEx($model, 'deleted_at');
?>
		<?php 
echo $form->textField($model, 'deleted_at');
?>
		<?php 
echo $form->error($model, 'deleted_at');
?>
		</div><!-- row -->

		<label><?php 
echo GxHtml::encode($model->getRelationLabel('vendorMobiles'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'vendorMobiles', GxHtml::encodeEx(GxHtml::listDataEx(VendorMobile::model()->findAllAttributes(null, true)), false, true));
?>
		<label><?php 
echo GxHtml::encode($model->getRelationLabel('vendorNotes'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'vendorNotes', GxHtml::encodeEx(GxHtml::listDataEx(VendorNote::model()->findAllAttributes(null, true)), false, true));
?>
		<label><?php 
echo GxHtml::encode($model->getRelationLabel('vouchers'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'vouchers', GxHtml::encodeEx(GxHtml::listDataEx(Voucher::model()->findAllAttributes(null, true)), false, true));
?>
Example #3
0
<?php

$this->breadcrumbs = array(VendorMobile::label(2), Yii::t('app', 'Index'));
$this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . VendorMobile::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . VendorMobile::label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode(VendorMobile::label(2));
?>
</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
Example #4
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);
     }
 }