/**
   * Function create a new user account in the users_table. 
   * 
   * 
   * @return file
   */
  function addAccount()
  {
      $displayname = $_POST['txtdisname'];
      $firstname = $_POST['txtfname'];
      $lastname = $_POST['txtlname'];
      $email = $_POST['txtemail'];
      $pswd = $_POST['txtpwd'];
      $newsletter = $_POST['chknewsletter'];
      $date = date('Y-m-d');
      //address details
      $address = $_POST['txtaddr'];
      $city = $_POST['txtcity'];
      $state = $_POST['txtState'];
      $zipcode = $_POST['txtzipcode'];
      $country = $_POST['selCountry'];
      $group = $_POST['getGroup'];
      if ($newsletter == '') {
          $newsletter = 0;
      }
      if (count($Err->messages) > 0) {
          $output['val'] = $Err->values;
          $output['msg'] = $Err->messages;
      } else {
          if ($displayname != '' and $firstname != '' and $lastname != '' and $email != '' and $pswd != '') {
              $pswd = md5($pswd);
              $sql = "insert into users_table (user_display_name,user_fname,user_lname,user_email,user_pwd,user_status,user_doj,user_country,user_group) values('" . $displayname . "','" . $firstname . "','" . $lastname . "','" . $email . "','" . $pswd . "',1,'" . $date . "','" . $country . "','" . $group . "')";
              $obj = new Bin_Query();
              if ($obj->updateQuery($sql)) {
                  //add address detail in address book
                  $sq = "select user_id from users_table where user_email='{$email}' and user_pwd='{$pswd}'";
                  $qry1 = new Bin_Query();
                  $qry1->executeQuery($sq);
                  if (count($qry1->records) > 0) {
                      $newuserid = $qry1->records[0]['user_id'];
                      $adrsql = "insert into addressbook_table(user_id,contact_name,first_name,last_name,company,email,address,city,suburb,state,country,zip,phone_no,fax) values({$newuserid},'{$displayname}','{$firstname}','{$lastname}','','{$email}','{$address}','{$city}','','{$state}','{$country}','{$zipcode}','','')";
                      $qry1->updateQuery($adrsql);
                      $sql = "insert into newsletter_subscription_table(email,status)values('" . $email . "'," . $newsletter . ")";
                      if ($obj->updateQuery($sql)) {
                          $result = '<div class="alert alert-success">
 					<button type="button" class="close" data-dismiss="alert">×</button> <strong> well done !</strong> Account has been Created Successfully</div>';
                          $sqllogo = "select set_id,site_logo,site_moto,admin_email from admin_settings_table where set_id='1'";
                          $objlogo = new Bin_Query();
                          $objlogo->executeQuery($sqllogo);
                          $site_logo = $objlogo->records[0]['site_logo'];
                          $site_title = $objlogo->records[0]['site_moto'];
                          $admin_email = $objlogo->records[0]['admin_email'];
                          //select mail setting
                          $sqlMail = "SELECT * FROM mail_messages_table WHERE mail_msg_id=1 AND mail_user='******'";
                          $objMail = new Bin_Query();
                          $objMail->executeQuery($sqlMail);
                          $message = $objMail->records[0]['mail_msg'];
                          $title = $objMail->records[0]['mail_msg_title'];
                          $subject = $objMail->records[0]['mail_msg_subject'];
                          $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
                          $dir = dirname($_SERVER['PHP_SELF']) == "\\" ? '' : dirname($_SERVER['PHP_SELF']);
                          $site = $protocol . $_SERVER['HTTP_HOST'] . $dir;
                          $site_logo = $site . '/' . $site_logo;
                          $site_logo = $site_logo;
                          $message = str_replace("[title]", $site_title, $message);
                          $message = str_replace("[logo]", $site_logo, $message);
                          $message = str_replace("[firstname]", $firstname, $message);
                          $message = str_replace("[lastname]", $lastname, $message);
                          $message = str_replace("[user_name]", $email, $message);
                          $message = str_replace("[password]", $_POST['txtpwd'], $message);
                          $message = str_replace("[site_email]", $admin_email, $message);
                          Core_CAdminUserRegistration::sendingMail($email, $title, $message);
                          echo "<script> top.location = top.location; </script>";
                      } else {
                          $result = '<div class="alert alert-error">
  					<button type="button" class="close" data-dismiss="alert">×</button> Account Not Created</div>';
                      }
                  } else {
                      $result = '<div class="alert alert-error">
 					 <button type="button" class="close" data-dismiss="alert">×</button> Account Not Created</div>';
                  }
              } else {
                  $result = '<div class="alert alert-error">
 				 <button type="button" class="close" data-dismiss="alert">×</button> Account Not Created</div>';
              }
          }
      }
      return $result;
  }
 /**
  * Function is used to view the customer details page
  * 
  * 
  * @return array
  */
 function customerDetail()
 {
     include 'classes/Core/CAdminHome.php';
     include 'classes/Display/DAdminHome.php';
     include 'classes/Core/CAdminUserRegistration.php';
     include 'classes/Core/CRoleChecking.php';
     include 'classes/Display/DAdminUserRegistration.php';
     $output['monthlyorders'] = (int) Core_CAdminHome::monthlyOrders();
     $output['previousmonthorders'] = (int) Core_CAdminHome::previousMonthOrders();
     $output['totalorders'] = (int) Core_CAdminHome::totalOrders();
     $output['currentmonthuser'] = (int) Core_CAdminHome::currentMonthUser();
     $output['previousmonthuser'] = (int) Core_CAdminHome::previousMonthUser();
     $output['totalusers'] = (int) Core_CAdminHome::totalUsers();
     $output['currentmonthincome'] = Core_CAdminHome::currentMonthIncome();
     $output['previousmonthincome'] = Core_CAdminHome::previoustMonthIncome();
     $output['totalincome'] = Core_CAdminHome::totalIncome();
     $output['currentmonthproudctquantity'] = (int) Core_CAdminHome::currentMonthProudctQuantity();
     $output['previousmonthproudctquantity'] = (int) Core_CAdminHome::previousMonthProudctQuantity();
     $output['totalproudctquantity'] = (int) Core_CAdminHome::totalProudctQuantity();
     $output['lowstock'] = (int) Core_CAdminHome::lowStock();
     $output['totalproducts'] = (int) Core_CAdminHome::totalProducts();
     $output['enabledproducts'] = (int) Core_CAdminHome::enabledProducts();
     $output['disabledproducts'] = (int) Core_CAdminHome::disabledProducts();
     $output['pendingorders'] = (int) Core_CAdminHome::pendingOrders();
     $output['processingorders'] = (int) Core_CAdminHome::processingOrders();
     $output['deliveredorders'] = (int) Core_CAdminHome::deliveredOrders();
     $chkuser = Core_CRoleChecking::checkRoles();
     if ($chkuser) {
         $output['cusotmerdetail'] = Core_CAdminUserRegistration::customerDetail();
         Bin_Template::createTemplate('customerdetail.html', $output);
     } else {
         $output['usererr'] = 'You are Not having Privilege to view this page contact your Admin for detail';
         Bin_Template::createTemplate('Errors.html', $output);
     }
 }