Advertisement
reenadak

checking available date

Mar 24th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. function val_md_day($col,$val,$row, $instanceName)
  2. {
  3.     // Delete image file if it already existed
  4.     $query = "select md_day from ess where md_day = :md_day";
  5.     $queryParams = array('md_day' => $val);
  6.     $stmt = $this->Editor->doQuery($query,$queryParams);
  7.     if($row = $stmt->fetch(PDO::FETCH_ASSOC))
  8.     {
  9.         $not_found = 1;
  10.         $n = 1;
  11.         $check_date = $val;
  12.        
  13.         while($not_found)
  14.         {
  15.             $check_date = date('Y-m-d', strtotime('-1 day', strtotime($check_date)));
  16.             $query1 = "SELECT md_day FROM ess WHERE md_day = :md_day ";
  17.             $queryParams1 = array('md_day' =>  $check_date);
  18.             $stmt1 = $this->Editor->doQuery($query1,$queryParams1);
  19.            
  20.             if($row1 = $stmt1->fetch(PDO::FETCH_ASSOC))
  21.             {
  22.                 $not_found = 1;
  23.             }
  24.             else
  25.             {
  26.                 $not_found = 0;
  27.                 $this->Editor->showDefaultValidationMsg = false;
  28.                 $this->Editor->addTooltipMsg('Available Date is : ' . $check_date );
  29.                 return false;
  30.             }
  31.         }
  32.     }
  33.     else
  34.     {
  35.       return true;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement