/** * Handles what happens when user moves to URL/test/index */ public function index() { //test FPDF $pdf = new FPDF(); //test pagination class $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; // instantiate; set current page; set number of records $pagination = new Pagination(); $pagination->setCurrent($page); $pagination->setTotal(200); $markup = $pagination->parse(); echo $markup . "\n\n\n"; echo "\n\n\nGET ALL SERVICES:\n\n"; $service_model = new ServiceModel($this->logger); print_r($service_model->getServices()); $response = $service_model->getService('6013992000001494'); echo "\n\n\nQUERY SERVICE\n\n"; print_r($response); $service = $response['service']; $service->short_code = '29333'; $service->criteria = 'Love'; $service->correlator = '20150417172519'; $service->service_name = 'Service name after update'; $response = $service_model->updateService(json_decode(json_encode($service), true)); echo "\n\n\nUPDATE SERVICE\n\n"; print_r($response); //print_r($service); //$response2 = ServiceModel::getAllServices(); //echo "All Services\n\n\n"; //print_r(ServiceModel::getAllServices()); echo "\n\n\nDELETE SERVICE:\n\n"; print_r($service_model->deleteService('6013992000001495')); //echo "\n\n\nADD SERVICE:\n\n"; //print_r($service_model->addService(array('service_id' => '6013992000001495', 'service_name' => 'Test service', 'service_type'=>1, 'short_code' => '29678', 'criteria' => '', 'service_endpoint' => 'http://192.168.0.16/pardus/notify/sms/', 'delivery_notification_endpoint' => 'http://192.168.0.16/pardus/delivery/receipt/', 'interface_name' => 'notifySmsReception', 'correlator' => '34234234', 'status' => 0,'last_updated_by' => '2'))); $model = new MessageModel($this->logger); echo "\n\n\nGET INBOUND MESSAGES:\n\n"; //print_r(MessageModel:: getInboundMessages('2015-04-21 08:38:36', ''2015-04-21 08:38:39'', $subscriber_id='', $short_code='', $service_id='', $start_index=0, $limit=10)); print_r($model->getInboundMessages('2015-04-21 08:38:36', '2016-04-21 08:38:37', '', '', '', 0, 2)); echo "\nGET OUTBOUND MESSAGES:\n\n"; //print_r(MessageModel:: getInboundMessages('2015-04-21 08:38:36', ''2015-04-21 08:38:39'', $subscriber_id='', $short_code='', $service_id='', $start_index=0, $limit=10)); print_r($model->getOutboundMessages('2015-04-21 08:38:52', '2016-04-21 08:38:59', '', '', '', '', 0, 2)); echo "\nGET SUBSCRIPTION MESSAGES:\n\n"; //$start_date, $end_date, $subscriber_id='', $service_id='', $product_id='', $update_type='', $start_index=0, $limit=10 print_r($model->getSubscriptionMessages('2015-04-15 17:00:04', '2016-04-15 17:29:43', '', '', '', '', 0, 2)); echo "\nGET DELIVERY MESSAGES:\n\n"; //$start_date, $end_date, $subscriber_id='', $correlator='', $start_index=0, $limit=10 print_r($model->getDeliveryMessages('2015-04-20 15:00:54', '2016-04-20 15:15:54', '', '', 0, 2)); //render the view and pass the raw post data $this->View->renderWithoutHeaderAndFooter('test/index', array('test' => 'This is a test page.')); }
/** * Handles what happens when user moves to URL/service/all. This returns all servives in the system. */ public function all() { /* Initialize the request data */ //get request data $service_id = Request::get('service_id'); $service_type = Request::get('service_type'); $short_code = Request::get('short_code'); $page = null !== Request::get('page') ? (int) Request::get('page') : 1; //page - default is 1 $rpp = (int) Config::get('RECORDS_PER_PAGE'); //records per page $start_record = (int) (($page - 1) * $rpp); // start record //request data to be used in calling the model $data = array('service_id' => $service_id, 'service_type' => $service_type, 'short_code' => $short_code, 'page' => $page, 'rpp' => $rpp, 'start_record' => $start_record); //log the event $this->logger->debug('{class_mame}|{method_name}|{service_id}|request-request|{data}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'data' => json_encode($data))); $service_model = new ServiceModel($this->logger); $result = $service_model->getServices($service_id, $service_type, $short_code, $start_record, Config::get('RECORDS_PER_PAGE')); $data['result'] = $result; //add some pagination logic here $total_records = isset($result['_totalRecords']) ? $result['_totalRecords'] : 0; $pagination = new Pagination(); $pagination->setCurrent($page); $pagination->setTotal($total_records); $markup = $pagination->parse(); $data['markup'] = $markup; //success if ($result['result'] == 0) { $this->View->render('servicemanager/all', $data); } else { $this->View->render('error/loaderror', $result['resultDesc']); } //log the event $this->logger->debug('{class_mame}|{method_name}|{service_id}|result|{result}|{result_desc}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'result' => $result['result'], 'result_desc' => $result['resultDesc'])); }
/** * Handles what happens when user moves to URL/service/all. This returns all servives in the system. */ public function subscriptions() { /* Initialize the request data */ //get request data $subscriber_id = Request::get('subscriber_id'); $service_id = Request::get('service_id'); $product_id = Request::get('product_id'); $update_type = Request::get('update_type'); $start_date = Request::get('start_date'); $end_date = Request::get('end_date'); $page = null !== Request::get('page') ? (int) Request::get('page') : 1; //page - default is 1 $rpp = (int) Config::get('RECORDS_PER_PAGE'); //records per page $start_record = (int) (($page - 1) * $rpp); // start record //set default start date - 1 month ago if (!isset($start_date) || $start_date == '') { $date = date_create(date('Y-m-d')); date_sub($date, date_interval_create_from_date_string('1 months')); $start_date = date_format($date, 'Y-m-d'); } //set default end date - current day if (!isset($end_date) || $end_date == '') { $end_date = date('Y-m-d'); } //request data to be used in calling the model $data = array('subscriber_id' => $subscriber_id, 'service_id' => $service_id, 'product_id' => $product_id, 'update_type' => $update_type, 'start_date' => $start_date, 'end_date' => $end_date); //log the event $this->logger->debug('{class_mame}|{method_name}|request|request-data:{data}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'data' => json_encode($data))); //call the model $model = new MessageModel($this->logger); $result = $model->getSubscriptionMessages($start_date . ' 00:00:00', $end_date . ' 23:59:59', $subscriber_id, $service_id, $product_id, $update_type, $start_record, Config::get('RECORDS_PER_PAGE')); //add result $data['result'] = $result; //add some pagination logic here $total_records = isset($result['_totalRecords']) ? $result['_totalRecords'] : 0; $pagination = new Pagination(); $pagination->setCurrent($page); $pagination->setTotal($total_records); $markup = $pagination->parse(); $data['markup'] = $markup; $this->View->render('messages/subscriptions', $data); //log the event $this->logger->info('{class_mame}|{method_name}|result|{result}|result_desc:{result_desc}', array('class_mame' => __CLASS__, 'method_name' => __FUNCTION__, 'result' => $result['result'], 'result_desc' => $result['resultDesc'])); }