Ejemplo n.º 1
0
 function send_sms_notification($data)
 {
     $CI =& get_instance();
     $CI->load->model('User_model', 'user');
     $CI->load->model('Siteconfig_model', 'siteconfig');
     $CI->load->library('tidiitsms');
     /*
         $notify['senderId'] = ;
         $notify['receiverId'] = ;
         $notify['nType'] = ;
         $notify['nTitle'] = ;
         $notify['nMessage'] = ;
     */
     $SMS_SEND_ALLOW = $CI->siteconfig->get_value_by_name('SMS_SEND_ALLOW');
     if ($SMS_SEND_ALLOW == 'yes') {
         $smsLogPath = MAIN_SERVER_RESOURCES_PATH . 'sms_log/' . date('d-m-Y') . '/';
         if (!is_dir($smsLogPath)) {
             //create the folder if it's not already exists
             @mkdir($smsLogPath, 0755, TRUE);
         }
         //die('rrr');
         if (!array_key_exists('receiverMobileNumber', $data)) {
             return FALSE;
         } elseif ($data['receiverMobileNumber'] == "") {
             return FALSE;
         } else {
             $dataMessage = $data['nMessage'] . ' message send mobile no ' . $data['receiverMobileNumber'];
             $smsLogFile = $smsLogPath . time() . uniqid() . '.txt';
             if (!write_file($smsLogFile, $dataMessage)) {
                 //echo 'Unable to write the file';
             } else {
                 //echo 'File written!';
             }
             //Send Mobile message
             $smsAddHistoryDataArr = array();
             $smsConfig = array('sms_text' => $data['nMessage'], 'receive_phone_number' => $data['receiverMobileNumber']);
             $smsResult = $CI->tidiitsms->send_sms($smsConfig);
             send_normal_push_notification($data);
             if (!array_key_exists('senderId', $data)) {
                 $data['senderId'] = "";
             }
             if (!array_key_exists('receiverId', $data)) {
                 $data['receiverId'] = "";
             }
             if (!array_key_exists('senderMobileNumber', $data)) {
                 $data['senderMobileNumber'] = "";
             }
             if (!array_key_exists('nType', $data)) {
                 $data['nType'] = "";
             }
             $smsAddHistoryDataArr = array('senderUserId' => $data['senderId'], 'receiverUserId' => $data['receiverId'], 'senderPhoneNumber' => $data['senderMobileNumber'], 'receiverPhoneNumber' => $data['receiverMobileNumber'], 'IP' => $CI->input->ip_address(), 'sms' => $data['nMessage'], 'sendActionType' => $data['nType'], 'smsGatewaySenderId' => $CI->siteconfig->get_value_by_name('SMS_GATEWAY_SENDERID'), 'smsGatewayReturnData' => $smsResult);
             $CI->user->add_sms_history($smsAddHistoryDataArr);
         }
     }
 }
Ejemplo n.º 2
0
 function decline_buying_club_order_invite_post()
 {
     $orderId = $this->post('orderId');
     $productId = $this->post('productId');
     $productPriceId = $this->post('productPriceId');
     $orderId = $this->post('orderId');
     $userId = $this->post('userId');
     $notificationId = $this->post('notificationId');
     $latitude = $this->post('latitude');
     $longitude = $this->post('longitude');
     $deviceType = $this->post('deviceType');
     $UDID = $this->post('UDID');
     $deviceToken = $this->post('deviceToken');
     if ($userId == "" || $latitude == "" || $longitude == "" || $deviceType == "" || $UDID == "" || $deviceToken == "" || $orderId == "" || $productId == "" || $productPriceId == "") {
         $this->response(array('error' => 'Please provide user index,order index,latitude,longitude,device id,device token,product index,product price index !'), 400);
         return FALSE;
     }
     $user = $this->user->get_details_by_id($userId)[0];
     if (empty($user)) {
         $this->response(array('error' => 'Please provide valid user index to process the invitation!'), 400);
         return FALSE;
     }
     $order = $this->order->get_single_order_by_id($orderId);
     if ($order->userId == $user->userId) {
         $this->response(array('error' => 'Please provide valid user index to accept the invitation!'), 400);
         return FALSE;
     }
     if (empty($order)) {
         $this->response(array('error' => 'Please provide valid order index to accept the invitation!'), 400);
         return FALSE;
     }
     $group = $this->user->get_group_by_id($order->groupId);
     $prod_price_info = $this->product->get_products_price_details_by_id($order->productPriceId);
     $a = $this->_get_available_order_quantity($orderId);
     $availQty = $prod_price_info->qty - $a[0]->productQty;
     $orderInfo = unserialize(base64_decode($order->orderInfo));
     if (!$availQty) {
         $this->response(array('error' => 'Order already completed by other members of this Buying Club.'), 400);
         return FALSE;
     }
     if (!$this->user->user_exists_on_group($userId, $order->groupId)) {
         $this->response(array('error' => 'You can not process this order because you are not member of this Buying Club.'), 400);
         return FALSE;
     }
     if ($order->parrentOrderID == 0) {
         $me = $user;
         foreach ($group->users as $key => $usr) {
             $mail_template_data = array();
             if ($me->userId != $usr->userId) {
                 $data['senderId'] = $userId;
                 $data['receiverId'] = $usr->userId;
                 $data['nType'] = 'BUYING-CLUB-ORDER-DECLINE';
                 $data['nTitle'] = 'Buying Club order [TIDIIT-OD-' . $order->orderId . '] cancel by <b>' . $me->firstName . ' ' . $me->lastName . '</b>';
                 $mail_template_data['TEMPLATE_GROUP_ORDER_DECLINE_ORDER_ID'] = $order->orderId;
                 $mail_template_data['TEMPLATE_GROUP_ORDER_DECLINE_ADMIN_NAME'] = $me->firstName . ' ' . $me->lastName;
                 $data['nMessage'] = "Hi, <br> Sorry! I can not process this Buying Club order right now.<br>";
                 $data['nMessage'] .= "";
                 $data['nMessage'] .= "Thanks <br> Tidiit Team.";
                 $data['isRead'] = 0;
                 $data['status'] = 1;
                 $data['createDate'] = date('Y-m-d H:i:s');
                 $data['appSource'] = $deviceType;
                 //Send Email message
                 $recv_email = $usr->email;
                 $sender_email = $me->email;
                 $mail_template_view_data = load_default_resources();
                 $mail_template_view_data['group_order_decline'] = $mail_template_data;
                 global_tidiit_mail($recv_email, "Buying Club order decline at Tidiit Inc Ltd", $mail_template_view_data, 'group_order_decline', $usr->firstName . ' ' . $usr->lastName);
                 $notificationId = $this->user->notification_add($data);
                 $push_not_data['receiverId'] = $group->admin->userId;
                 $push_not_data['nType'] = "BUYING-CLUB-ORDER-DECLINE";
                 $push_not_data['nTitle'] = 'New Buying Club Order Invitation';
                 $push_not_data['appSource'] = $deviceType;
                 //$push_not_data['orderId'] = $orderId;
                 $push_not_data['nMessage'] = 'You have invited to Buying Club[' . $group->groupTitle . '] by ' . $group->admin->firstName . ' ' . $group->admin->lastName . '.More details about this notifiaction,Check ' . $defaultResources['MainSiteBaseURL'];
                 send_normal_push_notification($push_not_data);
             }
         }
         $data['receiverId'] = $group->admin->userId;
         unset($data['nMessage']);
         $mail_template_view_data = load_default_resources();
         $defaultResources = $mail_template_view_data;
         $mail_template_data = array();
         $data['senderId'] = $userId;
         $data['nType'] = 'BUYING-CLUB-ORDER-DECLINE';
         $data['nTitle'] = 'Buying Club order [TIDIIT-OD-' . $order->orderId . '] cancel by <b>' . $me->firstName . ' ' . $me->lastName . '</b>';
         $mail_template_data['TEMPLATE_GROUP_ORDER_DECLINE_ORDER_ID'] = $order->orderId;
         $mail_template_data['TEMPLATE_GROUP_ORDER_DECLINE_ADMIN_NAME'] = $me->firstName . ' ' . $me->lastName;
         $data['nMessage'] = "Hi, <br> Sorry! I can not process this order right now.<br>";
         $data['nMessage'] .= "<a href='" . $defaultResources['MainSiteBaseURL'] . "shopping/group-re-order-process/" . base64_encode($orderId * 226201) . "' class='btn btn-warning btn-lg'>Re-order now</a><br><br>";
         $mail_template_data['TEMPLATE_GROUP_ORDER_DECLINE_ORDER_ID1'] = $orderId;
         $data['nMessage'] .= "Thanks <br> Tidiit Team.";
         $data['isRead'] = 0;
         $data['status'] = 1;
         $data['orderId'] = $orderId;
         $data['productId'] = $productId;
         $data['productPriceId'] = $productPriceId;
         $data['createDate'] = date('Y-m-d H:i:s');
         $data['appSource'] = $deviceType;
         //Send Email message
         $recv_email = $group->admin->email;
         $sender_email = $me->email;
         $mail_template_view_data = load_default_resources();
         $mail_template_view_data['group_order_decline'] = $mail_template_data;
         global_tidiit_mail($recv_email, "Buying Club order decline at Tidiit Inc Ltd", $mail_template_view_data, 'group_order_decline_admin', $group->admin->firstName . ' ' . $group->admin->lastName);
         $notificationId = $this->user->notification_add($data);
         $declient_data = array();
         $declient_data['acceptDeclineState'] = 2;
         $this->user->notification_edit($declient_data, $notificationId);
         $this->order->update(array('reOrder' => 1, 'cancelOrderUserId' => $userId), $orderId);
         /// sendin SMS to Leader
         $smsMsg = 'Buying Club[' . $group->groupTitle . ']  member[' . $usr->firstName . ' ' . $usr->lastName . '] has decline the invitation Tidiit order TIDIIT-OD-' . $order->orderId . '.';
         $sms_data = array('nMessage' => $smsMsg, 'receiverMobileNumber' => $orderInfo['group']->admin->mobile, 'senderId' => '', 'receiverId' => $orderInfo["group"]->admin->userId, 'senderMobileNumber' => '', 'nType' => $data['nType']);
         send_sms_notification($sms_data);
         $push_not_data['receiverId'] = $group->admin->userId;
         $push_not_data['nType'] = "BUYING-CLUB-ORDER-DECLINE";
         $push_not_data['nTitle'] = 'New Buying Club Order Invitation';
         $push_not_data['appSource'] = $deviceType;
         $push_not_data['notificationId'] = $notificationId;
         $push_not_data['nMessage'] = 'You have invited to Buying Club[' . $group->groupTitle . '] by ' . $group->admin->firstName . ' ' . $group->admin->lastName . '.More details about this notifiaction,Check ' . $defaultResources['MainSiteBaseURL'];
         send_push_notification($push_not_data);
     }
     $result = array();
     $result['message'] = 'Sorry for Buying Club order cancelation!';
     success_response_after_post_get($result);
 }
Ejemplo n.º 3
0
 function testing_send_normal_push_notification_get()
 {
     $dataArr = array('receiverId' => 100, 'nMessage' => 'testing push noificaion');
     send_normal_push_notification($dataArr);
 }