Ejemplo n.º 1
0
 public function actionSavePdf($id)
 {
     $subdistrbution = Subdistribution::model()->findByPk($id);
     $html = $this->actionPrint($id);
     //echo $html;
     $mPDF1 = Yii::app()->ePdf->mpdf('ar', 'A4');
     $mPDF1->WriteHTML($html);
     $mPDF1->Output($subdistrbution->code . '_vouchers.pdf', "D");
     Yii::app()->end();
 }
Ejemplo n.º 2
0
 public function actionPrint($id)
 {
     $subdistributions = Subdistribution::model()->findAll("distribution_id = :distribution_id", array(":distribution_id" => $id));
     Yii::import('application.controllers.SubdistributionController');
     $obj = new SubdistributionController("");
     $html = "";
     foreach ($subdistributions as $subdistribution) {
         $html .= $obj->actionPrint($subdistribution->id);
     }
     return $html;
 }
Ejemplo n.º 3
0
echo $form->textField($model, 'create_date');
?>
		<?php 
echo $form->error($model, 'create_date');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
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('subdistributions'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'subdistributions', GxHtml::encodeEx(GxHtml::listDataEx(Subdistribution::model()->findAllAttributes(null, true)), false, true));
?>

<?php 
echo GxHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
</div><!-- form -->
Ejemplo n.º 4
0
 <span class="required">*</span> <?php 
echo Yii::t('app', 'are required');
?>
.
	</p>

	<?php 
echo $form->errorSummary($model);
?>

		<div class="row">
		<?php 
echo $form->labelEx($model, 'subdistribution_id');
?>
		<?php 
echo $form->dropDownList($model, 'subdistribution_id', GxHtml::listDataEx(Subdistribution::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'subdistribution_id');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'type_id');
?>
		<?php 
echo $form->dropDownList($model, 'type_id', GxHtml::listDataEx(VoucherType::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'type_id');
?>
Ejemplo n.º 5
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'))));
Ejemplo n.º 6
0
 public function restEvents()
 {
     $this->onRest('req.get.GetBeneficiaryFordistribution.render', function ($distribution_id = "", $subdistribution_id = "", $include = 1, $withall = 0, $withvendor = 0) {
         $include = "not in";
         $criteria = "";
         if (isset($_GET['include']) and $_GET['include'] != 0) {
             $include = "in";
         }
         if (isset($_GET['distribution_id']) and $_GET['distribution_id'] != 0) {
             $distribution = Distribution::model()->findByPk($_GET['distribution_id']);
             $criteria = "id " . $include . " (select distinct ben_id from voucher where distribution_voucher_id in (Select id from distribution_voucher where subdistribution_id in (SELECT id FROM `subdistribution` WHERE distribution_id = " . $_GET['distribution_id'] . ")))";
             if ($_GET['withvendor'] == 1) {
                 $beneficiaries = Beneficiary::model()->findAll($criteria);
                 $count = count($beneficiaries);
                 $count_assigned = 0;
                 $returned_array = [];
                 foreach ($beneficiaries as $beneficiary) {
                     $vendor_id = $beneficiary->getVendor($_GET['distribution_id']);
                     $obj = new stdClass();
                     foreach ($beneficiary as $key => $value) {
                         $obj->{$key} = $value;
                     }
                     $obj->vendor = $vendor_id;
                     if ($obj->vendor != 0) {
                         $count_assigned += 1;
                     }
                     array_push($returned_array, $obj);
                 }
                 echo CJSON::encode(['count_beneficiaries' => $count, 'assigned_beneficiaries' => $count_assigned, 'Beneficiaries' => $returned_array]);
                 Yii::app()->end();
             }
         } elseif (isset($_GET['subdistribution_id']) and $_GET['subdistribution_id'] != 0 and $_GET['include'] != 0) {
             $criteria = "id " . $include . " (select distinct ben_id from voucher where distribution_voucher_id in (Select id from distribution_voucher where subdistribution_id  = " . $_GET['subdistribution_id'] . "))";
             if ($_GET['withall'] != 0) {
                 $included_beneficiaries = Beneficiary::model()->findAll($criteria);
                 $returned_array = [];
                 foreach ($included_beneficiaries as $beneficiary) {
                     $obj = new stdClass();
                     foreach ($beneficiary as $key => $value) {
                         $obj->{$key} = $value;
                     }
                     $obj->available = "false";
                     array_push($returned_array, $obj);
                 }
                 $count_included = count($included_beneficiaries);
                 $subdistribution = Subdistribution::model()->findByPk($_GET['subdistribution_id']);
                 $criteria = "id not in (select distinct ben_id from voucher where distribution_voucher_id in (Select id from distribution_voucher where subdistribution_id in (SELECT id FROM `subdistribution` WHERE distribution_id = " . $subdistribution->distribution_id . ")))";
                 $available_beneficiaries = Beneficiary::model()->findAll($criteria);
                 foreach ($available_beneficiaries as $beneficiary) {
                     $obj = new stdClass();
                     foreach ($beneficiary as $key => $value) {
                         $obj->{$key} = $value;
                     }
                     $obj->available = "true";
                     array_push($returned_array, $obj);
                 }
                 $count_available = count($available_beneficiaries);
                 echo CJSON::encode(['available_beneficiaries' => $count_available, 'included_beneficiaries' => $count_included, 'Beneficiaries' => $returned_array]);
                 Yii::app()->end();
             }
         } elseif (isset($_GET['subdistribution_id']) and $_GET['subdistribution_id'] != 0 and $include == 0) {
             $subdistribution = Subdistribution::model()->findByPk($_GET['subdistribution_id']);
             $criteria = "id " . $include . " (select distinct ben_id from voucher where distribution_voucher_id in (Select id from distribution_voucher where subdistribution_id in (SELECT id FROM `subdistribution` WHERE distribution_id = " . $subdistribution->distribution_id . ")))";
         }
         //echo $criteria;
         $beneficiaries = Beneficiary::model()->findAll($criteria);
         $count = count($beneficiaries);
         //$model = new Beneficiary('searchForVoucherAssignment');
         //$model->unsetAttributes();
         echo CJSON::encode(['count' => $count, 'Beneficiaries' => $beneficiaries]);
     });
 }
Ejemplo n.º 7
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('distribution-voucher-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' => 'distribution-voucher-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' => 'type_id', 'value' => 'GxHtml::valueEx($data->type)', 'filter' => GxHtml::listDataEx(VoucherType::model()->findAllAttributes(null, true))), 'expiration_date', 'create_date', 'deleted_at', array('class' => 'CButtonColumn'))));
Ejemplo n.º 8
0
<?php

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

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

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
Ejemplo n.º 9
0
	<div class="row">
		<?php 
echo $form->label($model, 'id');
?>
		<?php 
echo $form->textField($model, 'id');
?>
	</div>

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

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

	<div class="row">
		<?php 
echo $form->label($model, 'expiration_date');
Ejemplo n.º 10
0
 public function actionGenerate()
 {
     $model = new Beneficiary('searchForVoucherAssignment');
     $model->unsetAttributes();
     if (isset($_POST) && !empty($_POST)) {
         $subdistribution = Subdistribution::model()->findByPk($_POST['subdistribution_id']);
         if ($subdistribution) {
             // getting Voucher Types assosiated to this distribution.
             $distributionVouchers = $subdistribution->distributionVouchers;
             // getting The 'PENDING' status
             $criteria = new CDbCriteria();
             $criteria->addCondition('name="PENDING"');
             // created Status for vouchers
             $status = VoucherStatus::model()->find($criteria);
             // Choose eligible beneficiaries -- who are not registered in this distribution (Not sub distribution)
             $criteria3 = new CDbCriteria();
             $criteria_string = "t.id in (0";
             if (isset($_POST['beneficiaries']) && !empty($_POST['beneficiaries'])) {
                 foreach ($_POST['beneficiaries'] as $ben_id) {
                     $criteria_string = $criteria_string . ", " . $ben_id;
                 }
             }
             $criteria_string = $criteria_string . ")";
             $criteria3->addCondition($criteria_string);
             $beneficiaries = Beneficiary::model()->findAll($criteria3);
             $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
             $random_string_length = 10;
             foreach ($beneficiaries as $beneficiary) {
                 // for each beneficiary
                 foreach ($distributionVouchers as $distributionVoucher) {
                     // for each voucher type
                     //try to find an existing voucher assosiated to this beneficiary
                     $criteria4 = new CDbCriteria();
                     $criteria4->condition = "ben_id = " . $beneficiary->id . " and distribution_voucher_id = " . $distributionVoucher->id;
                     $exist = Voucher::model()->findAll($criteria4);
                     // if no voucher found :
                     if (count($exist) == 0) {
                         $voucher = new Voucher();
                         // create voucher
                         $string = '';
                         $exist = "";
                         //Generate random number
                         do {
                             for ($i = 0; $i < $random_string_length; $i++) {
                                 $string .= $characters[rand(0, strlen($characters) - 1)];
                             }
                             $exist = Voucher::model()->exists('code =:code', array(":code" => $string));
                         } while ($exist == "1");
                         $voucher->code = $string;
                         $voucher->distribution_voucher_id = $distributionVoucher->id;
                         $voucher->ben_id = $beneficiary->id;
                         $voucher->vendor = NULL;
                         $voucher->status_id = $status->id;
                         $voucher->create_date = new CDbExpression('NOW()');
                         $voucher->insert();
                         $voucher->save();
                     }
                 }
             }
         }
     } else {
         if (isset($_GET['Beneficiary'])) {
             $model->setAttributes($_GET['Beneficiary']);
         }
         $this->render('generate', array('model' => $model));
         //$this->render('generate');
     }
 }