Esempio n. 1
0
 function getActivityByMinutes($productId)
 {
     $timezonestimestamp = gmt_to_local(local_to_gmt(), $this->config->item('timezones'));
     $timezonestime = date('Y-m-d H:i:m', $timezonestimestamp);
     $all_ret = array();
     $version = "all";
     for ($i = 29; $i >= 0; $i--) {
         $all_size = 0;
         $dataStr = date('Y-m-d-H-i', strtotime("-{$i} minutes", strtotime($timezonestime)));
         $allAcs = $this->redis->keys("razor_r_ac_p_" . $productId . "_" . $dataStr . "*");
         if ($allAcs && count($allAcs) > 0) {
             for ($k = 0; $k < count($allAcs); $k++) {
                 $key = $allAcs[$k];
                 $len = $this->redis->hlen($key);
                 $all_size += $len;
             }
         }
         if ($i == 0) {
             $onlinedata = array('minutes' => lang("v_rpt_realtime_now"), 'size' => $all_size);
         } else {
             $onlinedata = array('minutes' => "- " . $i . lang("v_rpt_realtime_minutes"), 'size' => $all_size);
         }
         array_push($all_ret, $onlinedata);
     }
     return json_encode($all_ret);
 }
Esempio n. 2
0
 function addFaq()
 {
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     if ($this->input->post('addFaq')) {
         //Set rules
         $this->form_validation->set_rules('question', 'Question', 'required|trim|xss_clean');
         $this->form_validation->set_rules('faq_content', 'Answer', 'required|trim');
         if ($this->form_validation->run()) {
             //prepare insert data
             $insertData = array();
             $insertData['question'] = $this->input->post('question');
             $insertData['faq_content'] = $this->input->post('faq_content', false);
             $insertData['created'] = local_to_gmt();
             //Add Groups
             $this->faq_model->addfaq($insertData);
             //Notification message
             $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('success', translate_admin('FAQ added successfully')));
             redirect_admin('faq/viewFaqs');
         }
     }
     //If - Form Submission End
     //Load View
     $data['message_element'] = 'administrator/faq/addFaq';
     $this->load->view('administrator/admin_template', $data);
 }
Esempio n. 3
0
 public function mobileCode()
 {
     $post = $this->input->post();
     $mobile = $post['mobile'];
     $this->load->helper('string');
     $this->load->model('sms');
     $this->load->model('validation');
     if (!preg_mobile($mobile)) {
         echo json_encode(array('code' => '1002', 'msg' => '错误的手机号码'));
         exit;
     }
     $code = mt_rand(100000, 999999);
     $msg = "您好!您验证手机号所需的验证码为" . $code . ",请勿泄露给任何人,30分钟内有效。";
     if ($this->sms->send($mobile, $msg)) {
         $this->validation->delete_by(array('mobile' => $mobile));
         if ($this->validation->insert(array('mobile' => $mobile, 'code' => $code, 'expires' => local_to_gmt() + 1800))) {
             echo json_encode(array('code' => '1000'));
             exit;
         }
     } else {
         echo json_encode(array('code' => '1002', 'msg' => '发送失败,请稍候重试'));
         exit;
     }
     echo json_encode(array('code' => '1001', 'msg' => '发生错误'));
 }
Esempio n. 4
0
 /**
  * Loads Add Admin key.
  *
  * @access	private
  * @param	nil
  * @return	void
  */
 public function addAdmin_key()
 {
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     if ($this->input->post('addAdmin_key')) {
         //Set rules
         $this->form_validation->set_rules('Admin_key', 'Page_key', 'required|trim|xss_clean');
         //$this->form_validation->set_rules('page_ref.','page_ref.','required|trim|xss_clean');
         if ($this->form_validation->run()) {
             //prepare insert data
             $insertData = array();
             $insertData['page_key'] = $this->input->post('Admin_key');
             $insertData['page_refer'] = $this->input->post('page_ref');
             $insertData['status'] = $this->input->post('is_footer');
             $insertData['created'] = local_to_gmt();
             if ($this->Common_model->getTableData('admin_key', array('status' => 0))->num_rows() == 0 && $insertData['status'] == 0) {
                 //Add Groups
                 $this->Admin_key_model->addAdmin_key($insertData);
                 //Notification message
                 $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('success', translate_admin('Admin Key added successfully')));
             } else {
                 $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate_admin('Sorry! Already another Admin Key in active state.')));
             }
             redirect_admin('admin_key/viewAdmin_key');
         }
     }
     //If - Form Submission End
     //Get Faq Categories
     $data['Admin_key'] = $this->Admin_key_model->getAdmin_keys();
     $data['message_element'] = "administrator/admin_key/addAdmin_key";
     $this->load->view('administrator/admin_template', $data);
 }
Esempio n. 5
0
 function getTransRateByTime($productId)
 {
     $r = $this->getTargetListByProductId($productId);
     $num = $r->num_rows();
     $ret = array();
     $nret = array();
     foreach ($r->result() as $row) {
         $transEvents = $this->getTransEventsIdByTargetId($row->tid);
         $event_from = $transEvents["from"];
         $event_to = $transEvents["to"];
         $timezonestimestamp = gmt_to_local(local_to_gmt(), $this->config->item('timezones'));
         $timezonestime = date('Y-m-d H:i:m', $timezonestimestamp);
         $from_count = 0;
         $to_count = 0;
         for ($i = 29; $i >= 0; $i--) {
             $dataStr = date('Y-m-d-H-i', strtotime("-{$i} minutes", strtotime($timezonestime)));
             $from_size = $this->redis->get("razor_r_p_e_" . $productId . "_" . $event_from . "_" . $dataStr);
             $from_count += $from_size;
             $to_size = $this->redis->get("razor_r_p_e_" . $productId . "_" . $event_to . "_" . $dataStr);
             $to_count += $to_size;
             if ($from_count == 0) {
                 $rate = 0;
             } else {
                 $rate = $to_count / $from_count;
             }
         }
         $r = array('name' => $row->targetname, 'time' => '-' . $i . lang("v_rpt_realtime_minutes"), 'from_count' => $from_count, 'to_count' => $to_count, 'rate' => $rate, 'event_to' => $event_to);
         if ($to_count == 0) {
             continue;
         }
         array_push($ret, $r);
     }
     return $ret;
 }
Esempio n. 6
0
function current_time($timezone, $daylight_saving)
{
    $time = time();
    $gmt = local_to_gmt($time);
    $local = gmt_to_local($gmt, $timezone, $daylight_saving);
    return standard_date("DATE_RFC822", $local);
}
Esempio n. 7
0
 public function index()
 {
     $data = array();
     $show_count = 3;
     //首页展示楼层数量
     $this->load->model('user');
     $this->load->model('product');
     $this->load->model('product_category');
     $this->load->model('product_category_map');
     $this->load->model('newss');
     $this->load->model('link');
     $this->load->model('product_brand');
     $this->load->model('ad');
     $this->load->model('order');
     $this->load->model('coupon');
     $product_cate = $this->product_category->get_level_tree();
     //树状产品类型
     /*	
     		if($product_cate){
     			foreach ($product_cate as $key => $item) {
     				$cate_id_ary = $this->product_category->get_all_children($item['id']);
     				$ids = array($item['id']);
     				foreach ($cate_id_ary as $k => $v) {
     					$ids[] = $v;
     				}
     
     				$hot_product = $this->product_category_map->get_product_by_cate($ids);	//首页展示的商品
     				$brand = $this->product_brand->get_by_cateid($item['id']); 				//首页商品区展示的品牌
     				$product_cate[$key]['hot_product'] = $hot_product;
     				// $product_cate[$key]['product_cate_brand'] = $brand;
     				if($key == ($show_count-1))	//只展示前三楼
     					break;
     			}
     		}
     */
     //$handpick_product = $this->product->lists(8,'','',array('handpick = 1'));
     //$data['handpick_product'] = $handpick_product;
     $data['show_count'] = $show_count;
     $data['product_cate'] = $product_cate;
     $data['news'] = $this->newss->lists(array("status='1' or (status='2' and show_time < " . local_to_gmt() . ")", "cate_id='1'"), 5, "a.show_time desc");
     //按发布时间
     $data['vip_news'] = $this->newss->lists(array("status='1' or (status='2' and show_time < " . local_to_gmt() . ")", "cate_id='2'"), 5, "a.show_time desc");
     //按发布时间
     $data['link'] = $this->link->lists(array("num" => "5"));
     //最新五条友情链接
     $data['ad_home'] = $this->ad->lists(array("where" => "position_id = 1"));
     //首页广告
     //$data['ad_1F'] = $this->ad->lists(array("where"=>"position_id = 2"));//1L广告
     //$data['ad_2F'] = $this->ad->lists(array("where"=>"position_id = 3"));//2L广告
     //$data['ad_3F'] = $this->ad->lists(array("where"=>"position_id = 4"));//3L广告
     $data['product_brand'] = $this->product_brand->lists(array("num" => "10"));
     //最新27条品牌信息
     $data['coupon'] = $this->coupon->lists(array("expirse_from < " . local_to_gmt(), "expirse_to > " . local_to_gmt()), 5, "a.id desc");
     if ($this->auth->is_login()) {
         $data['order_count'] = $this->order->user_count(array('user_id' => $this->auth->user_id()));
         $user = $this->user->get($this->auth->user_id());
         $data['score'] = $user->score;
     }
     $this->load->view('home/index', $data);
 }
Esempio n. 8
0
 function get_gmt_time($time = '')
 {
     if ($time == '') {
         $time = time();
     }
     $gmt = local_to_gmt($time);
     return $gmt;
 }
Esempio n. 9
0
 function get_est_time()
 {
     $now = time();
     $gmt = local_to_gmt($now);
     $timezone = 'UM4';
     $daylight_saving = FALSE;
     $tt = gmt_to_local($gmt, $timezone, $daylight_saving);
     return $tt;
 }
Esempio n. 10
0
 public function insert($row)
 {
     if (is_array($row) && !empty($row)) {
         if (!isset($row['create_time']) || $row['create_time'] == '') {
             $row['create_time'] = local_to_gmt();
         }
         if ($this->db->insert($this->table, $row)) {
             return $this->db->insert_id();
         }
     }
     return false;
 }
Esempio n. 11
0
 public function insert($row)
 {
     if (is_array($row) && !empty($row)) {
         if (!isset($row['create_time']) || intval($row['create_time']) <= 0) {
             $row['create_time'] = local_to_gmt();
         }
         if (!isset($row['expires']) || intval($row['expires']) <= 0) {
             $row['expires'] = $row['create_time'] + 24 * 3600;
         }
         if ($this->db->insert($this->table, $row)) {
             return $this->db->insert_id();
         }
     }
     return false;
 }
Esempio n. 12
0
 function getOnlineUsers($productId)
 {
     $timezonestimestamp = gmt_to_local(local_to_gmt(), $this->config->item('timezones'));
     $timezonestime = date('Y-m-d H:i:m', $timezonestimestamp);
     $ret = array();
     for ($i = 30; $i >= 0; $i--) {
         $dataStr = date('Y-m-d-H-i', strtotime("-{$i} minutes", strtotime($timezonestime)));
         $size = $this->redis->hlen("razor_r_u_p_" . $productId . "_" . $dataStr);
         if ($i == 0) {
             $onlinedata = array('minutes' => lang("v_rpt_realtime_now"), 'size' => $size);
         } else {
             $onlinedata = array('minutes' => "- " . $i . lang("v_rpt_realtime_minutes"), 'size' => $size);
         }
         array_push($ret, $onlinedata);
     }
     return $ret;
 }
Esempio n. 13
0
 public function insert($row)
 {
     if (is_array($row) && !empty($row)) {
         if (!isset($row['create_time']) || intval($row['create_time']) == 0) {
             $row['create_time'] = local_to_gmt();
         }
         if (!isset($row['user_id']) || intval($row['user_id']) == 0) {
             $row['user_id'] = $this->auth->is_login() ? $this->auth->user_id() : 0;
         }
         if (!isset($row['status'])) {
             $row['status'] = 1;
         }
         if ($this->db->insert($this->table, $row)) {
             return $this->db->insert_id();
         }
     }
     return false;
 }
Esempio n. 14
0
 public function insert($row)
 {
     if (is_array($row) && !empty($row)) {
         if (!isset($row['user_id'])) {
             $row['user_id'] = $this->auth->user_id();
         }
         if (!isset($row['username'])) {
             $row['username'] = $this->auth->username();
         }
         if (!isset($row['time'])) {
             $row['time'] = local_to_gmt();
         }
         if (!isset($row['ip'])) {
             $row['ip'] = $this->input->ip_address();
         }
         if ($this->db->insert($this->table, $row)) {
             return $this->db->insert_id();
         }
     }
     return false;
 }
Esempio n. 15
0
File: time.php Progetto: GStepOne/CI
 function test()
 {
     ini_set('date.timezone', 'PRC');
     //people republic of china
     $this->load->helper("date");
     //  echo timezone_menu("UP8");
     // $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
     $time = time();
     // echo standard_date("DATE_ATOM", $time);
     $timestamp = local_to_gmt($time);
     //转化为时间戳 gmt greenwich mean time 格林尼治时间
     //$timezone="PRC";//people republic of china
     //  echo gmt_to_local($timestamp,$timezone,true);
     $mysql = '20061124092345';
     $unix = mysql_to_unix($mysql);
     $past_time = '19900926092633';
     $a = strtotime($past_time);
     echo local_to_gmt($past_time);
     // $time=time();
     echo timespan($past_time, $time);
     ///$past_time 一定是个时间戳
 }
Esempio n. 16
0
 function getEventNumByEvent($productId)
 {
     $timezonestimestamp = gmt_to_local(local_to_gmt(), $this->config->item('timezones'));
     $timezonestime = date('Y-m-d H:i:m', $timezonestimestamp);
     $all_ret = array();
     $version = "all";
     $eventid_array = $this->event->getEventIdentifierinfo($productId, $version);
     foreach ($eventid_array->result() as $row) {
         $all_size = 0;
         for ($i = 0; $i <= 30; $i++) {
             $dataStr = date('Y-m-d-H-i', strtotime("-{$i} minutes", strtotime($timezonestime)));
             $size = $this->redis->get("razor_r_p_e_" . $productId . "_" . $row->event_identifier . "_" . $dataStr);
             $all_size += $size;
         }
         $data = array('event' => $row->event_identifier, 'size' => $all_size);
         if ($all_size == 0) {
             continue;
         }
         array_push($all_ret, $data);
     }
     return $all_ret;
 }
Esempio n. 17
0
 public function id($id)
 {
     if (!$id) {
         show_error('参数错误', 500);
     }
     $product = $this->product->get($id);
     if (!$product) {
         show_404();
     }
     $this->product->add_view($id);
     $category = $this->product->get_category($id);
     if ($category) {
         $data['category'] = $category;
         if ($category->parent_id) {
             $parent = $this->product_category->get($category->parent_id);
             $data['parent'] = $parent;
             $data['child'] = $this->product_category->all(array('where' => array('parent_id' => $category->parent_id)));
         }
     }
     $brand = $this->product_brand->get($product->brand_id);
     $data['brand_name'] = '';
     if ($brand) {
         $data['brand_name'] = $brand->name;
     }
     $data['product'] = $product;
     //看了又看
     $data['view_again'] = $this->product->all(array('status' => 1), 'view_num desc', '', 3);
     //销售排行
     $data['goodsale'] = $this->product->all(array('status' => 1), 'sale_num desc', '', 9);
     //最终购买了
     $data['last_buy'] = $this->product->all(array('status' => 1), '', '', 3);
     if ($this->auth->is_login()) {
         $this->load->model('user_browse_history');
         $this->user_browse_history->insert(array('user_id' => $this->auth->user_id(), 'product_id' => $id, 'create_time' => local_to_gmt()));
     }
     $this->load->view('home/item', $data);
 }
Esempio n. 18
0
            {
            	alert('Sorry! Email or Phone number is not allowed');return false;
            }
	})
})
</script>
<script type="text/javascript">
// Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.

//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:

var currenttime = '<?php 
echo date("F d, Y H:i:s", get_user_time(local_to_gmt(), get_user_timezoneL($this->uri->segment(3))));
?>
' //PHP method of getting server date

///////////Stop editting here/////////////////////////////////

var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
Esempio n. 19
0
 function pay()
 {
     if (!$this->input->get('list_id') || !$this->input->get('status')) {
         echo '[{"status":"Required All Fields"}]';
     } else {
         $list_id = $this->input->get('list_id');
         $list['list_id'] = $list_id;
         $token = $_GET["token"];
         $playerid = $_GET["PayerID"];
         $status = $this->input->get('status');
         //$httpParsedResponseAr = $this->PPHttpPost('GetExpressCheckoutDetails', $padata, $api_user, $api_pwd, $api_key, $PayPalMode);
         // print_r($httpParsedResponseAr['ACK']);exit;
         if ($status == 'success') {
             //print_r($_REQUEST['ItemName']);exit;
             //echo "<script> alert(''success');</script>";
             $custom = $this->session->userdata('custom');
             //print_r($custom);
             //exit;
             $data = array();
             $list = array();
             $data = explode('@', $custom);
             $contact_key = $data[9];
             $list['list_id'] = $data[0];
             $list['userby'] = $data[1];
             $query1 = $this->Common_model->getTableData('list', array('id' => $list['list_id']));
             $buyer_id = $query1->row()->user_id;
             $list['userto'] = $buyer_id;
             $list['checkin'] = $data[2];
             $list['checkout'] = $data[3];
             $list['no_quest'] = $data[4];
             $amt = explode('%', $httpParsedResponseAr['AMT']);
             $list['price'] = $amt[0];
             $currency = $httpParsedResponseAr['CURRENCYCODE'];
             $list['payment_id'] = 2;
             $list['credit_type'] = 1;
             $list['transaction_id'] = 0;
             $is_travelCretids = $data[5];
             $user_travel_cretids = $data[6];
             $list['topay'] = get_currency_value2($currency, $query1->row()->currency, $data[7]);
             $list['currency'] = $query1->row()->currency;
             $list['admin_commission'] = $data[8];
             //Entering into it
             $list['status'] = 3;
             $this->db->select_max('group_id');
             $group_id = $this->db->get('calendar')->row()->group_id;
             if (empty($group_id)) {
                 echo $countJ = 0;
             } else {
                 $countJ = $group_id;
             }
             $insertData['list_id'] = $list['list_id'];
             $insertData['group_id'] = $countJ + 1;
             $insertData['availability'] = 'Booked';
             $insertData['booked_using'] = 'Other';
             $checkin = date('m/d/Y', $list['checkin']);
             $checkout = date('m/d/Y', $list['checkout']);
             $days = getDaysInBetween($checkin, $checkout);
             $count = count($days);
             $i = 1;
             foreach ($days as $val) {
                 if ($count == 1) {
                     $insertData['style'] = 'single';
                 } else {
                     if ($count > 1) {
                         if ($i == 1) {
                             $insertData['style'] = 'left';
                         } else {
                             if ($count == $i) {
                                 $insertData['notes'] = '';
                                 $insertData['style'] = 'right';
                             } else {
                                 $insertData['notes'] = '';
                                 $insertData['style'] = 'both';
                             }
                         }
                     }
                 }
                 $insertData['booked_days'] = $val;
                 $this->Trips_model->insert_calendar($insertData);
                 $i++;
             }
             if ($list['price'] > 75) {
                 $user_id = $list['userby'];
                 $details = $this->Referrals_model->get_details_by_Iid($user_id);
                 $row = $details->row();
                 $count = $details->num_rows();
                 if ($count > 0) {
                     $details1 = $this->Referrals_model->get_details_refamount($row->invite_from);
                     if ($details1->num_rows() == 0) {
                         $insertData = array();
                         $insertData['user_id'] = $row->invite_from;
                         $insertData['count_trip'] = 1;
                         $insertData['amount'] = 25;
                         $this->Referrals_model->insertReferralsAmount($insertData);
                     } else {
                         $count_trip = $details1->row()->count_trip;
                         $amount = $details1->row()->amount;
                         $updateKey = array('id' => $row->id);
                         $updateData = array();
                         $updateData['count_trip'] = $count_trip + 1;
                         $updateData['amount'] = $amount + 25;
                         $this->Referrals_model->updateReferralsAmount($updateKey, $updateData);
                     }
                 }
             }
             $q = $query1->result();
             $row_list = $query1->row();
             $iUser_id = $q[0]->user_id;
             $details2 = $this->Referrals_model->get_details_by_Iid($iUser_id);
             $row = $details2->row();
             $count = $details2->num_rows();
             if ($count > 0) {
                 $details3 = $this->Referrals_model->get_details_refamount($row->invite_from);
                 if ($details3->num_rows() == 0) {
                     $insertData = array();
                     $insertData['user_id'] = $row->invite_from;
                     $insertData['count_book'] = 1;
                     $insertData['amount'] = 75;
                     $this->Referrals_model->insertReferralsAmount($insertData);
                 } else {
                     $count_book = $details3->row()->count_book;
                     $amount = $details3->row()->amount;
                     $updateKey = array('id' => $row->id);
                     $updateData = array();
                     $updateData['count_trip'] = $count_book + 1;
                     $updateData['amount'] = $amount + 75;
                     $this->Referrals_model->updateReferralsAmount($updateKey, $updateData);
                 }
             }
             $admin_email = $this->dx_auth->get_site_sadmin();
             $admin_name = $this->dx_auth->get_site_title();
             $query3 = $this->Common_model->getTableData('users', array('id' => $list['userby']));
             $rows = $query3->row();
             $username = $rows->username;
             $user_id = $rows->id;
             $email_id = $rows->email;
             $query4 = $this->Users_model->get_user_by_id($buyer_id);
             $buyer_name = $query4->row()->username;
             $buyer_email = $query4->row()->email;
             //Check md5('No Travel Cretids') || md5('Yes Travel Cretids')
             if ($is_travelCretids == '7c4f08a53f4454ea2a9fdd94ad0c2eeb') {
                 $query5 = $this->Referrals_model->get_details_refamount($user_id);
                 $amount = $query5->row()->amount;
                 $updateKey = array('user_id ' => $user_id);
                 $updateData = array();
                 $updateData['amount'] = $amount - $user_travel_cretids;
                 $this->Referrals_model->updateReferralsAmount($updateKey, $updateData);
                 $list['credit_type'] = 2;
                 $list['ref_amount'] = $user_travel_cretids;
                 $row = $query4->row();
                 //sent mail to administrator
                 $email_name = 'tc_book_to_admin';
                 $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A'), "{traveler_email_id}" => $email_id, "{checkin}" => date('d-m-Y', $list['checkin']), "{checkout}" => date('d-m-Y', $list['checkout']), "{market_price}" => $user_travel_cretids + $list['price'], "{payed_amount}" => $list['price'], "{travel_credits}" => $user_travel_cretids, "{host_name}" => ucfirst($buyer_name), "{host_email_id}" => $buyer_email);
                 //Send Mail
                 $this->Email_model->sendMail($admin_email, $email_id, ucfirst($username), $email_name, $splVars);
                 //sent mail to buyer
                 $email_name = 'tc_book_to_host';
                 $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{username}" => ucfirst($buyer_name), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A'), "{traveler_email_id}" => $email_id, "{checkin}" => date('d-m-Y', $list['checkin']), "{checkout}" => date('d-m-Y', $list['checkout']), "{market_price}" => $list['price']);
                 //Send Mail
                 if ($buyer_email != '0') {
                     $this->Email_model->sendMail($buyer_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
                 }
             }
             $list['book_date'] = local_to_gmt();
             //Actual insertion into the database
             $this->Common_model->insertData('reservation', $list);
             $reservation_id = $this->db->insert_id();
             //Send Message Notification
             $insertData = array('list_id' => $list['list_id'], 'reservation_id' => $reservation_id, 'userby' => $list['userby'], 'userto' => $list['userto'], 'message' => 'You have a new reservation request from ' . ucfirst($username), 'created' => local_to_gmt(), 'message_type' => 1);
             $this->Message_model->sentMessage($insertData, ucfirst($buyer_name), ucfirst($username), $row_list->title, $reservation_id);
             $message_id = $this->db->insert_id();
             $actionurl = site_url('trips/request/' . $reservation_id);
             //Reservation Notification To Host
             $email_name = 'host_reservation_notification';
             $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{username}" => ucfirst($buyer_name), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A'), "{traveler_email_id}" => $email_id, "{checkin}" => date('d-m-Y', $list['checkin']), "{checkout}" => date('d-m-Y', $list['checkout']), "{market_price}" => $list['price'], "{action_url}" => $actionurl);
             //Send Mail
             //
             if ($buyer_email != '0') {
                 $this->Email_model->sendMail($buyer_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
             }
             //Reservation Notification To Traveller
             $email_name = 'traveller_reservation_notification';
             $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($username));
             //Send Mail
             $this->Email_model->sendMail($email_id, $admin_email, ucfirst($admin_name), $email_name, $splVars);
             //Reservation Notification To Administrator
             $email_name = 'admin_reservation_notification';
             $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{traveler_name}" => ucfirst($username), "{list_title}" => $row_list->title, "{book_date}" => date('m/d/Y'), "{book_time}" => date('g:i A'), "{traveler_email_id}" => $email_id, "{checkin}" => date('d-m-Y', $list['checkin']), "{checkout}" => date('d-m-Y', $list['checkout']), "{market_price}" => $user_travel_cretids + $list['price'], "{payed_amount}" => $list['price'], "{travel_credits}" => $user_travel_cretids, "{host_name}" => ucfirst($buyer_name), "{host_email_id}" => $buyer_email);
             //Send Mail
             $this->Email_model->sendMail($admin_email, $email_id, ucfirst($username), $email_name, $splVars);
             //	if($is_block == 'on')
             //	{
             $this->db->select_max('group_id');
             $group_id = $this->db->get('calendar')->row()->group_id;
             if (empty($group_id)) {
                 echo $countJ = 0;
             } else {
                 $countJ = $group_id;
             }
             $insertData1['list_id'] = $list['list_id'];
             //$insertData['reservation_id'] = $reservation_id;
             $insertData1['group_id'] = $countJ + 1;
             $insertData1['availability'] = 'Not Available';
             $insertData1['booked_using'] = 'Other';
             $checkin = date('m/d/Y', $list['checkin']);
             $checkout = date('m/d/Y', $list['checkout']);
             $days = getDaysInBetween($checkin, $checkout);
             $count = count($days);
             $i = 1;
             foreach ($days as $val) {
                 if ($count == 1) {
                     $insertData1['style'] = 'single';
                 } else {
                     if ($count > 1) {
                         if ($i == 1) {
                             $insertData1['style'] = 'left';
                         } else {
                             if ($count == $i) {
                                 $insertData1['notes'] = '';
                                 $insertData1['style'] = 'right';
                             } else {
                                 $insertData1['notes'] = '';
                                 $insertData1['style'] = 'both';
                             }
                         }
                     }
                 }
                 $insertData1['booked_days'] = $val;
                 $this->Trips_model->insert_calendar($insertData1);
                 $i++;
             }
         }
         $referral_amount = $this->db->where('id', $this->dx_auth->get_user_id())->get('users')->row()->referral_amount;
         if ($referral_amount > 100) {
             $this->db->set('referral_amount', $referral_amount - 100)->where('id', $this->dx_auth->get_user_id())->update('users');
         } else {
             $this->db->set('referral_amount', 0)->where('id', $this->dx_auth->get_user_id())->update('users');
         }
         echo '[{"status":"SUCCESS updated"}]';
     }
 }
Esempio n. 20
0
 public function cancel_travel($params1 = '', $params2 = '', $params3 = '')
 {
     if ($params1 != '') {
         $conditions = array('reservation.id' => $params1);
         $row = $this->Trips_model->get_reservation($conditions)->row();
         if ($row->status == 12 || $row->status == 6) {
             echo translate('This reservation is already cancelled by Guest.');
             exit;
         } else {
             if ($row->status == 5 || $row->status == 11) {
                 echo translate('This reservation is already cancelled by Host.');
                 exit;
             }
         }
     }
     if ($this->input->post('reservation_id')) {
         $reservation_id = $this->input->post('reservation_id');
         $admin_email = $this->dx_auth->get_site_sadmin();
         $admin_name = $this->dx_auth->get_site_title();
         $conditions = array('reservation.id' => $reservation_id);
         $row = $this->Trips_model->get_reservation($conditions)->row();
         $before_status = $row->status;
         if ($this->Users_model->get_user_by_id($row->userby)) {
             $query1 = $this->Users_model->get_user_by_id($row->userby);
         } else {
             $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Your List was deleted.')));
             redirect('travelling/your_trips');
         }
         $traveler_name = $query1->row()->username;
         $traveler_email = $query1->row()->email;
         $query2 = $this->Users_model->get_user_by_id($row->userto);
         $host_name = $query2->row()->username;
         $host_email = $query2->row()->email;
         $list_title = $this->Common_model->getTableData('list', array('id' => $row->list_id))->row()->title;
         $updateKey = array('id' => $reservation_id);
         $updateData = array();
         $check_user = $this->db->where('user_id', $this->dx_auth->get_user_id())->where('id', $row->list_id)->get('list');
         if ($check_user->num_rows() == 1) {
             if ($row->status == 7) {
                 $updateData['status'] = 11;
             } else {
                 $updateData['status'] = 5;
             }
             if ($row->status == 1) {
                 $updateData['status'] = 13;
             }
             $host_cancellation = $this->Common_model->getTableData('host_cancellation_policy', array('id' => 1))->row();
             $check_free_cancellation_limit = $this->db->query("SELECT * FROM (`reservation`) WHERE `userto` = " . $this->dx_auth->get_user_id() . " AND from_unixtime(cancel_date) >= DATE_SUB(CURRENT_TIMESTAMP(),INTERVAL " . $host_cancellation->months . " MONTH) AND (`status` = 5  OR `status` = 11)");
             if ($check_free_cancellation_limit->num_rows() >= $host_cancellation->free_cancellation) {
                 $free_cancellation_limit = 0;
                 $date1 = new DateTime(date('Y-m-d H:i:s'));
                 $date2 = new DateTime(date('Y-m-d H:i:s', $row->checkin));
                 $interval = $date1->diff($date2);
                 if ($interval->days < $host_cancellation->days) {
                     $penalty_amount = $host_cancellation->before_amount;
                 } else {
                     $penalty_amount = $host_cancellation->after_amount;
                 }
                 $check_already_penalty = $this->Common_model->getTableData('host_cancellation_penalty', array('user_id' => $this->dx_auth->get_user_id()));
                 if ($check_already_penalty->num_rows() != 0) {
                     $update_penalty['amount'] = $check_already_penalty->row()->amount + get_currency_value_lys($host_cancellation->currency, $check_already_penalty->row()->currency, $penalty_amount);
                     $update_penalty_key['id'] = $check_already_penalty->row()->id;
                     $this->Common_model->updateTableData('host_cancellation_penalty', 0, $update_penalty_key, $update_penalty);
                 } else {
                     $insert_penalty['amount'] = $penalty_amount;
                     $insert_penalty['user_id'] = $this->dx_auth->get_user_id();
                     $insert_penalty['currency'] = $host_cancellation->currency;
                     $this->Common_model->inserTableData('host_cancellation_penalty', $insert_penalty);
                 }
                 $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => 1, 'userto' => $row->userto, 'message' => "You're cross the free cancellation limit. So, Admin will take {$penalty_amount}" . $host_cancellation->currency . " penalty amount from your next payout.", 'created' => local_to_gmt(), 'message_type' => 3);
                 $this->Message_model->sentMessage($insertData, 1);
                 $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => 1, 'userto' => 1, 'message' => "{$host_name} cross the free cancellation limit. So, You will earn {$penalty_amount}" . $host_cancellation->currency . " penalty amount from {$host_name} next payout.", 'created' => local_to_gmt(), 'message_type' => 3);
                 $this->Message_model->sentMessage($insertData, 1);
             } else {
                 $free_cancellation_limit = $host_cancellation->free_cancellation - $check_free_cancellation_limit->num_rows();
             }
             $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userto, 'userto' => $row->userby, 'message' => "Sorry, Your reservation is cancelled by {$host_name} for {$list_title}.", 'created' => local_to_gmt(), 'message_type' => 3);
             $this->Message_model->sentMessage($insertData, 1);
         } else {
             if ($row->status == 7) {
                 $updateData['status'] = 12;
             } else {
                 $updateData['status'] = 6;
             }
             if ($row->status == 1) {
                 $updateData['status'] = 13;
             }
             $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userby, 'userto' => $row->userto, 'message' => "Sorry, Your list reservation is cancelled by {$traveler_name} for {$list_title}.", 'created' => local_to_gmt(), 'message_type' => 3);
             $this->Message_model->sentMessage($insertData, 1);
         }
         $updateData['cancel_date'] = time();
         $this->Trips_model->update_reservation($updateKey, $updateData);
         // payment_helper called for refund amount for host and guest as per host and guest cancellation policy
         refund($reservation_id);
         /*	$cancel_trip_referral_query = $this->db->select('cancel_trips_referral_code')->where('id',$row->userby)->get('users');
         			if($cancel_trip_referral_query->num_rows()!=0)
         			{
         				if($cancel_trip_referral_query->row()->cancel_trips_referral_code != '')
         				{
         			 $this->db->set('trips_referral_code',$cancel_trip_referral_query->row()->cancel_trips_referral_code)->where('id',$row->userby)->update('users');
         			 $this->db->set('cancel_trips_referral_code','')->where('id',$row->userby)->update('users');
         			 $referral_by = $this->db->where('referral_code',$cancel_trip_referral_query->row()->cancel_trips_referral_code)->get('users');
         				if($referral_by->num_rows()!=0)
         				{
         					$referral_amount = $referral_by->row()->referral_amount-25;
         					$this->db->set('referral_amount',$referral_amount)->where('referral_code',$cancel_trip_referral_query->row()->cancel_trips_referral_code)->update('users');
         				}
         				}
         			}
         			
         			$cancel_list_referral_query = $this->db->select('cancel_list_referral_code')->where('id',$row->userto)->get('users');
         			if($cancel_list_referral_query->num_rows()!=0)
         			{
         				if($cancel_list_referral_query->row()->cancel_list_referral_code != '')
         				{
         			 $this->db->set('list_referral_code',$cancel_list_referral_query->row()->cancel_list_referral_code)->where('id',$row->userto)->update('users');
         			 $this->db->set('cancel_list_referral_code','')->where('id',$row->userto)->update('users');
         				 $referral_by = $this->db->where('referral_code',$cancel_list_referral_query->row()->cancel_list_referral_code)->get('users');
         				if($referral_by->num_rows()!=0)
         				{
         					$referral_amount = $referral_by->row()->referral_amount-75;
         					$this->db->set('referral_amount',$referral_amount)->where('referral_code',$cancel_list_referral_query->row()->cancel_list_referral_code)->update('users');
         				}
                         }
         			}
         		*/
         $comment = $this->input->post('comment');
         $this->db->where('list_id', $row->list_id)->where('booked_days >=', $row->checkin)->where('booked_days <=', $row->checkout)->delete('calendar');
         if ($row->status == 3) {
             $status = 'Confirmed';
         } else {
             if ($row->status == 7) {
                 $status = 'After Checkin';
             } else {
                 $status = 'Pending';
             }
         }
         if ($updateData['status '] == 5 || $updateData['status '] == 11) {
             if (isset($penalty_amount)) {
                 $penalty = 'From your next payout we will take ' . $penalty_amount . $host_cancellation->currency . ' penalty amount.';
                 $admin_penalty = 'From ' . $host_name . ' next payout You will earn ' . $penalty_amount . $host_cancellation->currency . ' penalty amount.';
             } else {
                 $penalty = '';
                 $admin_penalty = '';
             }
             //if(isset($free_cancellation_limit))
             //{
             $free_cancellation = 'Remaining Free cancellation: ' . $free_cancellation_limit;
             //}
             //Send Mail To Host
             $email_name = 'host_reservation_cancel';
             $splVars = array("{penalty}" => $penalty, "{cancellation_limit}" => $free_cancellation, "{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{comment}" => $comment, "{traveler_name}" => ucfirst($host_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($traveler_name));
             $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
             //Send Mail To Traveller
             $email_name = 'traveler_reservation_cancel';
             $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{user_type}" => 'Host', "{status}" => $status, "{comment}" => $comment, "{traveler_name}" => ucfirst($host_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($traveler_name));
             $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
             //Send Mail To Administrator
             $email_name = 'admin_reservation_cancel';
             $splVars = array("{penalty}" => $admin_penalty, "{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{traveler_name}" => ucfirst($host_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($traveler_name));
             $this->Email_model->sendMail($admin_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
         } else {
             $admin_penalty = '';
             $free_cancellation = '';
             //Send Mail To Host
             $email_name = 'host_reservation_cancel';
             $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{comment}" => $comment, "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name));
             $this->Email_model->sendMail($traveler_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
             //Send Mail To Traveller
             $email_name = 'traveler_reservation_cancel';
             $splVars = array("{site_name}" => $this->dx_auth->get_site_title(), "{user_type}" => 'Guest', "{status}" => $status, "{comment}" => $comment, "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name));
             $this->Email_model->sendMail($host_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
             //Send Mail To Administrator
             $email_name = 'admin_reservation_cancel';
             $splVars = array("{penalty}" => $admin_penalty, "{site_name}" => $this->dx_auth->get_site_title(), "{status}" => $status, "{traveler_name}" => ucfirst($traveler_name), "{list_title}" => $list_title, "{host_name}" => ucfirst($host_name));
             $this->Email_model->sendMail($admin_email, $admin_email, ucfirst($admin_name), $email_name, $splVars);
         }
         $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('You are successfully cancelled the trip.')));
         if ($params3 == '') {
             $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Reservation Cancelled Successfully.')));
             redirect('travelling/your_trips');
         } else {
             $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Reservation Cancelled Successfully.')));
             redirect('listings/my_reservation');
         }
     } else {
         $conditions = array('reservation.id' => $params1);
         $row = $this->Trips_model->get_reservation($conditions)->row();
         if ($this->Trips_model->get_reservation($conditions)->num_rows() == 0) {
             redirect('info');
         }
         $check_user = $this->db->where('user_id', $this->dx_auth->get_user_id())->where('id', $row->list_id)->get('list');
         if ($check_user->num_rows() == 1) {
             $data['user_type'] = 'host';
         } else {
             $data['user_type'] = 'guest';
         }
         $checkin = $row->checkin;
         $checkout = $row->checkout;
         $diff1 = $checkout - $checkin;
         $days1 = ceil($diff1 / (3600 * 24));
         $diff2 = local_to_gmt() - $checkin;
         $days2 = ceil($diff2 / (3600 * 24));
         $policy = $this->Common_model->getTableData('cancellation_policy', array('id' => $row->policy))->row();
         $data['policy_name'] = $policy->name;
         $date1 = new DateTime(date('Y-m-d H:i:s', $row->checkin));
         $date2 = new DateTime(date('Y-m-d H:i:s'));
         $interval = $date1->diff($date2);
         if ($row->status != 7) {
             if ($policy->list_before_status == 0) {
                 $data['nights'] = 0;
                 $data['non_nights'] = ceil($diff1 / (3600 * 24));
             } else {
                 if ($policy->list_before_days <= $interval->days) {
                     $data['nights'] = $days = $interval->days;
                     $data['non_nights'] = 0;
                 } else {
                     $data['nights'] = $days = ceil($diff1 / (3600 * 24)) - $policy->list_non_refundable_nights;
                     if ($policy->list_non_refundable_nights > ceil($diff1 / (3600 * 24))) {
                         $data['non_nights'] = ceil($diff1 / (3600 * 24));
                     } else {
                         $data['non_nights'] = $policy->list_non_refundable_nights;
                     }
                 }
             }
         } else {
             if ($row->status == 7) {
             }
         }
         $data['reservation_id'] = $params1;
         $data['list_id'] = $params2;
         $this->load->view(THEME_FOLDER . '/travelling/view_cancel_travel', $data);
     }
 }
Esempio n. 21
0
 protected function renderContent()
 {
     //Get some pre value from URL
     //The type of the content we want to create
     $type = isset($_GET['type']) ? strtolower(trim($_GET['type'])) : '';
     //If it has guid, it means this is a translated version
     $guid = isset($_GET['guid']) ? strtolower(trim($_GET['guid'])) : '';
     //Get the list of Content Type
     $types = GxcHelpers::getAvailableContentType();
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     //Available Terms for this Object Type
     $terms = array();
     //Selected Terms
     $selected_terms = array();
     //Get Term Order
     $term_orders = ConstantDefine::getTermOrder();
     //If $type is empty then redirect to choose content type page
     if ($type != '') {
         //Check if the type appear in content type Definition
         if (array_key_exists($type, $types)) {
             // If the guid is not empty, it means we are creating a translated version of a content
             // We will exclude the translated language and include the name of the translated content to $versions
             if ($guid != '') {
                 $temp_object = Object::model()->findAll('guid=:gid', array(':gid' => $guid));
                 if (count($temp_object) > 0) {
                     foreach ($temp_object as $obj) {
                         $lang_exclude[] = $obj->lang;
                         $langs = GxcHelpers::getAvailableLanguages();
                         $versions[] = $obj->object_name . ' - ' . $langs[$obj->lang]['name'];
                     }
                 }
             }
             //Import the Content Type Class
             Yii::import('common.content_type.' . $type . '.' . $types[$type]['class']);
             //Init the class
             $typeClassObj = new $types[$type]['class']();
             $content_resources = $typeClassObj->Resources();
             //We start to implement the checking Permission HERE
             $param_content_check = array();
             $data_content_check = array();
             $param_content_check['type'] = $type;
             if (GxcContentPermission::checkCreatePermission($param_content_check, $data_content_check, $typeClassObj->Permissions())) {
                 $param_content_check['new_content'] = true;
                 $content_status = GxcContentPermission::getContentStatus($param_content_check, $data_content_check, $typeClassObj->Permissions());
                 $model = new $types[$type]['class']();
                 // Uncomment the following line if AJAX validation is needed
                 // $this->performAjaxValidation($model);
                 $model->object_date = date('Y-m-d H:i:s');
                 $model->person = '';
                 $model->guid = $guid;
                 $get_languages = GxcHelpers::loadLanguageItems($lang_exclude);
                 $available_languages = array();
                 foreach ($get_languages as $key => $value) {
                     $available_languages[] = $key;
                 }
                 //Get available Taxonomy and Terms for this Object
                 $available_taxonomy = Taxonomy::model()->findAll(' type = :type AND lang IN (' . implode(',', $available_languages) . ') ', array(':type' => $type));
                 if ($available_taxonomy) {
                     foreach ($available_taxonomy as $t) {
                         $temp = array();
                         $temp['id'] = $t->taxonomy_id;
                         $temp['lang'] = $t->lang;
                         $temp['name'] = $t->name;
                         $temp['terms'] = array();
                         //Look for the Term Items belong to this Taxonomy
                         $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC', 'params' => array(':id' => $t->taxonomy_id)));
                         if ($list_terms) {
                             foreach ($list_terms as $term) {
                                 $temp_item['id'] = $term->term_id;
                                 $temp_item['name'] = CHtml::encode($term->name);
                                 $temp_item['parent'] = $term->parent;
                                 $temp['terms']['item_' . $term->term_id] = $temp_item;
                             }
                         }
                         $terms[$t->taxonomy_id] = $temp;
                     }
                 }
                 if (isset($_POST[$types[$type]['class']])) {
                     $model->attributes = $_POST[$types[$type]['class']];
                     //Convert the date time publish to timestamp
                     $model->object_date = strtotime($model->object_date);
                     $model->object_date_gmt = local_to_gmt($model->object_date);
                     //Check which button the User click To Send to person or group
                     $button = $_POST['which_button'];
                     $trans = new Transfer();
                     // Get the Terms that the User Choose
                     //
                     $post_terms = isset($_POST['terms']) ? $_POST['terms'] : array();
                     $selected_terms = array();
                     if (!empty($post_terms)) {
                         foreach ($post_terms as $t) {
                             $t = explode('_', $t);
                             if (!isset($selected_terms[$t[1]])) {
                                 $selected_temp = array();
                                 $selected_temp['id'] = $terms[$t[1]]['id'];
                                 $selected_temp['lang'] = $terms[$t[1]]['lang'];
                                 $selected_temp['name'] = $terms[$t[1]]['name'];
                                 $selected_temp['terms']['item_' . $t[0]]['id'] = $t[0];
                                 $selected_temp['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                                 $selected_temp['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                                 $selected_temp['terms']['item_' . $t[0]]['data'] = $t[2];
                                 $selected_temp['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                                 $selected_terms[$t[1]] = $selected_temp;
                             } else {
                                 if (!isset($selected_terms['terms']['item_' . $t[0]])) {
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['id'] = $t[0];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data'] = $t[2];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                                 }
                             }
                         }
                     }
                     // After having the selected Terms, we need to make sure  all parents
                     // of the selected Terms must be added also
                     foreach ($selected_terms as $tx_key => $t) {
                         $array_parent_selected_terms = array();
                         foreach ($t['terms'] as $key => $st_terms) {
                             $current_term = $st_terms;
                             while ($current_term['parent'] != 0) {
                                 if (!isset($array_parent_selected_terms['item_' . $current_term['parent']]) && !isset($t['terms']['item_' . $current_term['parent']])) {
                                     $array_parent_selected_terms['item_' . $current_term['parent']] = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                                     $array_parent_selected_terms['item_' . $current_term['parent']]['data'] = key($term_orders);
                                     $array_parent_selected_terms['item_' . $current_term['parent']]['data_name'] = $term_orders[key($term_orders)];
                                 }
                                 $current_term = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                             }
                         }
                         $selected_terms[$tx_key]['terms'] = CMap::mergeArray($t['terms'], $array_parent_selected_terms);
                     }
                     //Re-Set the Status based on what User Chooose
                     //The content is sent to ROLES OR STATUS
                     if ($button == '1') {
                         //Check if the object_status is number or character
                         if (!is_numeric($model->object_status)) {
                             //Set the status to Pending
                             $trans->note = $model->object_status;
                             $model->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->type = ConstantDefine::TRANS_ROLE;
                             $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                         } else {
                             $trans->type = ConstantDefine::TRANS_STATUS;
                             $trans->after_status = $model->object_status;
                         }
                         $trans->from_user_id = user()->id;
                         $trans->to_user_id = 0;
                         $trans->before_status = ConstantDefine::OBJECT_STATUS_DRAFT;
                     }
                     //The content is sent to PERSON DIRECTLY
                     if ($button == '2') {
                         $to_user_id = User::findPeople($model->person);
                         //Start to Transfer to the user and set the status to Pending
                         if ($to_user_id) {
                             $model->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->from_user_id = user()->id;
                             $trans->to_user_id = $to_user_id->user_id;
                             $trans->type = ConstantDefine::TRANS_PERSON;
                             $trans->before_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                         } else {
                             $model->addError('person', t('User not found'));
                         }
                     }
                     //Work with Resource Binding
                     $resource = array();
                     $resource_upload = array();
                     foreach ($content_resources as $res) {
                         $resource_upload[] = GxcHelpers::getArrayResourceObjectBinding('resource_upload_' . $res['type']);
                     }
                     $i = 0;
                     $count_resource = 0;
                     foreach ($content_resources as $cres) {
                         $j = 1;
                         foreach ($resource_upload[$i] as $res_up) {
                             $j++;
                             $count_resource++;
                         }
                         $i++;
                     }
                     $model->total_number_resource = $count_resource;
                     if ($model->save()) {
                         user()->setFlash('success', t('cms', 'Create new Content Successfully!'));
                         $trans->object_id = $model->object_id;
                         $trans->save();
                         // We have all the selected Terms for now
                         // We will add them to Object Terms
                         foreach ($selected_terms as $tx_key => $t) {
                             foreach ($t['terms'] as $key => $st_terms) {
                                 $obj_term = new ObjectTerm();
                                 $obj_term->object_id = $model->object_id;
                                 $obj_term->term_id = $st_terms['id'];
                                 $obj_term->data = $st_terms['data'];
                                 $obj_term->save();
                                 unset($obj_term);
                             }
                         }
                         //Update Resource Binding Here
                         $i = 0;
                         $count_resource = 0;
                         foreach ($content_resources as $cres) {
                             $j = 1;
                             foreach ($resource_upload[$i] as $res_up) {
                                 $obj_res = new ObjectResource();
                                 $obj_res->resource_id = $res_up['resid'];
                                 $obj_res->object_id = $model->object_id;
                                 $obj_res->description = '';
                                 $obj_res->type = $cres['type'];
                                 $obj_res->resource_order = $j;
                                 $obj_res->save();
                                 $j++;
                                 $count_resource++;
                             }
                             $i++;
                         }
                         //Re-init new Model
                         $model = new $types[$type]['class']();
                         $model->object_date = date('Y-m-d H:i:s');
                         Yii::app()->controller->refresh();
                     } else {
                         $model->object_date = date('Y-m-d H:i:s', $model->object_date);
                     }
                 }
                 $render_template = 'cmswidgets.views.object.object_form_widget';
                 if (file_exists(Yii::getPathOfAlias('common.content_type.' . strtolower($type) . '.object_form_widget') . '.php')) {
                     $render_template = 'common.content_type.' . strtolower($type) . '.object_form_widget';
                 }
                 $this->render($render_template, array('model' => $model, 'versions' => $versions, 'lang_exclude' => $lang_exclude, 'content_status' => $content_status, 'terms' => $terms, 'selected_terms' => $selected_terms, 'type' => $type, 'content_resources' => $content_resources));
             }
         } else {
             //The type is not in Content Type Definition
             $this->render('cmswidgets.views.object.object_start_widget', array('types' => $types));
         }
     } else {
         //There is no Type in $_GET
         $this->render('cmswidgets.views.object.object_start_widget', array('types' => $types));
     }
 }
 function curr_timestamp($format = 'Y-m-d H:i:s')
 {
     return date($format, local_to_gmt());
     /*date("Y-m-d H:i:s", now());*/
 }
Esempio n. 23
0
 protected function renderContent()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     $model = GxcHelpers::loadDetailModel('Object', $id);
     //We start to implement the checking Permission HERE
     $param_content_check = array();
     $data_content_check = array();
     $param_content_check['type'] = $model->object_type;
     $param_content_check['new_content'] = false;
     $param_content_check['content_status'] = $model->object_status;
     $param_content_check['content_author'] = $model->object_author;
     //Get current trans_to of the object
     $trans = Transfer::model()->findAll(array('condition' => ' object_id=:obj ', 'params' => array(':obj' => $model->object_id), 'order' => 'transfer_id DESC'));
     $param_content_check['check_trans_note'] = false;
     if ($trans != null && count($trans) > 0) {
         $latest_trans_to = $trans[0];
         $param_content_check['trans_type'] = $latest_trans_to->type;
         $param_content_check['trans_to'] = $latest_trans_to->to_user_id;
         $param_content_check['trans_note'] = $latest_trans_to->note;
     }
     //Get Types list and type of the Object
     $types = GxcHelpers::getAvailableContentType();
     $type = (string) $model->object_type;
     //Import the Content Type Class
     Yii::import('common.content_type.' . $type . '.' . $types[$type]['class']);
     $typeClassObj = new $types[$type]['class']();
     $content_resources = $typeClassObj->Resources();
     //Check if the User has the Permission to update the Content
     if (GxcContentPermission::checkUpdatePermission($param_content_check, $data_content_check, $typeClassObj->Permissions())) {
         //Convert the object date from timestamp to datetime format
         $model->object_date = date('Y-m-d H:i:s', $model->object_date);
         //Get available content Status that the Object can be sent to
         $content_status = GxcContentPermission::getContentStatus($param_content_check, $data_content_check, $typeClassObj->Permissions());
         //If the Object is Pending and being sent to someone, get that person info
         if ($model->object_status == ConstantDefine::OBJECT_STATUS_PENDING) {
             if ($latest_trans_to->type == ConstantDefine::TRANS_PERSON) {
                 $send_to_user = User::model()->findbyPk($latest_trans_to->to_user_id);
                 if ($send_to_user == null) {
                     $model->person = '';
                 } else {
                     $model->person = trim($send_to_user->display_name);
                 }
             }
         }
         //Unset value for Lang Exclude, Version and Guid when updating
         $lang_exclude = array();
         $versions = array();
         $guid = $model->guid;
         // Create new instance Object based on Object Type
         $object = new $types[$type]['class']();
         $object->person = $model->person;
         $object->setAttributes($model->attributes, false);
         // Get Extra Info - Object Meta of the Object Type
         $object_metas = ObjectMeta::model()->findAll('meta_object_id = :obj ', array(':obj' => $model->object_id));
         foreach ($object_metas as $object_meta) {
             $key = (string) $object_meta->meta_key;
             $object->{$key} = $object_meta->meta_value;
         }
         // This is not a new Record
         $object->isNewRecord = false;
         //Set current tags for Object
         $object->_oldTags = $object->tags;
         $object->scenario = 'updateWithTags';
         //Available Terms for this Object Type
         $terms = array();
         //Selected Terms
         $selected_terms = array();
         //Get Term Order
         $term_orders = ConstantDefine::getTermOrder();
         //Get available Taxonomy and Terms for this Object
         $available_taxonomy = Taxonomy::model()->findAll(' type = :type AND lang IN (' . $object->lang . ') ', array(':type' => $type));
         if ($available_taxonomy) {
             foreach ($available_taxonomy as $t) {
                 $temp = array();
                 $temp['id'] = $t->taxonomy_id;
                 $temp['lang'] = $t->lang;
                 $temp['name'] = $t->name;
                 $temp['terms'] = array();
                 $selected_temp = array();
                 $selected_temp['id'] = $t->taxonomy_id;
                 $selected_temp['lang'] = $t->lang;
                 $selected_temp['name'] = $t->name;
                 $selected_temp['terms'] = array();
                 //Look for the Term Items belong to this Taxonomy
                 $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC', 'params' => array(':id' => $t->taxonomy_id)));
                 if ($list_terms) {
                     foreach ($list_terms as $term) {
                         $temp_item['id'] = $term->term_id;
                         $temp_item['name'] = CHtml::encode($term->name);
                         $temp_item['parent'] = $term->parent;
                         $temp['terms']['item_' . $term->term_id] = $temp_item;
                     }
                 }
                 $terms[$t->taxonomy_id] = $temp;
                 //Look for selected Terms belong to this Taxonomy
                 $sl_terms = ObjectTerm::model()->findAll(array('select' => '*', 'condition' => 'object_id=:id', 'params' => array(':id' => $object->object_id)));
                 if ($sl_terms) {
                     foreach ($sl_terms as $sl_term) {
                         if (isset($terms[$t->taxonomy_id]['terms']['item_' . $sl_term->term_id])) {
                             $selected_temp['terms']['item_' . $sl_term->term_id] = $terms[$t->taxonomy_id]['terms']['item_' . $sl_term->term_id];
                             $selected_temp['terms']['item_' . $sl_term->term_id]['data'] = $sl_term->data;
                             $selected_temp['terms']['item_' . $sl_term->term_id]['data_name'] = $term_orders[$sl_term->data];
                         }
                     }
                 }
                 $selected_terms[$t->taxonomy_id] = $selected_temp;
             }
         }
         //IF having the Post Method - Start to working to save it
         if (isset($_POST[$types[$type]['class']])) {
             $object->attributes = $_POST[$types[$type]['class']];
             //Convert the date time publish to timestamp
             $object->object_date = strtotime($object->object_date);
             $object->object_date_gmt = local_to_gmt($object->object_date);
             //Check which button the User click To Send to person or group
             $button = $_POST['which_button'];
             $trans = new Transfer();
             // Get the Terms that the User Choose
             $post_terms = isset($_POST['terms']) ? $_POST['terms'] : array();
             $selected_terms = array();
             if (!empty($post_terms)) {
                 foreach ($post_terms as $t) {
                     $t = explode('_', $t);
                     if (!isset($selected_terms[$t[1]])) {
                         $selected_temp = array();
                         $selected_temp['id'] = $terms[$t[1]]['id'];
                         $selected_temp['lang'] = $terms[$t[1]]['lang'];
                         $selected_temp['name'] = $terms[$t[1]]['name'];
                         $selected_temp['terms']['item_' . $t[0]]['id'] = $t[0];
                         $selected_temp['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                         $selected_temp['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                         $selected_temp['terms']['item_' . $t[0]]['data'] = $t[2];
                         $selected_temp['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                         $selected_terms[$t[1]] = $selected_temp;
                     } else {
                         if (!isset($selected_terms['terms']['item_' . $t[0]])) {
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['id'] = $t[0];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data'] = $t[2];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                         }
                     }
                 }
             }
             // After having the selected Terms, we need to make sure  all parents
             // of the selected Terms must be added also
             foreach ($selected_terms as $tx_key => $t) {
                 $array_parent_selected_terms = array();
                 foreach ($t['terms'] as $key => $st_terms) {
                     $current_term = $st_terms;
                     while ($current_term['parent'] != 0) {
                         if (!isset($array_parent_selected_terms['item_' . $current_term['parent']]) && !isset($t['terms']['item_' . $current_term['parent']])) {
                             $array_parent_selected_terms['item_' . $current_term['parent']] = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                             $array_parent_selected_terms['item_' . $current_term['parent']]['data'] = key($term_orders);
                             $array_parent_selected_terms['item_' . $current_term['parent']]['data_name'] = $term_orders[key($term_orders)];
                         }
                         $current_term = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                     }
                 }
                 $selected_terms[$tx_key]['terms'] = CMap::mergeArray($t['terms'], $array_parent_selected_terms);
             }
             //Re-Set the Status based on what User Chooose
             //The content is sent to ROLES OR STATUS
             if ($button == '1') {
                 //Check if the object_status is number or character
                 if (!is_numeric($object->object_status)) {
                     //Set the status to Pending
                     $trans->note = $object->object_status;
                     $object->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->type = ConstantDefine::TRANS_ROLE;
                     $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                 } else {
                     $trans->type = ConstantDefine::TRANS_STATUS;
                     $trans->after_status = $object->object_status;
                 }
                 $trans->from_user_id = user()->id;
                 $trans->to_user_id = 0;
                 $trans->before_status = ConstantDefine::OBJECT_STATUS_DRAFT;
             }
             //The content is sent to PERSON DIRECTLY
             if ($button == '2') {
                 $to_user_id = User::findPeople($object->person);
                 //Start to Transfer to the user and set the status to Pending
                 if ($to_user_id) {
                     $object->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->from_user_id = user()->id;
                     $trans->to_user_id = $to_user_id->user_id;
                     $trans->type = ConstantDefine::TRANS_PERSON;
                     $trans->before_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                 } else {
                     $object->addError('person', t('User not found'));
                 }
             }
             //Work with Resource Binding
             $resource = array();
             $resource_upload = array();
             foreach ($content_resources as $res) {
                 $resource_upload[] = GxcHelpers::getArrayResourceObjectBinding('resource_upload_' . $res['type']);
             }
             $i = 0;
             $count_resource = 0;
             foreach ($content_resources as $cres) {
                 $j = 1;
                 foreach ($resource_upload[$i] as $res_up) {
                     $j++;
                     $count_resource++;
                 }
                 $i++;
             }
             $object->total_number_resource = $count_resource;
             if ($object->save()) {
                 user()->setFlash('success', t('cms', 'Update content Successfully!'));
                 $trans->object_id = $object->object_id;
                 $trans->save();
                 //This is the update process, we should delete old
                 //Object Term binding
                 ObjectTerm::model()->deleteAll('object_id = :id', array(':id' => $object->object_id));
                 // We have all the selected Terms for now
                 // We will add them to Object Terms
                 foreach ($selected_terms as $tx_key => $t) {
                     foreach ($t['terms'] as $key => $st_terms) {
                         $obj_term = new ObjectTerm();
                         $obj_term->object_id = $object->object_id;
                         $obj_term->term_id = $st_terms['id'];
                         $obj_term->data = $st_terms['data'];
                         $obj_term->save();
                         unset($obj_term);
                     }
                 }
                 //Re update for Resource
                 ObjectResource::model()->deleteAll('object_id = :id', array(':id' => $object->object_id));
                 $i = 0;
                 $count_resource = 0;
                 foreach ($content_resources as $cres) {
                     $j = 1;
                     foreach ($resource_upload[$i] as $res_up) {
                         $obj_res = new ObjectResource();
                         $obj_res->resource_id = $res_up['resid'];
                         $obj_res->object_id = $object->object_id;
                         $obj_res->description = '';
                         $obj_res->type = $cres['type'];
                         $obj_res->resource_order = $j;
                         $obj_res->save();
                         $j++;
                         $count_resource++;
                     }
                     $i++;
                 }
             }
             $object->object_date = date('Y-m-d H:i:s', $object->object_date);
         }
         //Start Render the Form
         $render_template = 'cmswidgets.views.object.object_form_widget';
         if (file_exists(Yii::getPathOfAlias('common.content_type.' . strtolower($type) . '.object_form_widget') . '.php')) {
             $render_template = 'common.content_type.' . strtolower($type) . '.object_form_widget';
         }
         $this->render($render_template, array('model' => $object, 'versions' => $versions, 'lang_exclude' => $lang_exclude, 'content_status' => $content_status, 'terms' => $terms, 'selected_terms' => $selected_terms, 'type' => $type, 'content_resources' => $content_resources));
     }
 }
Esempio n. 24
0
 /**
  * Loads Manage Static helps View.
  *
  * @access	private
  * @param	nil
  * @return	void
  */
 public function edithelp()
 {
     //Get id of the category
     $id = is_numeric($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     if ($this->input->post('edithelp')) {
         $check_data = $this->db->where('id', $id)->get('help');
         if ($check_data->num_rows() == 0) {
             $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate_admin('This help already deleted.')));
             redirect_admin('help/viewhelp');
         }
         //Set rules
         $this->form_validation->set_rules('question', 'help title', 'required|trim|xss_clean');
         $this->form_validation->set_rules('description', 'help content', 'required|trim');
         $this->form_validation->set_rules('page_refer', 'page refer', 'required|trim|xss_clean');
         //|callback_helpUrlCheck|callback_helpUrlValid');
         $this->form_validation->set_rules('status', 'active', 'required|trim|xss_clean');
         if ($this->form_validation->run()) {
             //prepare update data
             $updateData = array();
             $updateData['question'] = $this->input->post('question');
             $updateData['description'] = $this->input->post('description', false);
             $updateData['page_refer'] = $this->input->post('page_refer');
             $updateData['status'] = $this->input->post('status');
             $updateData['modified_date'] = local_to_gmt();
             //Edit Faq Category
             $updateKey = array('help.id' => $this->uri->segment(4));
             $this->help_model->updatehelp($updateKey, $updateData);
             //Notification message
             $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('success', translate_admin('Help updated successfully')));
             redirect_admin('help/viewhelp');
         }
     }
     //If - Form Submission End
     //Set Condition To Fetch The Faq Category
     $condition = array('help.id' => $id);
     //Get Groups
     $data['helps'] = $this->help_model->gethelps($condition);
     if ($data['helps']->num_rows() == 0) {
         $this->session->set_flashdata('flash_message', $this->Common_model->admin_flash_message('error', translate_admin('This help already deleted.')));
         redirect_admin('help/viewhelp');
     }
     //Load View
     $data['message_element'] = "administrator/help/edithelp";
     $this->load->view('administrator/admin_template', $data);
 }
 /**
  * Index
  *
  * Display's the matches
  *
  * @access	public
  * @return	void
  */
 function index()
 {
     // Load the Matches model
     $this->CI->load->model('Matches_model', 'matches');
     // Load the Squads model
     $this->CI->load->model('Squads_model', 'squads');
     // Check the match type
     if ((bool) $this->setting['matches_type']) {
         // Retrieve the upcoming matches
         $matches = $this->CI->matches->get_matches($this->setting['matches_number'], '', array('match_date >' => mdate('%Y-%m-%d %H:%i:%s', local_to_gmt(time()))));
     } else {
         // Retrieve the latest matches
         $matches = $this->CI->matches->get_matches($this->setting['matches_number'], '', array('match_date <' => mdate('%Y-%m-%d %H:%i:%s', local_to_gmt(time()))));
     }
     // Check if matches exist
     if ($matches) {
         // Matches exist, loop through each match
         foreach ($matches as $match) {
             // Select proper opponent
             if ((bool) $match->match_source) {
                 // Opponent is Internal Squad
                 $opponent = $this->CI->squads->get_squad(array('squad_id' => $match->opponent_id));
                 // Check if opponent exists
                 if ($opponent) {
                     // Opponent exists, assign match opponent
                     $match->opponent = $opponent->squad_title;
                     $match->opponent_slug = $opponent->squad_slug;
                 } else {
                     // Opponent doesn't exist, don't assign it
                     $match->opponent = "";
                     $match->opponent_slug = "";
                 }
             } else {
                 //Oppoenent is external
                 $opponent = $this->matches->get_opponent(array('opponent_id' => $match->opponent_id));
                 // Check if opponent exists
                 if ($opponent) {
                     // Opponent exists, assign match opponent
                     $match->opponent = $opponent->opponent_title;
                     $match->opponent_slug = $opponent->opponent_slug;
                 } else {
                     // Opponent doesn't exist, don't assign it
                     $match->opponent = "";
                     $match->opponent_slug = "";
                 }
             }
             // Retrieve match date, format timezone & assign match date
             $match->date = $this->CI->ClanCMS->timezone($match->match_date);
         }
     }
     // Create a reference to matches & setting
     $this->data->matches =& $matches;
     $this->data->setting = $this->setting;
     // Assign the widget info
     $widget->title = '';
     $widget->content = $this->CI->load->view('widgets/matches', $this->data, TRUE);
     // Check the match type
     if ((bool) $this->setting['matches_type']) {
         $widget->tabs = array(array('title' => 'MATCHES', 'link' => 'matches', 'selected' => FALSE), array('title' => 'UPCOMING MATCHES', 'link' => 'matches/upcoming', 'selected' => TRUE));
     } else {
         $widget->tabs = array(array('title' => 'MATCHES', 'link' => 'matches', 'selected' => TRUE), array('title' => 'UPCOMING MATCHES', 'link' => 'matches/upcoming', 'selected' => FALSE));
     }
     // Load the widget view
     $this->CI->load->view(WIDGET . 'widget', $widget);
 }
Esempio n. 26
0
function _mdate($str, $stamp = '')
{
    $stamp = $stamp ? local_to_gmt($stamp) : now();
    $local_stamp = gmt_to_local($stamp, ci()->system_settings['timezones']);
    return gmdate($str, $local_stamp);
}
Esempio n. 27
0
 public function list_photo()
 {
     $room_id = $this->input->get('room_id');
     $filename = dirname($_SERVER['SCRIPT_FILENAME']) . '/images/' . $room_id;
     if (!file_exists($filename)) {
         mkdir(dirname($_SERVER['SCRIPT_FILENAME']) . '/images/' . $room_id, 0777, true);
     }
     $file_element_name = "uploadedfile";
     $config['upload_path'] = "./images/{$room_id}";
     $config['allowed_types'] = 'gif|jpg|png';
     $config['remove_spaces'] = TRUE;
     $config['max_size'] = 102400 * 8;
     $config['encrypt_name'] = FALSE;
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload($file_element_name)) {
         echo $this->upload->display_errors();
     } else {
         $upload_data = $this->upload->data();
         $image_name = $upload_data['file_name'];
         $insertData['list_id'] = $room_id;
         $insertData['name'] = $image_name;
         $insertData['created'] = local_to_gmt();
         $check = $this->db->where('list_id', $room_id)->get('list_photo');
         $photo_status['photo'] = 1;
         $this->db->where('id', $room_id)->update('lys_status', $photo_status);
         if ($check->num_rows() == 0) {
             $insertData['is_featured'] = 1;
         } else {
             $insertData['is_featured'] = 0;
         }
         if ($image_name != '') {
             $this->Common_model->insertData('list_photo', $insertData);
         }
         //$this->watermark($room_id,$image_name);
         $list_photo = $this->db->where('list_id', $room_id)->order_by('id', 'asc')->get('list_photo');
         if ($list_photo->num_rows() != 0) {
             foreach ($list_photo->result() as $row) {
                 $data['image_url'] = base_url() . "images/" . $room_id . "/" . $row->name;
             }
         }
         $this->watermark($room_id, $image_name);
         $this->watermark1($room_id, $image_name);
         echo json_encode($data);
         exit;
     }
 }
Esempio n. 28
0
 public function test_local_to_gmt()
 {
     $this->assertEquals(mktime(gmdate('G', $this->time), gmdate('i', $this->time), gmdate('s', $this->time), gmdate('n', $this->time), gmdate('j', $this->time), gmdate('Y', $this->time)), local_to_gmt($this->time));
 }
Esempio n. 29
0
 public function mobile_save_verify()
 {
     //$now = time();
     //$gmt = local_to_gmt($now);
     //$date_now = date('Y-d-m H:i:s',$gmt);
     $i = 0;
     //print_r($_POST['myRadio'][$i]);
     $now = time();
     $gmt = local_to_gmt($now);
     $date_now = date('Y-m-d H:i:s', $gmt);
     $i = 0;
     foreach ($_POST['id'] as $key) {
         //Add New Data Verify
         $data = array('std_id' => $key, 'ver_id' => $_POST['ver_id'], 'dep_id' => $_POST['dep_id'], 'ver_sta_id' => $_POST['myRadio'][$i], 'maj_id' => $_POST['maj_id'], 'ter_id' => $_POST['ter_id'], 'yea_title' => $_POST['yea_title'], 'usr_id' => $this->session->userdata('usr_id'), 'log_time' => $date_now, 'sitekey' => md5($date_now));
         $this->Verifys_model->save_verify_checked($data);
         $i++;
     }
     //print_r($_POST['id'][0]);
     exit;
 }
Esempio n. 30
0
 public function review_by_traveller($param = '')
 {
     if ($this->input->post()) {
         $reservation_id = $this->input->post('reservation_id');
         $review = $this->input->post('review');
         $feedback = $this->input->post('feedback');
         $cleanliness = $this->input->post('cleanliness');
         $communication = $this->input->post('communication');
         $accuracy = $this->input->post('accuracy');
         $checkin = $this->input->post('checkin');
         $location = $this->input->post('location');
         $value = $this->input->post('value');
         $updateKey = array('id' => $reservation_id);
         $updateData = array();
         $updateData['status '] = 10;
         $this->Trips_model->update_reservation($updateKey, $updateData);
         $conditions = array('reservation.id' => $reservation_id);
         $row = $this->Trips_model->get_reservation($conditions)->row();
         $username = ucfirst($this->dx_auth->get_username());
         $insertData = array('list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'userby' => $row->userto, 'userto' => $row->userby, 'message' => "{$username} gives the reviews for you.", 'created' => local_to_gmt(), 'message_type ' => 4);
         //$this->Message_model->sentMessage($insertData);
         $insertDataR = array('userby' => $row->userby, 'userto' => $row->userto, 'list_id' => $row->list_id, 'reservation_id' => $reservation_id, 'review' => $review, 'feedback' => $feedback, 'cleanliness' => $cleanliness, 'communication' => $communication, 'accuracy' => $accuracy, 'checkin' => $checkin, 'location' => $location, 'value' => $value, 'created' => local_to_gmt());
         $this->Trips_model->insertReview($insertDataR);
         //Update The Review Cout
         $no_review = get_list_by_id($row->list_id)->review;
         $update_r = $no_review + 1;
         $data = array('review' => $update_r);
         $this->db->where('id', $row->list_id);
         $this->db->update('list', $data);
         $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Your review saved successfully.')));
         redirect('hosting/my_reservation');
     } else {
         if (isset($param)) {
             $reservation_id = $param;
             $conditions = array('reservation.id' => $reservation_id, 'reservation.userby' => $this->dx_auth->get_user_id());
             $result = $this->Trips_model->get_reservation($conditions);
             if ($result->num_rows() == 0) {
                 redirect('info');
             }
             if ($result->row()->status != 9) {
                 redirect('trips/traveler_review/' . $reservation_id);
             }
             $data['reservation_id'] = $param;
             $data['title'] = get_meta_details('Review', 'title');
             $data["meta_keyword"] = get_meta_details('Review', 'meta_keyword');
             $data["meta_description"] = get_meta_details('Review', 'meta_description');
             $data['message_element'] = 'trips/view_review_traveller';
             $this->load->view('template', $data);
         } else {
             redirect('info');
         }
     }
 }