/** * 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.')); }
public function subscriptions_pdf() { /* 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'); //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, 0, Config::get('MAX_RECORDS_PDF')); //add result $data['result'] = $result; //print_r($result); //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); $title = "Subscription Requests Extract - Subscriber: {$subscriber_id}, Service ID: {$service_id}, Product ID: {$product_id}, Update Type: {$update_type}, Start Date: {$start_date}, End Date: {$end_date}"; $headers = array('#', 'Subscriber', 'Service ID', 'Product ID', 'Update Type', 'Effective Time', 'Expiry Time', 'Processing Time'); $sizes = array(15, 43, 40, 40, 35, 35, 35, 35); $max_sizes = array(10, 30, 28, 28, 30, 25, 25, 25); $data = array(); $filename = __FUNCTION__ . '_' . Session::get('user_name') . '_' . date('YmdHis') . '.pdf'; $i = 0; foreach ($result['messages'] as $message) { $data[$i] = array($message->id, $message->subscriber_id, $message->service_id, $message->product_id, $message->update_desc, $message->effective_time, $message->expiry_time, $message->created_on); $i++; } $pdf = new PDF($title, $data, $headers, $sizes, $max_sizes); $pdf->Output($filename, 'I'); //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'])); }