public function registerAction()
 {
     if ($_POST['submit'] == 'Submit' or $_POST['submit'] == 'submit') {
         $customerType = $_POST['customerType'];
         $icno = $_POST['icno'];
         $name = $_POST['name'];
         $accountno = $_POST['accountNo'];
         $mobileno = $_POST['mobileNo'];
         $local = $_POST['isLocal'];
         $nric = $_POST['NRIC'];
         $mailing = $_POST['mailingAddress'];
         $delivery = $_POST['deliveryAddress'];
         $gender = $_POST['gender'];
         $race = $_POST['race'];
         $dob = $_POST['dob'];
         $nationality = $_POST['nationality'];
         $billing = $_POST['billingOptions'];
         $postcode = $_POST['Postcode'];
         $city = $_POST['city'];
         $state = $_POST['state'];
         $country = $_POST['country'];
         $email = $_POST['emailAddress'];
         $password = $_POST['password'];
         $namakey = str_replace(' ', '_', $name) . "_" . strtotime(date("YmdHis"));
         $register = new Object_Customer();
         $register->setcustomerType($customerType);
         $register->seticno($icno);
         $register->setname($name);
         $register->setaccountNo($accountno);
         $register->setmobileNo($mobileno);
         $register->setisLocal($local);
         $register->setNRIC($nric);
         $register->setmailingAddress($mailing);
         $register->setdeliveryAddress($delivery);
         $register->setgender($gender);
         $register->setrace($race);
         $register->setdob($dob);
         $register->setnationality($nationality);
         $register->setbillingOptions($billingOptions);
         $register->setPostcode($postcode);
         $register->setcity($city);
         $register->setstate($state);
         $register->setcountry($country);
         $register->setemailAddress($email);
         $register->setKey(strtolower($namakey));
         $register->setO_parentId('47');
         $register->setIndex(0);
         $register->setPublished(1);
         $register->save();
         /* $emailDocument = "'".$_COOKIE['languagecode']."'/emailcontactus";
             print_r($emailDocument);
             $params = array('fullname' => $fname,
             'subject' => $subject,
             'email' => $email,
             'phone' => $phone,
             'location' => $location,
             'message' => $message
             );
             $mail->setDocument($emailDocument);
             $mail->setParams($params);
            */
         // $this->view->sm = '<div style="width:87%; padding: 10px; margin:5px 0; height: auto; border:2px solid #ddd; font-size:12px; background:#e6efc2; color:#264409; border-color:#c6d880; font-size:12px;">Your message has been successfully sent. Thank you for your confidence in us.</div>';
         $customerType = "";
         $icno = "";
         $name = "";
         $accountno = "";
         $mobileno = "";
         $local = "";
         $nric = "";
         $mailing = "";
         $delivery = "";
         $gender = "";
         $race = "";
         $dob = "";
         $nationality = "";
         $billing = "";
         $postcode = "";
         $city = "";
         $state = "";
         $country = "";
         $email = "";
         $password = "";
         $_POST['submit'] = "";
     }
     $this->enableLayout();
 }
 public function addAction()
 {
     $valid = true;
     $username = $_POST['username'];
     $password = $_POST['password'];
     $name = $_POST['name'];
     $address = $_POST['address'];
     $email = $_POST['email'];
     $delivery_address = $_POST['delivery_address'];
     $mailing_address = $_POST['mailing_address'];
     $race = $_POST['race'];
     $nationality = $_POST['nationality'];
     $passport = $_POST['passport'];
     $postcode = $_POST['postcode'];
     $city = $_POST['city'];
     $state = $_POST['state'];
     $country = $_POST['country'];
     $mobile = $_POST['mobile'];
     $gender = $_POST['gender'];
     $dob = $_POST['dob'];
     $dateofbirth = strtotime($dob);
     $date_ob = new Pimcore_Date($dateofbirth);
     $namekey = str_replace(' ', '_', $name) . "_" . strtotime(date("YmdHis"));
     $getRaceObj = Object_Abstract::getById($race);
     $getNationalityObj = Object_Abstract::getById($nationality);
     $getCountryObj = Object_Abstract::getById($country);
     $return_array = array();
     // $cekuser   = new Object\Customer\Listing();
     // $cekuser->setCondition("username = '******'");
     // if($cekuser->Count() >= 1 )
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'username is already used';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // if($username == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Username is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($password == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Password is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($name == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Name is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($address == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Address is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($email == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Email is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($delivery_address == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Delivery Address is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($mailing_address == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Mailing Address is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($race == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Race is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     // else if($nationality == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Nationality is required';
     //     $return_array['data']       = '';
     //     $valid = false;
     // }
     if ($valid) {
         $addregister = array();
         $addregister = new Object_Customer();
         $addregister->setusername($username);
         $addregister->setpassword($password);
         $addregister->setname($name);
         $addregister->setaddress($address);
         $addregister->setemailAddress($email);
         $addregister->setdeliveryAddress($delivery_address);
         $addregister->setmailingAddress($mailing_address);
         $addregister->setrace($getRaceObj);
         $addregister->setnationality($getNationalityObj);
         $addregister->setpassportNo($passport);
         $addregister->setPostcode($postcode);
         $addregister->setcity($city);
         $addregister->setstate($state);
         $addregister->setcountry($getCountryObj);
         $addregister->setmobileNo($mobile);
         $addregister->setgender($gender);
         $addregister->setdob($date_ob);
         $getPath = Object_Abstract::getByPath('/customers');
         $addregister->setKey(strtolower($namekey));
         $addregister->setO_parentId($getPath->o_id);
         $addregister->setIndex(0);
         $addregister->setPublished(1);
         $addregister->save();
         $return_array['status'] = 'success';
         $return_array['message'] = 'Thank you for your registration';
         $return_array['data'] = $addregister;
     }
     $json_customer = $this->_helper->json($return_array);
     Website_P1GlobalFunction::sendResponse($json_customer);
     $this->sendResponse($json_customer);
 }
 public function createuserAction()
 {
     // $errorMsg = "";
     error_reporting(1);
     $password = rand(8, 12);
     $content = $_POST['data'];
     $requestedData = json_decode($content);
     if ($this->checkExists($requestedData)) {
         if ($this->authenicateUserAPIKey($requestedData->auth)) {
             if (empty($requestedData->NRIC_PP) || !isset($requestedData->NRIC_PP) && $this->checkExists($requestedData->NRIC_PP)) {
                 $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                 echo json_encode($json);
                 exit;
             } else {
                 if (empty($requestedData->IDType) || !isset($requestedData->IDType) && $this->checkExists($requestedData->IDType)) {
                     $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                     echo json_encode($json);
                     exit;
                 } else {
                     if (empty($requestedData->Username) || !isset($requestedData->Username) && $this->checkExists($requestedData->Username)) {
                         $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                         echo json_encode($json);
                         exit;
                     } else {
                         if (empty($requestedData->Fullname) || !isset($requestedData->Fullname) && $this->checkExists($requestedData->Fullname)) {
                             $json = array('code' => "REG003-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided.");
                             echo json_encode($json);
                             exit;
                         }
                     }
                 }
             }
             //                else if (!preg_match($email_reg, $requestedData->Username)) {
             //                    $json = array('code' => "REG003-202", 'ErrorMsg' => "Please check all fields are provided correct.");
             //                    echo json_encode($json);
             //                    exit;
             //                }
             //                else if (!preg_match($email_reg, $requestedData->Username)) {
             //                    $json = array('code' => "REG003-202", 'ErrorMsg' => "Please check all fields are provided correct.");
             //                    echo json_encode($json);
             //                    exit;
             //                }
             $addregister = array();
             $addregister = new Object_Customer();
             $namekey = str_replace(' ', '_', $requestedData->Fullname) . "_" . strtotime(date("YmdHis"));
             $addregister->setUsername($requestedData->Username);
             $addregister->setNRIC_PP($requestedData->NRIC_PP);
             $addregister->setPassword(md5($password));
             $addregister->setFullname($requestedData->Fullname);
             if (strtoupper($requestedData->IDType) != "PASSPORT") {
                 $addregister->setnationality("Malaysia");
                 $getNationalityObj = Object_Abstract::getById("Malaysia");
             }
             $getPath = Object_Abstract::getByPath('/customers');
             $addregister->setKey(strtolower($namekey));
             $addregister->setO_parentId($getPath->o_id);
             $addregister->setIndex(0);
             $addregister->setPublished(1);
             $response = $addregister->save();
             if ($this->checkExists($response)) {
                 $json = array('code' => "REG003-200", 'status' => "Success");
                 echo json_encode($json);
                 //   $this->sendemail($password, $requestedData->Username);
                 exit;
             } else {
                 $json = array('code' => "REG003-206", 'status' => "Unable to connect to server");
                 echo json_encode($json);
                 exit;
             }
         } else {
             $json = array('code' => "REG003-201", 'ErrorMsg' => "Invalid authentication");
             echo json_encode($json);
             exit;
         }
     } else {
         $json = array('code' => "REG003-203", 'status' => "failure", 'ErrorMsg' => "Json format is incorrect.");
         echo json_encode($json);
         exit;
     }
 }