Пример #1
0
 public function actionUpdate($id)
 {
     $model = new SettingsForm();
     if (isset($_POST['SettingsForm'])) {
         $model->attributes = $_POST['SettingsForm'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromStore($id);
     }
     $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
     $themes = array();
     foreach ($directories as $directory) {
         $themes[] = basename($directory);
     }
     $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
     $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
     $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
     $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
     $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
     $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
     $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
     $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
     $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
     $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
     $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
     // TODO: localisation
     $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
     // TODO: localisation
     $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
     $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
     $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
 }
Пример #2
0
 public function actionTreeFill()
 {
     $id = !isset($_GET['root']) ? 'source' : $_GET['root'];
     $dataTree = array();
     if ($id == 'source') {
         $root = Zone::model()->findByPk(0);
     } else {
         $root = Zone::model()->findByPk($id);
     }
     foreach ($root->children as $child) {
         $dataTree[] = array('id' => $child->zid, 'text' => CHtml::link($child->name, array('/zone/view/id/' . $child->zid)), 'collapsed' => $child->zid != 0, 'hasChildren' => true);
     }
     echo CTreeView::saveDataAsJson($dataTree);
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $zone = Zone::model()->findAllByAttributes(array('district_id' => $id));
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['District'])) {
         $model->attributes = $_POST['District'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'zone' => $zone));
 }
Пример #4
0
 public function actionUpdate($id)
 {
     $model = Zone::model()->findByPk($id);
     if (!is_object($model)) {
         throw new CException("Specified zone doesn't exists.");
         return;
     }
     if (isset($_POST['Zone'])) {
         $model->attributes = $_POST['Zone'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     }
     $statusOptions = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled'));
     $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
     $this->render('update', array('model' => $model, 'statusOptions' => $statusOptions, 'countries' => $countries));
 }
Пример #5
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel($id);
         // check child
         $zone = Zone::model()->find('state_id=?', array($model->id));
         if ($zone == NULL) {
             $model->delete();
         } else {
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Пример #6
0
 public function beforeDelete()
 {
     $project = project::model()->findAll();
     $zone = Zone::model()->findAll();
     foreach ($project as $id => $item) {
         $projects = explode('|', $item->country_id);
         if (in_array($this->country_id, array_values($projects))) {
             Yii::app()->setFlashMessage('Can not delete, Country in use in project master', 'error');
             return false;
         }
     }
     foreach ($zone as $id => $item) {
         $zones = explode('|', $item->country_id);
         if (in_array($this->country_id, array_values($zones))) {
             Yii::app()->setFlashMessage('Can not delete, Country in use in zone master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
Пример #7
0
 public static function getZone($id)
 {
     return Zone::model()->findByPk($id);
 }
Пример #8
0
 public function getRows($pq)
 {
     $rows = $pq->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
     $n = count($rows);
     echo 'Jumlah propinsi: ' . $n . " \n";
     $count = 0;
     foreach ($rows as $value) {
         $count++;
         $row = pq($value);
         $kolom_provinsi = $row->find('td:eq(1) > a');
         $nama_provinsi = $kolom_provinsi->text();
         $link_provinsi = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolom_provinsi->attr('href')) . '&perhal=1000';
         echo sprintf("Memproses propinsi %d dari %d\n", $count, $n);
         echo sprintf("Propinsi: %s Link: %s\n", $nama_provinsi, $link_provinsi);
         $province = Province::model()->findByAttributes(array('name' => $nama_provinsi));
         if (!$province instanceof Province) {
             $province = new Province();
             $province->name = $nama_provinsi;
             if (!$province->save()) {
                 throw new CException('Cannot save province');
             }
         }
         $countdistrict = 0;
         $pqDist = phpQuery::newDocumentHtml($this->getContents($link_provinsi));
         $rowsDist = $pqDist->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
         $nDist = count($rowsDist);
         $countDist = 0;
         foreach ($rowsDist as $valueDist) {
             $countDist++;
             $rowDist = pq($valueDist);
             switch ($rowDist->find('td:eq(2)')->text()) {
                 case 'Kota':
                     $tipeDist = 'kota';
                     break;
                 default:
                 case 'Kab.':
                     $tipeDist = 'kabupaten';
                     break;
             }
             $kolomDist = $rowDist->find('td:eq(3) > a');
             $namaDist = $kolomDist->text();
             $linkDist = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomDist->attr('href')) . '&perhal=1000';
             echo sprintf("Memproses distrik " . $province->name . " %d dari %d\n", $countDist, $nDist);
             echo sprintf("Distrik: %s Link: %s\n", $namaDist, $linkDist);
             $distrik = District::model()->findByAttributes(array('name' => $namaDist, 'province_id' => $province->id, 'type' => $tipeDist));
             if (!$distrik instanceof District) {
                 $distrik = new District();
                 $distrik->name = $namaDist;
                 $distrik->type = $tipeDist;
                 $distrik->province_id = $province->id;
                 if (!$distrik->save()) {
                     throw new CException('Cannot save district');
                 }
             }
             $pqZone = phpQuery::newDocumentHtml($this->getContents($linkDist));
             $rowsZone = $pqZone->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
             $nZone = count($rowsZone);
             $countZone = 0;
             foreach ($rowsZone as $valueZone) {
                 $countZone++;
                 $rowZone = pq($valueZone);
                 $kolomZone = $rowZone->find('td:eq(4) > a');
                 $namaZone = $kolomZone->text();
                 $linkZone = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomZone->attr('href')) . '&perhal=1000';
                 echo sprintf("Memproses zone  %d dari %d\n", $countZone, $nZone);
                 echo sprintf("zone: %s Link: %s\n", $namaZone, $linkZone);
                 $new_zone = false;
                 $zone = Zone::model()->findByAttributes(array('name' => $namaZone, 'district_id' => $distrik->id));
                 if (!$zone instanceof Zone) {
                     $zone = new Zone();
                     $zone->name = $namaZone;
                     $zone->active = 1;
                     $zone->district_id = $distrik->id;
                     if (!$zone->save()) {
                         throw new CException('Cannot save Zone');
                     }
                     $new_zone = true;
                 }
                 echo 'sukses saving zone' . "\n";
                 $countArea = 0;
                 $pqArea = phpQuery::newDocumentHtml($this->getContents($linkZone));
                 $rowsArea = $pqArea->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
                 $nArea = count($rowsArea);
                 // Let's speed up things a bit
                 $trans = Yii::app()->db->beginTransaction();
                 foreach ($rowsArea as $valueArea) {
                     $countArea++;
                     $rowArea = pq($valueArea);
                     $kolomArea = $rowArea->find('td:eq(2) > a');
                     $kolomKodePos = $rowArea->find('td:eq(1)');
                     $namaArea = $kolomArea->text();
                     $kodePos = $kolomKodePos->text();
                     $linkKodePos = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomArea->attr('href')) . '&perhal=1000';
                     $area = $new_zone ? null : Area::model()->findByAttributes(array('name' => $namaArea, 'zone_id' => $zone->id));
                     if (!$area instanceof Area) {
                         $area = new Area();
                         $area->name = $namaArea;
                         $area->postcode = $kodePos;
                         $area->zone_id = $zone->id;
                         if (!$area->save()) {
                             throw new CException('Cannot save area');
                         }
                     }
                     echo 'Sukses Saving Code Post' . "/n kode pos adalah " . $area->postcode . "\n";
                 }
                 $trans->commit();
             }
         }
     }
 }
Пример #9
0
		<?php 
echo $form->labelEx($model, "[{$id}]country_id");
?>
		<?php 
echo $form->dropDownList($model, "[{$id}]country_id", CHtml::listData(Country::model()->findAll('', 'id', 'name'), 'id', 'name'), array('ajax' => array('type' => 'POST', 'url' => $this->createUrl('zones') . "id/{$id}", 'update' => '#CheckoutAddress_' . $id . '_zone_id')));
?>
		<?php 
echo $form->error($model, "[{$id}]country_id");
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, "[{$id}]zone_id");
?>
		<?php 
echo $form->dropDownList($model, "[{$id}]zone_id", CHtml::listData(Zone::model()->findAll('', 'id', 'name'), 'id', 'name'));
?>
		<?php 
echo $form->error($model, "[{$id}]zone_id");
?>
		</div><!-- row -->


<?php 
$this->endWidget();
?>
</div><!-- form -->
<div class="uid hide"><a href="<?php 
echo $this->createUrl('delete', array('id' => $model->id));
?>
" class="del-link"></a><a href="<?php 
Пример #10
0
		<?php 
echo $form->labelEx($model, "[{$id}]country_id");
?>
		<?php 
echo $form->dropDownList($model, "[{$id}]country_id", CHtml::listData(Country::model()->findAll(''), 'id', 'name'), array('ajax' => array('type' => 'POST', 'url' => $this->createUrl('zones') . "id/{$id}", 'update' => '#CheckoutAddress_' . $id . '_zone_id')));
?>
		<?php 
echo $form->error($model, "[{$id}]country_id");
?>
		</div><!-- row-fluid -->
		<div class="row-fluid">
		<?php 
echo $form->labelEx($model, "[{$id}]zone_id");
?>
		<?php 
echo $form->dropDownList($model, "[{$id}]zone_id", CHtml::listData(Zone::model()->findAll('country_id=:country_id', array(':country_id' => $c_id)), 'id', 'name'));
?>
		<?php 
echo $form->error($model, "[{$id}]zone_id");
?>
		</div><!-- row-fluid -->


<?php 
$this->endWidget();
?>
</div><!-- form -->
<div class="uid hide"><a href="<?php 
echo $this->createUrl('delete', array('id' => $model->id));
?>
" class="del-link"></a><a href="<?php 
Пример #11
0
 /**
  * Modify User POST
  */
 function modzone()
 {
     $clang = Yii::app()->lang;
     $zone_name = flattenText(Yii::app()->request->getPost("zone_name"));
     $z_name = flattenText(Yii::app()->request->getPost("z_name"));
     $zone_id = (int) Yii::app()->request->getPost("zone_id");
     $z_id = (int) Yii::app()->request->getPost("z_id");
     $c_id = (int) Yii::app()->request->getPost("c_id");
     $IsActive = flattenText(Yii::app()->request->getPost("IsActive"));
     $addsummary = '';
     $aViewUrls = array();
     $is_Active = 0;
     if ($IsActive) {
         $is_Active = 1;
     }
     $sresult = Zone::model()->findAllByAttributes(array('zone_id' => $zone_id));
     $sresultcount = count($sresult);
     if (Permission::model()->hasGlobalPermission('superadmin', 'read') || $sresultcount > 0 && Permission::model()->hasGlobalPermission('Regions', 'update')) {
         if ($z_name == '') {
             $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing zone"), $clang->gT("Could not modify zone."), "warningheader", $clang->gT("Zone  name not be empty."), $this->getController()->createUrl('admin/zone/modifyzone'), $clang->gT("Back"), array('zone_id' => $zone_id));
         } elseif (Zone::model()->findByAttributes(array('zone_Name' => $z_name, 'IsActive' => $is_Active), 'country_id=:country_id', array(':country_id' => $c_id))) {
             $aViewUrls['message'] = array('title' => $clang->gT("Failed to add Zone"), 'message' => $clang->gT("The Zone already exists."), 'class' => 'warningheader');
         } else {
             $oRecord = Zone::model()->findByPk($zone_id);
             $oRecord->zone_Name = $this->escape($z_name);
             $oRecord->country_id = $this->escape($c_id);
             $oRecord->IsActive = $this->escape($is_Active);
             $uresult = $oRecord->save();
             // store result of save in uresult
             if ($uresult) {
                 // When saved successfully
                 Yii::app()->setFlashMessage($clang->gT("Zone updated successfully"));
                 $this->getController()->redirect(array("admin/zone/index"));
             } else {
                 //Saving the user failed for some reason, message about email is not helpful here
                 // Username and/or email adress already exists.
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing zone"), $clang->gT("Could not modify zone."), 'warningheader');
             }
         }
     } else {
         Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
     }
     $this->_renderWrappedTemplate('region/Zone', $aViewUrls);
 }
Пример #12
0
 protected function getRootZone($rootId)
 {
     return Zone::model()->findByPk(isset($rootId) && $rootId != 'source' ? $rootId : 0);
 }
Пример #13
0
    ?>
            </td>
            <td align="right" style="text-align: right;">
                <label for='zone'>
                    <a href="<?php 
    echo CController::createUrl('admin/zone/index');
    ?>
" target="_blank"><?php 
    $clang->eT("Zone* : ");
    ?>
</a>
                </label>
            </td>
            <td>
                <?php 
    $zone = Zone::model()->findAll('country_id=:country_id', array(':country_id' => (int) $mrw["country_id"]));
    $zonelist = CHtml::listData($zone, 'zone_id', 'zone_Name');
    echo CHtml::dropDownList('zonelist', $mrw['zone_id'], $zonelist, array('ajax' => array('type' => 'POST', 'data' => array('action' => 'selectstate', 'zone_name' => 'js:this.value'), 'url' => CController::createUrl('admin/contact/sa/selectstate'), 'update' => '#statelist')));
    ?>
            </td>
        </tr>
        <tr>
            <td align="right" style="text-align: right;">
                <label for='state'>
                    <a href="<?php 
    echo CController::createUrl('admin/state/index');
    ?>
" target="_blank"><?php 
    $clang->eT("State* : ");
    ?>
</a>
Пример #14
0
 public function actionZones($id)
 {
     //echo 'post is'.$id;
     if (Yii::app()->getRequest()->getIsAjaxRequest() && isset($id)) {
         $data = Zone::model()->findAll('country_id=:country_id', array(':country_id' => (int) $_POST['CheckoutAddress'][$id]['country_id']));
         $data = CHtml::listData($data, 'id', 'name');
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     } else {
         throw new CHttpException(400, Yii::t('info', 'Your request is invalid.'));
     }
 }
Пример #15
0
    <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'place-of-offence-form', 'enableAjaxValidation' => false));
?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

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

            <?php 
echo $form->textFieldControlGroup($model, 'place', array('span' => 5, 'maxlength' => 145));
?>

            <?php 
echo $form->dropDownListControlGroup($model, 'zone_id', CHtml::listData(Zone::model()->findAll(array('order' => 'id ASC')), 'id', 'zone'), array('span' => 5));
?>
      

            <?php 
echo $form->textFieldControlGroup($model, 'police_station_id', array('span' => 5));
?>
            
            <div id="select_district" >
                <label>Select District</label>
                <?php 
//echo $form->dropDownList($model,'district_id',CHtml::listData(District::model()->findAllByAttributes(array('states_id'=>$model->state_id),array('order' => 'name ASC')), 'id', 'name'),array('empty'=>'---Select State first---','span'=>5));
?>
                <?php 
echo $form->dropDownList($model, 'state_id', CHtml::listData(States::model()->findAllByPk(array(19, 7, 32)), 'id', 'name'), array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('placeOfPosting/courts'), 'update' => '#PlaceOfOffence_court_id', 'data' => array('state_id' => 'js:this.value')), 'empty' => 'Select District'), array('span' => 5));
?>
Пример #16
0
 public function getZoneToolTips($postcode)
 {
     if (!$postcode) {
         $postcode = $this->postcode;
     }
     $areas = Yii::app()->db->createCommand()->select('*')->from('area')->where('postcode = ' . $postcode)->queryAll();
     foreach ($areas as $area) {
         $namaArea[$area['id']][Zone::model()->findByPk($area['zone_id'])->name] = $area['name'];
     }
     foreach ($namaArea as $value) {
         foreach ($value as $key => $value) {
             $returnArray[$key][] = $value;
         }
     }
     foreach ($returnArray as $key => $value) {
         $return[] = array($key => $value);
     }
     return $return;
 }
Пример #17
0
    <table class='users'>
        <tr class='oddrow'>
            <th><?php 
    $clang->eT("Add city:");
    ?>
</th>
            <td style='width:20%'>
                <input type='text' maxlength="50" name='new_city' />
                <input type='Hidden' name='country_name' value="<?php 
    echo (int) $country_id;
    ?>
" />
            </td>
            <td>
                <?php 
    $region = Zone::model()->isactive()->findAll('country_id=:country_id', array(':country_id' => (int) $country_id), array('condition' => "IsActive = 1"));
    $reglist = CHtml::listData($region, 'zone_id', 'zone_Name');
    echo CHtml::dropDownList('zonelist', 'zone_id', $reglist, array('prompt' => 'Select zone', 'ajax' => array('type' => 'POST', 'data' => array('action' => 'selectstate', 'zonelist' => 'js:this.value', 'isactive' => '1'), 'url' => CController::createUrl('admin/city/sa/selectstate'), 'update' => '#statelist')));
    ?>
            </td>
            <td>
                <?php 
    echo CHtml::dropDownList('statelist', '', array('stateselect' => 'Select state'));
    ?>
            </td>
            <td style='width:15%'><input type='submit' value='<?php 
    $clang->eT("Save");
    ?>
' />
                <input type='hidden' name='action' value='addcity' /></td>
        </tr>
Пример #18
0
 function selectzone()
 {
     if (isset($_POST['isactive'])) {
         $data = Zone::model()->isactive()->findAll('country_id=:country_id', array(':country_id' => (int) $_POST['country_name']));
     } else {
         $data = Zone::model()->findAll('country_id=:country_id', array(':country_id' => (int) $_POST['country_name']));
     }
     $data = CHtml::listData($data, 'zone_id', 'zone_Name');
     if (count($data)) {
         echo CHtml::tag('option', array('value' => '0'), CHtml::encode('Select zone...'), true);
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     } else {
         echo CHtml::tag('option', array('value' => '0'), CHtml::encode('No State available'), true);
     }
     $state = CHtml::tag('option', array('value' => '0'), CHtml::encode('Select state...'), true);
     $city = CHtml::tag('option', array('value' => '0'), CHtml::encode('Select city...'), true);
     echo "<script language='javascript' type='text/javascript'>\n                \$('#statelist').html('" . $state . "');\n                \$('#citylist').html('" . $city . "');\n            </script>";
 }
Пример #19
0
 public function actionPayment($id)
 {
     $cart = $this->getCart();
     $add = CheckoutAddress::model()->findByPk($id);
     $link;
     $onlinePaymentMethodName;
     $extrapObj = array();
     $orderArray = array();
     $classArray = array();
     if (!empty($add) && !empty($cart['items'])) {
         if (isset($_POST['Payment']['payment_method'])) {
             $pay_method = $_POST['Payment']['payment_method'];
             $cart['payment'] = $pay_method == 4 ? 2 : $pay_method;
             $paymentType = is_numeric($pay_method) ? 'others' : 'online';
             $order = new Order();
             $order->order_status_id = 1;
             $order->total = $this->getCartTotal();
             $order->ip = Yii::app()->request->userHostAddress;
             $order->user_agent = Yii::app()->request->userAgent;
             $order->firstname = $add->firstname;
             $order->lastname = $add->lastname;
             $order->email = $add->email;
             $order->telephone = $add->telephone;
             $order->payment_firstname = $add->firstname;
             $order->payment_lastname = $add->lastname;
             $order->payment_company = '';
             $order->payment_tax_id = 0;
             $order->payment_address_1 = $add->address_1;
             $order->payment_address_2 = $add->address_2;
             $order->payment_city = $add->city;
             $order->payment_postcode = $add->postal_code;
             $order->payment_country_id = $add->country_id;
             $order->payment_zone_id = $add->zone_id;
             $order->payment_method = $cart['payment'];
             $order->payment_code = uniqid() . rand(1, 9);
             $order->shipping_firstname = $add->firstname;
             $order->shipping_lastname = $add->lastname;
             $order->shipping_company = '';
             $order->shipping_address_1 = $add->address_1;
             $order->shipping_address_2 = $add->address_2;
             $order->shipping_city = $add->city;
             $order->shipping_postcode = $add->postal_code;
             $order->shipping_country_id = $add->country_id;
             $order->shipping_zone_id = $add->zone_id;
             $order->shipping_method = 2;
             if ($add->zone_id == 2412) {
                 $order->shipping_method = 1;
             }
             $storeid = UtilityHelper::yiiparam('storeID');
             $store = Store::model()->findByPk($storeid);
             $order->store_id = $storeid;
             $order->store_name = $store->name;
             $order->store_url = $store->url;
             $order->payment_country = Country::model()->findByPk($order->payment_country_id)->name;
             $order->payment_zone = Zone::model()->findByPk($order->payment_zone_id)->name;
             $order->shipping_country = $order->payment_country;
             $order->shipping_zone = $order->payment_zone;
             if ($order->save()) {
                 foreach ($cart['items'] as $product) {
                     $orderproduct = new OrderProduct();
                     $orderproduct->order_id = $order->id;
                     $orderproduct->product_id = $product['product_id'];
                     $orderproduct->name = $product['name'];
                     $orderproduct->model = $product['model'];
                     $orderproduct->quantity = $product['quantity'];
                     $orderproduct->price = $product['price'];
                     $orderproduct->total = $product['total'];
                     $orderproduct->tax = 0;
                     if ($orderproduct->save()) {
                         if (!empty($product['option'])) {
                             foreach ($product['option'] as $orderoption) {
                                 $orderoption->order_id = $order->id;
                                 $orderoption->order_product_id = $orderproduct->id;
                                 $orderoption->save();
                             }
                         }
                     } else {
                         Yii::log("CartPaymentOrderProductErrors: " . CVarDumper::dumpAsString($orderproduct->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment");
                     }
                 }
                 //Yii::app()->user->setState('user_cart', NULL);
                 $extrap = array();
                 //
                 switch ($paymentType) {
                     case 'others':
                         // Will need to loop through the ids for non online payment to do this properly
                         if ($pay_method == 1) {
                             $link = '_cash';
                             $extrap = array('orderID' => $order->id, 'total' => $order->total);
                             UtilityHelper::changeOrderStatus($order->id);
                         } else {
                             if ($pay_method == 3) {
                                 $link = '_bank';
                                 $extrap = array('orderID' => $order->id, 'total' => $order->total);
                             }
                         }
                         break;
                     case 'online':
                         $subClasses = new PaymentGatewayHelper();
                         $subClassesArray = $subClasses->getSubClasses();
                         foreach ($subClassesArray as $class => $payOption) {
                             ${$class} = new $class();
                             $onlinePaymentMethodName = ${$class}->getPaymentName();
                             if ($pay_method == $onlinePaymentMethodName) {
                                 $link = ${$class}->getViewLink();
                                 ${$class}->setOrderObj($order);
                                 $extrapObj = ${$class}->getOrderObj();
                                 foreach ($extrapObj as $field => $value) {
                                     $orderArray[$field] = $value;
                                 }
                                 $link = ${$class}->getViewLink();
                                 $extrap = array('orderID' => $orderArray['id'], 'total' => $orderArray['total']);
                                 ${$class}->regPaymentTransaction($order);
                                 $classArray['pay_method'] = $pay_method;
                             } else {
                                 continue;
                             }
                         }
                         break;
                     default:
                         break;
                 }
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray), false, true);
                     Yii::app()->end();
                 }
                 $this->render($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray));
                 Yii::app()->end();
             } else {
                 Yii::log("CartPaymentErrors: " . CVarDumper::dumpAsString($order->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment");
             }
         }
         if (Yii::app()->getRequest()->getIsAjaxRequest()) {
             $this->renderPartial('_payment', array('app' => $add), false, true);
             Yii::app()->end();
         }
         $this->render('payment', array('app' => $add));
         Yii::app()->end();
     }
     $this->redirect(array('cart'));
 }
Пример #20
0
</div>
			<div class="span8"><?php 
echo $form->textField($model, 'postal_code', array('maxlength' => 10));
?>
			<?php 
echo $form->error($model, 'postal_code');
?>
</div>
			</div><!-- row -->
			<div class="row-fluid">
			<div class="span4"><?php 
echo $form->labelEx($model, 'zone_id');
?>
</div>
			<div class="span8"><?php 
echo $form->dropDownList($model, 'zone_id', CHtml::listData(Zone::model()->findAll('country_id=:country_id', array(':country_id' => 156), 'id', 'name'), 'id', 'name'));
?>
			<?php 
echo $form->error($model, 'zone_id');
?>
</div>
			</div><!-- row -->
			<input name="id" type="hidden" value="<?php 
echo $model->id;
?>
" />
		</div>
	</div>
	
	<?php 
if (!empty($address)) {
Пример #21
0
		<?php 
echo $form->labelEx($model, 'country_id');
?>
		<?php 
echo $form->dropDownList($model, 'country_id', GxHtml::listDataEx(Country::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'country_id');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'zone_id');
?>
		<?php 
echo $form->dropDownList($model, 'zone_id', GxHtml::listDataEx(Zone::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'zone_id');
?>
		</div><!-- row -->


<?php 
echo GxHtml::submitButton('Save');
$this->endWidget();
?>
</div><!-- form -->
<div class="uid hide"><a href="<?php 
echo $this->createUrl('delete', array('id' => $model->id));
?>
Пример #22
0
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Zone::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #23
0
 function selectzone()
 {
     //$data = Zone::model()->findAll('country_id=:country_id', array(':country_id' => (int) $_POST['country_Name']));
     if (isset($_POST['isactive'])) {
         $data = Zone::model()->isactive()->findAllByAttributes(array('country_id' => (int) $_POST['country_name']));
     } else {
         $data = Zone::model()->findAllByAttributes(array('country_id' => (int) $_POST['country_name']));
     }
     $data = CHtml::listData($data, 'zone_id', 'zone_Name');
     if (count($data)) {
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     } else {
         echo CHtml::tag('option', array('value' => '0'), CHtml::encode('No Zone available'), true);
     }
 }
Пример #24
0
$cs->registerScriptFile($baseUrl . '/js/jspdf/libs/base64.js');
$this->menu = array(array('label' => 'List Issued Books', 'url' => array('index')), array('label' => 'Issue a Book', 'url' => array('create')));
?>
<h1>All offences with fine details</h1>

<p>
    
</p>
<div class="wide form">

    <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
?>
	<label>Select Zone</label>
    <?php 
echo $form->dropDownList($model, 'zone', CHtml::listData(Zone::model()->findAll(array('order' => 'zone ASC')), 'id', 'zone'), array('empty' => '--All Zones--', 'span' => 5, 'maxlength' => 145, 'options' => array($_GET['Challan']['zone'] => array('selected' => true))));
?>
                    

        <div class="form-actions">
        <?php 
echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
    </div>

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

</div><!-- search-form -->
Пример #25
0
 public function actionZones()
 {
     if (isset($_POST['Order']['shipping_country_id'])) {
         $id = (int) $_POST['Order']['shipping_country_id'];
     } else {
         if (isset($_POST['Order']['payment_country_id'])) {
             $id = (int) $_POST['Order']['payment_country_id'];
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest() && isset($id)) {
         $data = Zone::model()->findAll('country_id=:country_id', array(':country_id' => $id));
         $data = CHtml::listData($data, 'id', 'name');
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     } else {
         throw new CHttpException(400, Yii::t('info', 'Your request is invalid.'));
     }
 }