Exemple #1
0
 public function autorization($login, $password)
 {
     $db = connectDb::db();
     $data = $db->prepare('SELECT s.ID, s.First_name, s.Last_name, s.Email, s.Password, s.Photo, s.Phone_number, Shop_discount, r.Name as role FROM staff s, role r WHERE s.ID_role = r.ID AND Email = ? AND Password = ? AND r.Name = "admin"');
     $data->execute([$login, $password]);
     $row = $data->fetch(PDO::FETCH_ASSOC);
     return $row;
 }
 private static function getInstance()
 {
     if (!self::$_instance) {
         // If no instance then make one
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #3
0
 function action_index()
 {
     $this->view->generate('login_view.php', 'template_view.php');
     if (isset($_POST['inputEmail'])) {
         $db = connectDb::db();
         $data = $db->prepare('SELECT s.ID, s.First_name, s.Last_name, s.Email, s.Password, s.Photo, s.Rating, s.Phone_number, Shop_discount, r.Name as role FROM staff s, role r WHERE s.ID_role = r.ID AND Email = ? AND Password = ? AND r.Name = "admin"');
         $data->execute([$_POST['inputEmail'], $_POST['inputPassword']]);
         $row = $data->fetch(PDO::FETCH_ASSOC);
         if ($row != false) {
             $_SESSION['user_info'] = $row;
             header("Location: /");
         }
     }
 }
 public function __destruct()
 {
     parent::__destruct();
 }
 /**
  * Create new instance
  *
  * @param string $tempDir
  * @param string $installDir
  * @param int $maxExecutionTime
  */
 public function __construct($tempDir = null, $installDir = null, $maxExecutionTime = 120)
 {
     parent::__construct();
     // Init logger
     //$this->log->info('Class '.__CLASS__.' | '.__FUNCTION__);
     //$this->_log->pushHandler(new NullHandler());
     $this->setTempDir('_tmp');
     $this->setInstallDir(CONTEXT);
     $this->_latestVersion = new version('0.0.0');
     $this->_currentVersion = new version('0.0.0');
     // Init cache
     //$this->_cache = new Cache(new NotCache());
     ini_set('max_execution_time', $maxExecutionTime);
 }
Exemple #6
0
 public function add_tip($parametr)
 {
     foreach ($parametr['id'] as $val) {
         $data = connectDb::db()->prepare("INSERT INTO `order` (`ID_staff`, `ID_client`, `ID_services`, `Price_service`, `ID_product`, `Price_product`, `Time`, `Status`,`Tip`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
         $data->execute([$val, 0, 0, 0, 0, 0, $parametr['time'], 1, $parametr['tip']]);
     }
     return $parametr;
 }
Exemple #7
0
 function action_staffsalary($param1)
 {
     if ($_SERVER['REQUEST_METHOD'] == "GET" && !empty($param1)) {
         $db = connectDb::db();
         $data = $db->prepare("SELECT ROUND(SUM(Price_service*(Percentage_service/100))+SUM(Price_product)*((SELECT Shop_discount FROM staff WHERE ID = :id_staff)/100) + SUM(Tip) - IFNULL((SELECT SUM(Price) FROM bought_drink WHERE ID_staff =:id_staff  AND `Time` > IFNULL((SELECT MAX(Time) FROM staff_salary WHERE ID_staff = :id_staff), 0)),0) ) as salary FROM `order` WHERE ID_staff =:id_staff AND Status = '1' AND `Time` > IFNULL((SELECT MAX(Time) FROM staff_salary WHERE ID_staff = :id_staff), 0)");
         $data->execute(['id_staff' => $param1]);
         $salary = $data->fetch(PDO::FETCH_COLUMN);
         if ($salary) {
             echo json_encode($salary);
             header('HTTP/1.1 200 OK');
         } else {
             echo 0;
         }
     } elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
         $date = new DateTime();
         $arr = json_decode($_POST['salary']);
         $mas = self::convertObj($arr);
         $db = connectDb::db();
         $insert = $db->prepare('INSERT INTO staff_salary (ID, ID_staff, `Time`, Salary) VALUES (NULL, ?, ?, ?)');
         $insert->execute([$mas['idStaff'], $date->getTimestamp(), $mas['salary']]);
         header('HTTP/1.1 200 OK');
     } else {
         header('HTTP/1.1 404 Not Found');
     }
 }