コード例 #1
0
ファイル: MyAccount.php プロジェクト: xepan/commerce
 function setModel($model)
 {
     //action menu item
     $myaccount_btn = $this->add('View', null, 'myaccount')->setElement('a')->setAttr('data-type', 'myaccount')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->setAttr('href', $this->app->url(null, ['selectedmenu' => 'myaccount']))->set('My Account');
     $order_btn = $this->add('View', null, 'order')->setElement('a')->setAttr('data-type', 'order')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->setAttr('href', $this->app->url(null, ['selectedmenu' => 'order']))->set('Order History');
     $mydesign_btn = $this->add('View', null, 'mydesign')->setElement('a')->setAttr('data-type', 'mydesign')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->setAttr('href', $this->app->url(null, ['selectedmenu' => 'mydesign']))->set('My Design');
     $mytemplate_btn = $this->add('View', null, 'mytemplate')->setElement('a')->setAttr('data-type', 'mytemplate')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->setAttr('href', $this->app->url(null, ['selectedmenu' => 'mytemplate']))->set('My Template');
     $setting_btn = $this->add('View', null, 'setting')->setElement('a')->setAttr('data-type', 'setting')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->setAttr('href', $this->app->url(null, ['selectedmenu' => 'setting']))->set('Settings');
     // $mydesign_btn = $this->add('View',null,'mydesign')->setElement('a')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->set('My Designs')->setAttr('data-type','mydesign');
     // $mytemplate_btn = $this->add('View',null,'mytemplate')->setElement('button')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->set('My Templates')->setAttr('data-type','mytemplate');
     // $setting_btn = $this->add('View',null,'setting')->setElement('button')->addClass('xepan-commerce-myaccount-action btn btn-block btn-primary')->set('Settings')->setAttr('data-type','setting');
     $this->js(true)->_selector(".xepan-commerce-myaccount-action[data-type='" . $_GET['selectedmenu'] . "']")->closest('div')->addClass('active');
     //Default selected Menu
     if (!($selected_menu = $this->app->stickyGET('selectedmenu'))) {
         $selected_menu = 'myaccount';
     }
     ${$selected_menu . "_btn"}->addClass('active');
     //My Account Info
     if ($selected_menu == "myaccount") {
         //remove extra tab spot
         $this->template->tryDel('order_wrapper');
         $this->template->tryDel('mydesign_wrapper');
         $this->template->tryDel('setting_wrapper');
         $this->template->tryDel('mytemplate_wrapper');
         //all email set at spot emails and lister template define at  email layout
         if (!$model->ref('Emails')->count()->getOne()) {
             $this->template->tryDel('email_wrapper');
         } else {
             $email_lister = $this->add('CompleteLister', null, 'emails', ['view\\tool\\' . $this->options['layout'], 'email_layout']);
             $email_lister->setModel($model->ref('Emails'));
         }
         if (!$model->ref('Phones')->count()->getOne()) {
             $this->template->tryDel('Contact_wrapper');
         } else {
             $contact_lister = $this->add('CompleteLister', null, 'contacts', ['view\\tool\\' . $this->options['layout'], 'contact_layout']);
             $contact_lister->setModel($model->ref('Phones'));
         }
         //Recent Order
         $recent_order = $this->add('xepan\\commerce\\Model_SalesOrder')->addCondition('contact_id', $model->id)->setOrder('id', 'desc')->setLimit(5);
         $this->add('xepan\\base\\Grid', null, 'recentorder', ['view/tool/myaccount-resent-order'])->setModel($recent_order, ['document_no', 'created_at', 'total_amount', 'gross_amount', 'net_amount']);
     } elseif ($selected_menu == "order") {
         $this->template->tryDel('mydesign_wrapper');
         $this->template->tryDel('setting_wrapper');
         $this->template->tryDel('myaccount_wrapper');
         $this->template->tryDel('mytemplate_wrapper');
         $order = $this->add('xepan\\commerce\\Model_SalesOrder')->addCondition('contact_id', $model->id)->setOrder('id', 'desc');
         $order_grid = $this->add('xepan\\base\\Grid', null, 'order_history', ['view/tool/myaccount-resent-order']);
         $order_grid->setModel($order, ['document_no', 'created_at', 'total_amount', 'gross_amount', 'net_amount']);
         $order_grid->addQuickSearch(['document_no']);
     } elseif ($selected_menu == "mydesign") {
         $this->template->tryDel('order_wrapper');
         $this->template->tryDel('setting_wrapper');
         $this->template->tryDel('myaccount_wrapper');
         $this->template->tryDel('mytemplate_wrapper');
         // my_designs
         $this->add('xepan/commerce/View_CustomerDesign', array('options' => $this->options), 'my_designs');
     } elseif ($selected_menu == "setting") {
         $this->template->tryDel('mydesign_wrapper');
         $this->template->tryDel('order_wrapper');
         $this->template->tryDel('myaccount_wrapper');
         $this->template->tryDel('mytemplate_wrapper');
         $this->add('xepan\\commerce\\View_MyAccountSetting', array('options' => $this->options), 'settings');
     } elseif ($selected_menu == "mytemplate") {
         $this->template->tryDel('mydesign_wrapper');
         $this->template->tryDel('order_wrapper');
         $this->template->tryDel('myaccount_wrapper');
         $this->template->tryDel('setting_wrapper');
         $this->add('xepan/commerce/View_CustomerTemplate', array('options' => $this->options), 'my_templates');
     }
     $this_url = $this->api->url(null, ['cut_object' => $this->name]);
     //Js For Reloading the Right Column and passed the type value
     // return $this->js('click')->_selector('.button.xepan-commerce-myaccount-action')->univ()
     //             ->location($this->app->url(null,['selectedmenu'=>$data['type']]));
     $this->template->trySet('member_address', empty($model['address']) ? "Update Your information" : $model['address']);
     $this->template->trySet('member_billing_address', empty($model['billing_address']) ? "Update Your information" : $model['billing_address']);
     $this->template->trySet('member_shipping_address', empty($model['shipping_address']) ? "Update Your information" : $model['shipping_address']);
     parent::setModel($model);
 }
コード例 #2
0
ファイル: PostDetail.php プロジェクト: xepan/blog
 function setModel($model)
 {
     $this->template->trySetHtml('comment_count', $model['comment_count']);
     $this->template->trySetHtml('post_description', $model['description']);
     parent::setModel($model);
 }
コード例 #3
0
ファイル: Detail.php プロジェクト: xepan/commerce
 function setModel($model)
 {
     //tryset html for description
     $this->template->trySetHtml('item_description', $model['description']);
     $this->template->trySetHtml('name', $model['name']);
     //specification
     $spec_grid = $this->add('xepan\\base\\Grid', null, 'specification', ["view/tool/item/detail/" . $this->options['specification_layout']]);
     $spec_grid->setModel($model->specification()->addCondition('is_system', '<>', true), ['name', 'value']);
     //add personalized button
     if ($model['is_designable']) {
         // add Personalioze View
         $personalized_page_url = $this->app->url($this->options['personalized_page'], ['xsnb_design_item_id' => $model['id']]);
         $this->add('Button', null, 'personalizedbtn')->addClass("xepan-commerce-item-personalize btn btn-primary btn-block")->set($this->options['personalized_button_label'] ?: "Personalize")->js('click', $this->js()->univ()->location($personalized_page_url));
     } else {
         $this->current_row_html['personalizedbtn'] = "";
         $this->current_row_html['personalizedbtn_wrapper'] = "";
     }
     //price calculation or add to cart button setup
     //if item is designable than hide "AddToCart" button
     if ($model['is_saleable']) {
         $options = ['button_name' => $this->options['addtocart_button_label'], 'show_addtocart_button' => $model['is_designable'] ? 0 : 1, 'show_price' => $this->options['show_price_or_amount'], 'show_multi_step_form' => $this->options['show_multi_step_form'], 'form_layout' => $this->options['multi_step_form_layout'], 'show_shipping_charge' => $this->options['show_shipping_charge'], 'shipping_charge_with_item_amount' => $this->options['shipping_charge_with_item_amount'], 'checkout_page' => $this->options['checkout_page'], 'continue_shopping_page' => $this->options['continue_shopping_page'], 'amount_group_in_multistepform' => $this->options['amount_group_in_multistepform']];
         $cart_btn = $this->add('xepan\\commerce\\Tool_Item_AddToCartButton', ['name' => "addtocart_view_" . $model->id, 'options' => $options], 'Addtocart');
         $cart_btn->setModel($model);
     }
     //add Item Uploadable
     // if($model['is_allowuploadable'] and $this->options['show_item_upload']){
     // 	// $contact = $this->add('xepan/base/Model_Contact');
     //  //    		if(!$contact->loadLoggedIn()){
     //  //  			//Todo add login panle here
     // 	// 	$this->add('View_Error',null,'item_upload')->set('add Login Panel Here');
     // 	// 	return;
     //  //    		}
     //  //    		$member_image=$this->add('xepan/commerce/Model_Designer_Images');
     // 	// $images_count = 1;
     // 	// if($model['upload_file_label']){
     // 	// 	$upload_array=explode(',', $model['upload_file_label']);
     // 	// 	$images_count = count($upload_array);
     // 	// }
     // 	$v = $this->add('View',null,'item_upload');
     // 	$this->api->stickyGET('show_cart');
     // 	if($_GET['show_cart']){
     // 		$v->add('Button')->setLabel('Back')->js('click',$v->js()->reload(array('show_cart'=>0)));
     // 		$options = [
     // 				'button_name'=>$this->options['addtocart_button_label'],
     // 				'show_addtocart_button'=>$model['is_designable']?0:1,
     // 				'show_price'=>$this->options['show_price_or_amount'],
     // 				'form_layout'=>$this->options['multi_step_form_layout'],
     // 				'show_original_price'=>$this->options['show_original_price']
     // 				];
     // 		$cart_btn = $v->add('xepan\commerce\Tool_Item_AddToCartButton',
     // 			[
     // 				'name' => "addtocart_view_".$model->id,
     // 				'options'=>$options
     // 			]);
     // 		$cart_btn->setModel($model);
     // 	}else{
     // 		$v->add('View')->setHTML($model['item_specific_upload_hint']);
     // 		$up_form = $v->add('Form');
     // 		$multi_upload_field = $up_form->addField('Upload','upload',"")
     // 				->allowMultiple($images_count)
     // 				->setFormatFilesTemplate('view/tool/item/detail/file_upload');
     // 		$multi_upload_field->setAttr('accept','.jpeg,.png,.jpg');
     // 		$multi_upload_field->setModel('filestore/Image');
     // 		$up_form->addSubmit('Next');
     // 		if($up_form->isSubmitted()){
     // 			//check for the image count
     // 			$upload_images_array = explode(",",$up_form['upload']);
     // 			if($images_count != count($upload_images_array))
     // 				$up_form->error('upload','upload all images');
     // 			$image_cat_model = $this->add('xepan\commerce\Model_Designer_Image_Category')->loadCategory($model['name']);
     // 			foreach ($upload_images_array as $file_id) {
     // 			    $image_model = $this->add('xepan/commerce/Model_Designer_Images');
     // 				$image_model['file_id'] = $file_id;
     // 				$image_model['designer_category_id'] = $image_cat_model->id;
     // 				$image_model->saveAndUnload();
     // 			}
     // 			$up_form->js(null,$v->js()->reload(array('show_cart'=>1,'file_upload_ids'=>$up_form['upload'])))->execute();
     // 		}
     // 	}
     // }
     parent::setModel($model);
 }