public function saveSettings()
 {
     $eqApp = new Apps();
     if ($_POST['name']) {
         $check_q = "SELECT * FROM crm_settings";
         $check_r = mysql_query($check_q);
         if (mysql_num_rows($check_r) == 0) {
             $eqApp->insertSql("crm_settings");
         } else {
             $eqApp->udpdateSql("crm_settings");
         }
     }
 }
 public function add()
 {
     if (isset($_POST['name'])) {
         $eqapp = new Apps();
         $getnumC_q = 'SELECT * FROM cms_plugins';
         $getnumC_r = mysql_query($getnumC_q);
         $getnumC_n = mysql_num_rows($getnumC_r);
         $_POST['sortorder'] = $getnumC_n + 1;
         $result = mysql_query("SHOW TABLE STATUS LIKE 'cms_plugins'");
         $row = mysql_fetch_array($result);
         $latest = $row['Auto_increment'];
         $eqapp->insertSql("cms_plugins");
         header('Location:' . _EQROOT_ . 'cms_plugins/edit/' . $latest);
     }
 }
 public function update()
 {
     //add or update company
     if (isset($_POST['name'])) {
         $eqapp = new Apps();
         $check_q = "SELECT * FROM settings";
         $check_r = mysql_query($check_q);
         if (mysql_num_rows($check_r) == 0) {
             //if a row doesnt exist, then add a row
             $eqapp->insertSql("settings");
         } else {
             //if a row does exist then update it
             $eqapp->udpdateSql("settings");
         }
     }
 }
 public function addUser()
 {
     $eqApp = new Apps();
     //function that adds a new user
     if (isset($_POST['fname']) && isset($_SESSION['x_equi'])) {
         //Run JSON header
         header('Content-type: application/json');
         $checkEmail_q = 'SELECT * FROM crm_users WHERE email = "' . $_POST['email'] . '"';
         $checkEmail_r = mysql_query($checkEmail_q);
         if (mysql_num_rows($checkEmail_r) > 0) {
             echo '{ "message": "fail" }';
         } else {
             $result = mysql_query("SHOW TABLE STATUS LIKE 'crm_users'");
             $row = mysql_fetch_array($result);
             $latest = $row['Auto_increment'];
             $eqApp->insertSql("crm_users");
             echo '{"message": "success","id": "' . $latest . '"}';
         }
         exit;
     }
 }
 public function addcat()
 {
     $eqApp = new Apps();
     if (isset($_POST['name'])) {
         header('Content-type: application/json');
         $getCat_q = 'SELECT * FROM crm_contacts_cats 
                      WHERE 
                      name = "' . $_POST['name'] . '"';
         $getCat_r = mysql_query($getCat_q);
         if (mysql_num_rows($getCat_r) > 0) {
             echo '{ "message": "error" }';
         } else {
             $eqApp->insertSql("crm_contacts_cats");
             $getLatest_q = 'SELECT * FROM crm_contacts_cats 
                             ORDER BY 
                             id DESC LIMIT 1';
             $getLatest_r = mysql_query($getLatest_q);
             $getLatest = mysql_fetch_array($getLatest_r);
             echo '{ "message": "success" , "id": "' . $getLatest['id'] . '"  }';
         }
         exit;
     }
 }
 public function addcat()
 {
     $eqApp = new Apps();
     //Add new Page category
     if (isset($_POST['name'])) {
         $eqApp->insertSql("cms_pages_cats");
         header('Location:' . _EQROOT_ . 'pages/cats');
     }
 }