Example #1
0
 public function execute()
 {
     $this->output->add_css("banshee/graphs.css");
     $this->output->add_css("banshee/filter.css");
     if (in_array($this->page->pathinfo[1], array_keys($this->graphs)) == false || valid_date($this->page->pathinfo[2]) == false) {
         $this->show_graphs();
     } else {
         $this->show_day_information($this->page->pathinfo[1], $this->page->pathinfo[2]);
     }
 }
Example #2
0
 public function save_oke($poll)
 {
     $result = true;
     if (trim($poll["question"]) == "") {
         $this->output->add_message("Fill in the question.");
         $result = false;
     }
     $answers = 0;
     foreach ($poll["answers"] as $answer) {
         if (trim($answer) != "") {
             $answers++;
         }
     }
     if ($answers < 2) {
         $this->output->add_message("Fill in at least 2 answers.");
         $result = false;
     } else {
         if ($answers > $this->settings->poll_max_answers) {
             $this->output->add_message("Too many answers given.");
             $result = false;
         }
     }
     if (valid_date($poll["begin"]) == false || valid_date($poll["end"]) == false) {
         $this->output->add_message("Invalid begin or end date.");
         $result = false;
     } else {
         $begin = strtotime($poll["begin"]);
         $end = strtotime($poll["end"]);
         $today = strtotime("today 00:00:00");
         if ($begin < $today) {
             $this->output->add_message("Begin date must not be in the past.");
             $result = false;
         }
         if ($begin > $end) {
             $this->output->add_message("End date must not be before begin date.");
             $result = false;
         }
     }
     return $result;
 }
Example #3
0
 public function appointment_oke($appointment)
 {
     $result = true;
     if (valid_date($appointment["begin"]) == false) {
         $this->output->add_message("Invalid start time.");
         $result = false;
     }
     if (valid_date($appointment["end"]) == false) {
         $this->output->add_message("Invalid end time.");
         $result = false;
     }
     if ($result) {
         if (strtotime($appointment["begin"]) > strtotime($appointment["end"])) {
             $this->output->add_message("Begin date must lie before end date.");
             $result = false;
         }
     }
     if (trim($appointment["title"]) == "") {
         $this->output->add_message("Empty short description not allowed.");
         $result = false;
     }
     return $result;
 }
 /**
  * Function updateTransferPrivilege	: updateTransferPrivilege
  * Input 					: $ID, $FromAccountNo, $ToAccountNo, $TradingDate, $Quantity, $EventID, $UpdatedBy, $Note
  * OutPut 					: error code. Return 0 if success else return error code (number >0).
  */
 function updateTransferPrivilege($ID, $FromAccountNo, $ToAccountNo, $TradingDate, $Quantity, $EventID, $UpdatedBy, $Note)
 {
     try {
         $class_name = $this->class_name;
         $function_name = 'updateTransferPrivilege';
         if (authenUser(func_get_args(), $this, $function_name) > 0) {
             return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
         }
         if (!required($EventID) || !numeric($EventID)) {
             $this->_ERROR_CODE = 22042;
         }
         if ($this->_ERROR_CODE == 0 && $FromAccountNo == $ToAccountNo) {
             $this->_ERROR_CODE = 22074;
         }
         if ($this->_ERROR_CODE == 0 && ($FromAccountNo == '0' && $ToAccountNo == '0' || $FromAccountNo == '' && $ToAccountNo == '')) {
             $this->_ERROR_CODE = 22075;
         }
         if ($this->_ERROR_CODE == 0 && (!required($TradingDate) || !valid_date($TradingDate))) {
             $this->_ERROR_CODE = 22073;
         }
         if ($this->_ERROR_CODE == 0 && (!required($Quantity) || $Quantity <= 0)) {
             $this->_ERROR_CODE = 22009;
         }
         if ($this->_ERROR_CODE == 0 && !required($UpdatedBy)) {
             $this->_ERROR_CODE = 22011;
         }
         if ($this->_ERROR_CODE == 0) {
             $query = sprintf("CALL sp_updateTransfer_Privilege ('%s','%s','%s','%s','%s','%s','%s','%s')", $ID, $FromAccountNo, $ToAccountNo, $TradingDate, $Quantity, $EventID, $UpdatedBy, $Note);
             //echo $query;
             $result = $this->_MDB2_WRITE->extended->getAll($query);
             //Can not updateEventStatus
             if (empty($result) || is_object($result)) {
                 $this->_ERROR_CODE = 22066;
                 write_my_log_path('ErrorCallStore', $query . '  ' . $result->backtrace[0]['args'][4], EVENT_PATH);
             } else {
                 if (isset($result[0]['varerror'])) {
                     if ($result[0]['varerror'] < 0) {
                         switch ($result[0]['varerror']) {
                             case 0:
                                 $this->_ERROR_CODE = 0;
                                 break;
                             case -1:
                                 //Invalid FromAccountID
                                 $this->_ERROR_CODE = 22071;
                                 break;
                             case -2:
                                 //Invalid ToAccountID
                                 $this->_ERROR_CODE = 22072;
                                 break;
                             case -3:
                                 //Exception
                                 $this->_ERROR_CODE = 22070;
                                 break;
                             case -4:
                                 //Invalid TradingDate
                                 $this->_ERROR_CODE = 22073;
                                 break;
                             case -5:
                                 //Invalid TransferPrivilegeID
                                 $this->_ERROR_CODE = 22087;
                                 break;
                             case -6:
                                 //so luong chuyen nhuong lon hon so luong cho phep
                                 $this->_ERROR_CODE = 22084;
                                 break;
                             case -7:
                                 //su kien khong cho phep chuyen nhuong
                                 $this->_ERROR_CODE = 22085;
                                 break;
                             default:
                                 //default
                                 $this->_ERROR_CODE = 22134;
                                 write_my_log_path($function_name, $query . '  VarError ' . $result[0]['varerror'], EVENT_PATH);
                                 break;
                         }
                     }
                 }
             }
         }
     } catch (Exception $e) {
         write_my_log_path('PHP-Exception', $function_name . ' Caught exception: ' . $e->getMessage() . ' ' . date('Y-m-d h:i:s'), DEBUG_PATH);
         $this->_ERROR_CODE = 23022;
     }
     return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
 }
Example #5
0
 public function save_oke($item)
 {
     $result = true;
     if (isset($item["id"]) == false) {
         if ($this->allow_create == false) {
             return false;
         }
     } else {
         if ($this->allow_update == false) {
             return false;
         }
     }
     foreach ($this->elements as $name => $element) {
         if ($name == "id" || $element["readonly"]) {
             continue;
         }
         if ($element["required"] && $element["type"] != "boolean" && trim($item[$name]) == "") {
             if ($element["type"] != "blob" || isset($item["id"]) == false) {
                 $this->output->add_message("The field " . $element["label"] . " cannot be empty.");
                 $result = false;
             }
         }
         if (trim($item[$name]) != "") {
             switch ($element["type"]) {
                 case "date":
                     if (valid_date($item[$name]) == false) {
                         $this->output->add_message("The field " . $element["label"] . " doesn't contain a valid date.");
                         $result = false;
                     }
                     break;
                 case "timestamp":
                     if (valid_timestamp($item[$name]) == false) {
                         $this->output->add_message("The field " . $element["label"] . " doesn't contain a valid timestamp.");
                         $result = false;
                     }
                     break;
                 case "enum":
                     if (in_array($item[$name], array_keys($element["options"])) == false) {
                         $this->output->add_message("The field " . $element["label"] . " doesn't contain a valid value.");
                         $result = false;
                     }
                     break;
                 case "integer":
                     if (is_numeric($item[$name]) == false) {
                         $this->output->add_message("The field " . $element["label"] . " should be numerical.");
                         $result = false;
                     }
                     break;
             }
         }
         if ($element["unique"]) {
             $query = "select count(*) as count from %S where %S=%s";
             $args = array($this->table, $name, $item[$name]);
             if (isset($item["id"])) {
                 $query .= " and id!=%d";
                 array_push($args, $item["id"]);
             }
             if (($current = $this->db->execute($query, $args)) == false) {
                 $this->output->add_message("Error checking item uniqueness.");
             } else {
                 if ($current[0]["count"] > 0) {
                     $this->output->add_message($element["label"] . " already exists.");
                     $result = false;
                 }
             }
         }
     }
     return $result;
 }
 /**
 * Function checkAccountValidate	: check the validation of data input
 * Input 					: array of data
 * Output 					: error code. Return 0 if data is valid and return error code
 							 (number >0).
 */
 function checkPayment($data)
 {
     //if(!required($data['FirstName'])) return 18012;
     if (!required($data['PaymentDate']) || !valid_date($data['PaymentDate'])) {
         return 21007;
     }
     if (!required($data['TotalMoney']) || !numeric($data['TotalMoney']) || $data['TotalMoney'] < 20000000) {
         return 21009;
     }
     if (isset($data['CreatedBy']) && !required($data['CreatedBy'])) {
         return 21010;
     }
     if (isset($data['UpdatedBy']) && !required($data['UpdatedBy'])) {
         return 21011;
     }
     return 0;
 }
	</td>
	<td class="cell">&nbsp;</td>
	<td class="cell"><input type="checkbox" name="int<?php 
    echo $arrData[resident_id];
    ?>
" <? if ($arrData[interview]) echo 'checked'; ?>></td>
	<td class="cell">&nbsp;</td>
	<td class="cell">
	<input type="checkbox" name="off<?php 
    echo $arrData[resident_id];
    ?>
" <? if ($arrData[offered]) echo 'checked'; ?>>
	<?php 
    $offered_date = $request['odate' . $arrData[resident_id]];
    //echo "rules_date=($rules_date)<br>";
    if ($offered_date != "" && !valid_date($offered_date)) {
        echo "<br><font color=red>Invalid Date!</font>";
    } else {
        $offered_date = mostrar_fecha(substr($arrData[offered_date], 0, 10));
    }
    ?>
	<input type="text" name="odate<?php 
    echo $arrData[resident_id];
    ?>
" value="<?php 
    echo $offered_date;
    ?>
" size="8">
	</td>
	<td class="cell">&nbsp;</td>
	</tr>
    $step_2[$key] = ${$key};
}
//Блок проверки личных данных
if (!$second_name) {
    $err_text .= "<li class=\"text-danger\">Не указана фамилия страхователя</li>";
}
if (!$first_name) {
    $err_text .= "<li class=\"text-danger\">Не указано имя страхователя</li>";
}
if (!$third_name) {
    $err_text .= "<li class=\"text-danger\">Не указано отчество страхователя</li>";
}
if (!$date_birth) {
    $err_text .= "<li class=\"text-danger\">Не указана дата рождения страхователя</li>";
}
if (!valid_date($date_birth) || age($date_birth) > 100) {
    $err_text .= "<li class=\"text-danger\">Дата рождения собственника указанна не верно</li>";
}
if ($first_name && $second_name && $third_name && $date_birth && mysql_num_rows(mysql_query("SELECT * FROM `bad_people` WHERE first_name = '" . trim($first_name) . "' AND second_name = '" . trim($second_name) . "' AND third_name = '" . trim($third_name) . "' AND date_of_birth = '" . $date_birth . "'")) > 0) {
    $err_text .= "<li class=\"text-danger\">Страхователь находится в списке людей, страхование которых запрещено!</li>";
}
if (!$place_birth) {
    $err_text .= "<li class=\"text-danger\">Не указано место рождения страхователя</li>";
}
if (!$place_work) {
    $err_text .= "<li class=\"text-danger\">Не указано место работы страхователя</li>";
}
if (!$phone_number) {
    $err_text .= "<li class=\"text-danger\">Не указан номер телефона страхователя</li>";
}
if (!$inn) {
/**
 * Test date and time for proper format
 *
 * @access	public
 * @param	string	date as string value
 * @param	string	format of date to test against
 * @param	string	delimiter of date value given for testing 
 * @return	boolean
 */
function valid_date_time($date, $format = "ymd", $delimiter = "-")
{
    return valid_date($date, $format, $delimiter) && valid_time($date);
}
Example #10
0
if (!valid_time($_POST['calltime'])) {
    die("Bad call time");
}
if (!valid_time($_POST['donetime'])) {
    die("Bad done time");
}
$unixcall = strtotime($_POST['calltime'] . ' ' . $_POST['calldate']);
$call = date('Y-m-d H:i:s', $unixcall);
$unixdone = strtotime($_POST['donetime'] . ' ' . $_POST['donedate']);
$done = date('Y-m-d H:i:s', $unixdone);
if ($unixdone <= $unixcall) {
    die("Event ends before it begins");
}
if ($type == 'other' || $type == 'rehearsal' || $type == 'sectional') {
    if ($repeat != '' && $repeat != 'no') {
        if (!valid_date($_POST['until'])) {
            die("Bad repeat-until date");
        }
        $dur = $unixdone - $unixcall;
        if ($repeat == "daily") {
            $interval = '+1 day';
        } else {
            if ($repeat == "weekly") {
                $interval = '+1 week';
            } else {
                if ($repeat == "biweekly") {
                    $interval = '+2 weeks';
                } else {
                    if ($repeat == "monthly") {
                        $interval = '+1 month';
                    } else {
Example #11
0
/**
 * Check whether or not a date string is real, non-zero date
 * 
 * @param string $date
 * @return boolean
 * @access public
 * @date 12/13/04
 */
function real_date($date)
{
    // first off, if they're blank, return false
    if (!$date || $date == '') {
        return FALSE;
    }
    // Make sure that the date is good format
    if (!valid_date($date)) {
        return FALSE;
    }
    // Get an array of the date parts
    if (!($dateArray = getDateArray($date))) {
        return FALSE;
    }
    // Validate that the date is a valid Gregorian date
    $month = $dateArray['Month'] ? $dateArray['Month'] : 1;
    $day = $dateArray['Day'] ? $dateArray['Day'] : 1;
    if (!checkdate($month, $day, $dateArray['Year'])) {
        return FALSE;
    }
    return TRUE;
}
Example #12
0
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'invalid argument']);
    die;
}
// Check Date
function valid_date($date_str)
{
    $date_var = date_parse($date_str);
    if ($date_var["error_count"] == 0 && checkdate($date_var["month"], $date_var["day"], $date_var["year"])) {
        return date("Y-m-d H:i:s", mktime(0, 0, 0, $date_var["month"], $date_var["day"], $date_var["year"]));
    } else {
        return false;
    }
}
$date_start = valid_date($start_ts);
$date_end = valid_date($end_ts);
if (empty($start_ts) || $date_start == FALSE) {
    $date_start = date("Y-m-d H:i:s", strtotime("-1 month"));
}
if (empty($end_ts) || $date_end == FALSE) {
    $date_end = date("Y-m-d H:i:s");
}
$date_start = date('Y-m-d', strtotime($date_start));
$date_end = date('Y-m-d 23:59:59', strtotime($date_end));
_log(json_encode(['date_start' => $date_end, 'date_end' => $date_end]));
// Check last_id
if (empty($last_id) || !is_numeric($last_id) || $last_id * 1 == 0) {
    $last_id = PHP_INT_MAX;
}
// Get User
switch ($user_mode) {
Example #13
0
//echo $sql;
//die;
$numrows = oci_fetch_all($querytrans, $res);
if ($numrows <= 0 && $amount < 1000) {
    echo "<SCRIPT LANGUAGE='JavaScript'>\r        alert('Sorry, this is the first deposit. You can only make a Deposit of KSh[1000]  and above, thank you!')\r        window.location.href='../views/purchases.php?id={$_GET['id']}&acid={$myacct}'\r        </SCRIPT>";
    exit;
}
if ($numrows > 0 && $amount < 500) {
    echo "<SCRIPT LANGUAGE='JavaScript'>\r        alert('Sorry, you can only make a deposit of KSh[500] and above, thank you!')\r        window.location.href='../views/purchases.php?id={$_GET['id']}&acid={$myacct}'\r        </SCRIPT>";
    exit;
}
if ($refrence == '') {
    echo "<SCRIPT LANGUAGE='JavaScript'>\r        window.alert('Please enter a valid Reference code, thank you!')\r        window.location.href='../views/purchases.php?id={$_GET['id']}&acid={$myacct}'\r        </SCRIPT>";
    exit;
}
$mysql = "select AMOUNT, PORTFOLIO, BANKACCDETS, DOC_NO FROM TRANS_AMOUNT WHERE DOC_NO='" . $refrence . "'";
$resbank = oci_parse($conn, $mysql) or die(" ");
oci_execute($resbank);
$numrows = oci_fetch_all($resbank, $res);
if ($numrows <= 0) {
    $value_date = valid_date();
    $sql = "INSERT INTO trans_amount(trans_type,member_no, full_name,account_no, amount,portfolio,mop, u_name, doc_no, branchid, BANKACCDETS, VALUE_DATE, AGENT_NO ) VALUES('" . $transtype . "','" . $member . "','" . $name . "','" . $acct_no . "','" . $amount . "','" . $desc . "','Funds Transfer','" . $_SESSION['username'] . "','" . $refrence . "','" . $_SESSION['Branchcode'] . "','" . $_SESSION['Branchname'] . "','" . $value_date . "','" . $agent_no . "')  returning TRANS_ID into :id ";
    $result = OCIParse($conn, $sql);
    OCIBindByName($result, ":ID", $id, 32);
    //global $id;
    OCI_Execute($result);
    if (!oci_parse($conn, $sql)) {
        echo "failed";
        echo "<SCRIPT LANGUAGE='JavaScript'>\r\t\t\twindow.alert('Sorry an error occurred, The transaction failed. [{$sql}]')\r\t\t\twindow.location.href='../views/members.php'\r\t\t\t</SCRIPT>";
        exit;
    } else {
Example #14
0
function kirjoita_solu(&$xls, $key, $string, &$rivi, &$sarake, $force_to_string)
{
    if (is_numeric($string) and !in_array($key, $force_to_string)) {
        $xls->writeNumber($rivi, $sarake, $string);
    } elseif (valid_date($string) != 0 and valid_date($string) !== false and !in_array($key, $force_to_string)) {
        $xls->writeDate($rivi, $sarake, $string);
    } else {
        $xls->write($rivi, $sarake, $string);
    }
    $sarake++;
}
Example #15
0
function validateAddition()
{
    if (trim($_POST["txtNewsTitle"]) == "" || trim($_POST["txtNews"]) == "") {
        return false;
    } else {
        if (trim($_POST["chk_staff"]) == "" && trim($_POST["chk_user"]) == "") {
            return false;
        } else {
            if (valid_date(trim($_POST["txtDate"])) != "1") {
                return false;
            } else {
                return true;
            }
        }
    }
}
 public function add_timeslot()
 {
     $id = $this->request->query['id'] ? $this->request->query['id'] : null;
     $action_type = "create";
     if ($id !== null and is_numeric($id)) {
         $check_timeslot = $this->Timeslot->find('first', array('conditions' => array('id' => $id, 'user_id' => $this->Session->read('user_id'))));
         if (count($check_timeslot) > 0) {
             $action_type = "update";
         }
     }
     $date = $this->request->query['date'];
     $start_hour = $this->request->query['start_hour'];
     $start_minute = $this->request->query['start_minute'];
     $end_hour = $this->request->query['end_hour'];
     $end_minute = $this->request->query['end_minute'];
     $type = $this->request->query['type'];
     $valid_types = array('BUSY', 'FREE', 'PER_BUSY');
     if (!in_array($type, $valid_types)) {
         $this->redirect($this->referer());
         exit;
     }
     if (!valid_minute($start_minute) or !valid_minute($end_minute) or !valid_hour($end_hour) or !valid_hour($start_hour)) {
         $this->redirect($this->referer());
         exit;
     }
     if (!valid_date($date)) {
         $this->redirect($this->referer());
         exit;
     }
     $user_id = $this->Session->read('user_id');
     $day_of_week = get_wday($date);
     $data = array('start_hour' => (int) $start_hour, 'start_minute' => (int) $start_minute, 'end_hour' => (int) $end_hour, 'end_minute' => (int) $end_minute, 'type' => $type, 'date' => $date, 'user_id' => $user_id, 'wday' => $day_of_week);
     if ($action_type == "update") {
         $this->Timeslot->id = $id;
     }
     $this->Timeslot->save($data);
     $this->redirect($this->referer());
     exit;
 }
Example #17
0
function valid_timestamp($timestamp)
{
    list($date, $time) = explode(" ", $timestamp, 2);
    return valid_date($date) && valid_time($time);
}
Example #18
0
function product_form_display($type, $prodId, $catId, $productCode, $productName, $desc, $listPrice, $discPercent, $date, $validate, $valid, $currDate)
{
    ?>
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="utf-8">
</head>
<body>
<header>
   <h1>Update Product</h1>
</header>
<div>
<form method="post" action="<?php 
    // $type is add or update passed from the calling script
    echo $type;
    ?>
.php">
<p><label>Category ID: <select name="catId">
   <option value="1" <?php 
    if ($catId == 1) {
        echo "selected";
    }
    ?>
>Guitars</option>
   <option value="2" <?php 
    if ($catId == 2) {
        echo "selected";
    }
    ?>
>Basses</option>
   <option value="3" <?php 
    if ($catId == 3) {
        echo "selected";
    }
    ?>
>Drums</option>
   <option value="4" <?php 
    if ($catId == 4) {
        echo "selected";
    }
    ?>
>Keyboards</option>   
</select></label>

<?php 
    if ($validate) {
        // Check to see if the category ID is numeric. If not, write an error message and set the $valid flag to false
        if (!is_numeric($catId)) {
            echo "<span class='error'>Category Id must be numeric</span>";
            $valid = false;
        }
    }
    ?>
</p>
<p><label>Product Code: <input type="text" name="prodCode" value="<?php 
    echo $productCode;
    ?>
"></label>
   <?php 
    if ($validate) {
        // Make sure they entered something in the product code. If not, write error message and set $valid = false
        if (empty($productCode)) {
            echo "<span class='error'>Product Code is required</span>";
            $valid = false;
        }
        // Make sure the product code is not too long for the database
        if (strlen($productCode) > 10) {
            echo "<span class='error'>Product Code has a maximum length of 10</span>";
            $valid = false;
        }
    }
    ?>
</p>
<p><label>Product Name: <input type="text" name="prodName" value="<?php 
    echo $productName;
    ?>
"></label>
      <?php 
    if ($validate) {
        // Make sure they entered something in the product name. If not, write error message and set $valid = false
        if (empty($productName)) {
            echo "<span class='error'>Product Name is required</span>";
            $valid = false;
        }
        // Make sure the product Name is not too long for the database
        if (strlen($productName) > 255) {
            echo "<span class='error'>Product Name has a maximum length of 255</span>";
            $valid = false;
        }
    }
    ?>
</p>
<p><label>Description: <textarea name="desc" cols="60"><?php 
    echo $desc;
    ?>
</textarea></label>
   <?php 
    if ($validate) {
        // Make sure they entered something in the description. If not, write error message and set $valid = false
        if (empty($desc)) {
            echo "<span class='error'>Description is required</span>";
            $valid = false;
        }
    }
    ?>
</p>
<p><label>List Price <input type="text" name="listPrice"  value="<?php 
    echo $listPrice;
    ?>
"></label>
   <?php 
    if ($validate) {
        // Check list price for numeric and maximum value
        if (!is_numeric($listPrice)) {
            echo "<span class='error'>List price must be numeric</span>";
            $valid = false;
        }
        if ($listPrice > 99999999.98999999) {
            echo "<span class='error'>List price exceeds maximum allowed</span>";
            $valid = false;
        }
    }
    ?>
 </p>
<p><label>Discount Percent: <input type="text" name="discPercent"  value="<?php 
    echo $discPercent;
    ?>
"></label>
   <?php 
    if ($validate) {
        // Check discount percent for numeric. If not, set to 0
        if (!is_numeric($discPercent)) {
            $discPercent = 0.0;
        }
        //Check discount percent for maximum value
        if ($discPercent > 100.0) {
            echo "<span class='error'>Discount percent cannot exceed 100%</span>";
            $valid = false;
        }
    }
    ?>
 </p>
<p><label>Date: <input type="text" name="date" placeholder="YYYY-MM-DD"  value="<?php 
    echo $date;
    ?>
"></label> 
or Use current date <input type="checkbox" name="currDate" value="y" 
<?php 
    if ($validate) {
        if ($currDate == 'y') {
            echo "checked";
        }
        ?>
 ></label><?php 
        // call the date validation function
        $dateValid = valid_date($date);
        if (!$dateValid) {
            $valid = false;
        }
    }
    ?>
 </p>
<p><input type="hidden" name="prodId" value="<?php 
    echo $prodId;
    ?>
">
<input type="submit" name="submit" value="<?php 
    echo $type;
    ?>
 Product"></p>
</form>
</div>
<footer>
   <p>Unit I Example</p>
</footer>
</body>
</html>

<?php 
    // return valid flag back to calling script
    return $valid;
}
Example #19
0
 public function show($pkey, $method = "echo")
 {
     _has_user_access_permission(TRUE, array('admin', 'management_company', 'staff', 'engineer'));
     $params = ($params = unserialize_object($pkey)) && is_array($params) ? $params : array();
     $company_id = in_array($this->current_user->group_id, array(GROUP_ADMIN, GROUP_STAFF, GROUP_ENGINEER)) ? $this->_post_args('company_id', ARGS_TYPE_INT, array_key_exists(SYS_COMPANY_ID, $params) && gtzero_integer($params[SYS_COMPANY_ID]) ? to_int($params[SYS_COMPANY_ID]) : 0) : $this->current_user->company_id;
     $site_id = isset($params[SYS_SITE_ID]) && gtzero_integer($params[SYS_SITE_ID]) ? to_int($params[SYS_SITE_ID]) : 0;
     $redirect_url = $this->_post_args('redirect_url', ARGS_TYPE_STRING, $this->agent->referrer());
     $site_info = $this->site_m->details($site_id, $company_id);
     if (!$site_info || _has_company_group_access($this->current_user->group_id) && $site_info->company_id != $this->current_user->company_id) {
         $this->show_permission_denied_error($method);
     }
     $company_id = in_array($this->current_user->group_id, array(GROUP_ADMIN, GROUP_STAFF, GROUP_ENGINEER)) ? $this->_post_args('company_id', ARGS_TYPE_INT, $site_info->company_id) : $this->current_user->company_id;
     $doc_key = $this->_post_args('doc_key', ARGS_TYPE_STRING) ? $this->_post_args('doc_key', ARGS_TYPE_STRING) : keygen();
     $csrf = _get_csrf_nonce();
     $data = array("site_id" => $site_id, 'notes_listing_url' => site_url('notes/index/' . serialize_object(array(SYS_REF_ID => $site_id, SYS_NOTE_TYPE_ID => NOTE_TYPE_SITE))), 'form_action' => site_url('sites/show/' . $pkey), 'cancel_url' => $redirect_url, 'page' => 'sites/show', 'title' => 'Site Detail', 'submit_btn_text' => 'Save Changes', 'company_id' => $company_id, 'company_name' => $site_info->company_name, 'site_id' => $site_info->id, 'district_no' => $site_info->district_no, 'site_code' => $site_info->site_code, 'town' => $site_info->town, 'address' => $site_info->address, 'street' => $site_info->street, 'postcode' => $site_info->postcode, 'site_ref' => $site_info->site_ref, 'upload_date' => !empty($site_info->upload_date) ? valid_date($site_info->upload_date, 'd/m/Y') : local_time(curr_timestamp(), 'd/m/Y'), 'static_scroller' => $site_info->static_scroller, 'shelter_fsu' => $site_info->shelter_fsu, 'easting' => $site_info->easting, 'northing' => $site_info->northing, 'shelter_type' => $site_info->shelter_type, 'site_configuration' => $site_info->site_configuration, 'height' => $site_info->height, 'panel' => $site_info->panel, 'ranking' => $site_info->ranking, 'embargo_start_date' => $site_info->embargo_start_date, 'status' => $site_info->status, 'power_build_pack_requested' => $site_info->power_build_pack_requested, 'power_build_pack_received_ttc' => $site_info->power_build_pack_received_ttc, 'actual_power_cost' => $site_info->actual_power_cost, 'power_build_date' => $site_info->power_build_date, 'meter_build_date' => $site_info->meter_build_date, 'site_forms' => $site_info->site_forms, 'site_statuses' => array('' => '', 1 => 'OPEN', 2 => 'SUBMITTED', 3 => 'COMPLETED'), 'scripts' => array('sites/show.js'), 'hiddenvars' => array_merge($csrf, array('redirect_url' => $redirect_url)));
     if ($this->input->is_ajax_request()) {
         $html = $this->template->raw_view('pages/sites/show_modal', $data, TRUE);
         if ($method == "ajax") {
             $output['html'] = $html;
             $this->_output_request($output, $redirect_url);
         } else {
             echo $html;
         }
     } else {
         if (!empty($output['status'])) {
             set_flash_data($output['status'], $output['message'], FALSE);
         }
         $this->template->load('default', $data);
     }
 }
Example #20
0
 public function index()
 {
     $this->load->model('classes/Classes_model');
     $this->load->model('child/child_model');
     $this->load->model('kin/kin_model');
     if (!$this->input->is_ajax_request()) {
         $this->ims_template->build('parent_account/blank', $this->data);
     } else {
         $this->data['unavailable_dates'] = $this->attendance_model->getUnavailableDate();
         //Any Day with Academic Events are unavailable dates
         $redirect_url_info = $this->session->userdata('redirect_url_info');
         if (is_array($redirect_url_info) and !empty($redirect_url_info)) {
             $this->data['attendance_date'] = $attendance_date = $redirect_url_info['date'];
             $this->data['attendanceType'] = $attendanceType = 1;
             $this->data['classId'] = $classId = $redirect_url_info['class_id'];
             $this->session->unset_userdata('redirect_url_info');
         } else {
             $this->data['attendance_date'] = $attendance_date = $this->input->post('attendace_date') === false ? date('Y-m-d') : $this->input->post('attendace_date');
             $this->data['attendanceType'] = $attendanceType = $this->input->post('attendanceType') === false ? 1 : $this->input->post('attendanceType');
             $this->data['classId'] = $classId = $this->input->post('classId') === false ? 0 : $this->input->post('classId');
         }
         if (_is('Teacher')) {
             $this->data['ClassLevel'] = $this->attendance_model->getAttendancePermission($this->current_user->id, $this->current_centre_role->centre_id, $this->default_yearterm->id);
         } else {
             $this->data['ClassLevel'] = $this->Classes_model->getClassLevel($this->current_centre_role->centre_id);
         }
         /* Check if child exist */
         $year = date('Y');
         $month = date('m');
         $year_term = $this->default_yearterm->id;
         $centre_id = $this->current_centre_role->centre_id;
         if (!empty($this->data['ClassLevel'])) {
             foreach ($this->data['ClassLevel'] as $key => $value) {
                 // $attendance = $this->attendance_model->getAttendanceListByMonth($year, $month, $value->id);
                 $child_count = $this->child_model->getClassListByMonth($value->id, $year, $month);
                 $this->data['ClassLevel'][$key]->childCount = count($child_count);
             }
         }
         /* Check if child exist */
         $this->data['date'] = $date = mysqlDateFormat($attendance_date);
         if ($classId != -1) {
             $lvlId = '';
             if ($classId != 0) {
                 foreach ($this->data['ClassLevel'] as $ClassLevel) {
                     if ($classId == $ClassLevel->id) {
                         $lvlId = $ClassLevel->id;
                         $this->data['class_level_name'] = $ClassLevel;
                         break;
                     }
                 }
                 $this->data['attendance_disabled'] = false;
                 if (valid_date($attendance_date) and !in_array(date('Y-n-j', strtotime($date)), $this->data['unavailable_dates'])) {
                     //date is valid and not an event day
                     $classAttendanceDescription = $this->attendance_model->checkAttendance($classId, $date, $attendanceType, $this->current_centre_role->centre_id, $lvlId);
                     if (!empty($classAttendanceDescription)) {
                         //Edit Mode
                         $this->data['child_attendance'] = array();
                         foreach ($classAttendanceDescription['childAttendance'] as $child_attendance) {
                             $this->data['child_attendance'][$child_attendance->child_id] = $child_attendance;
                         }
                         $this->data['classAttendance'] = $classAttendanceDescription['attendance'];
                         $year_term_child_class = $this->data['classAttendance']->term;
                     } else {
                         //Insert Mode
                         $year_term_child_class = $this->default_yearterm->id;
                     }
                     if ($attendanceType == 1) {
                         //$this->data['classDetails'] = $this->child_model->getClassListByDate($classId, $date);
                         $class_details = $this->child_model->getClassListByDate($classId, $date);
                         /* Get all kins related to the child */
                         if (!empty($class_details)) {
                             foreach ($class_details as $key => $value) {
                                 if (isset($this->data['child_attendance'][$value->id]->dropoff_type) && $this->data['child_attendance'][$value->id]->dropoff_type == 1) {
                                     // get kin
                                     $kin_details = $this->kin_model->get_all_kin_by_child($value->id);
                                 } else {
                                     if (isset($this->data['child_attendance'][$value->id]->dropoff_type) && $this->data['child_attendance'][$value->id]->dropoff_type == 2) {
                                         // get general
                                         $kin_details = $this->kin_model->get_pickup_dropoff_person_by_child($value->id);
                                     } else {
                                         $kin_details = $this->kin_model->get_all_kin_by_child($value->id);
                                     }
                                 }
                                 $this->data['classDetails'][] = $value;
                                 $this->data['classDetails'][$key]->kinDetails = $kin_details;
                             }
                         }
                         /* Get all kins related to the child */
                     }
                 } else {
                     $this->data['attendance_disabled'] = true;
                 }
             }
         } else {
             $lvlId = '';
             foreach ($this->data['ClassLevel'] as $all_class) {
                 foreach ($this->data['ClassLevel'] as $ClassLevel) {
                     if ($all_class->id == $ClassLevel->id) {
                         $lvlId = $ClassLevel->id;
                         $this->data['all_class'][$all_class->id]['class_level_name'] = $ClassLevel;
                         break;
                     }
                 }
                 $this->data['attendance_disabled'] = false;
                 if (valid_date($attendance_date) and !in_array(date('Y-n-j', strtotime($date)), $this->data['unavailable_dates'])) {
                     $classAttendanceDescription = $this->attendance_model->checkAttendance($all_class->id, $date, $attendanceType, $this->current_centre_role->centre_id);
                     if (!empty($classAttendanceDescription)) {
                         $this->data['all_class'][$all_class->id]['child_attendance'] = array();
                         foreach ($classAttendanceDescription['childAttendance'] as $child_attendance) {
                             $this->data['all_class'][$all_class->id]['child_attendance'][$child_attendance->child_id] = $child_attendance;
                         }
                         $this->data['all_class'][$all_class->id]['classAttendance'] = $classAttendanceDescription['attendance'];
                         $year_term_child_class = $this->data['all_class'][$all_class->id]['classAttendance']->term;
                     } else {
                         $year_term_child_class = $this->default_yearterm->id;
                     }
                     if ($attendanceType == 1) {
                         $this->data['all_class'][$all_class->id]['classDetails'] = $this->child_model->getClassListByDate($all_class->id, $date);
                         //                                     debug($this->data['all_class'][$all_class->id]['classDetails']);
                     }
                 } else {
                     $this->data['attendance_disabled'] = true;
                 }
             }
         }
         $this->load->view('attendances', $this->data);
     }
 }
 /**
  * (Function nay chi khac ConfirmBuyingStockForDividend_CutMoney o cho tham so $Note - Tao ngay 20100712, request ngay 20100709)
  * Function ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu  : Ke toan cat tien -- day dl qua Bravo -- cap nhat bankid khi cat tien thanh cong
  * Input            : $EventID, $AccountID, $Today, $UpdatedBy, $Note
  * OutPut           : error code. Return 0 if success else return error code (number >0).
  */
 function ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu($EventID, $AccountID, $UpdatedBy, $Today, $BankID, $Note)
 {
     try {
         $class_name = $this->class_name;
         $function_name = 'ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu';
         if (authenUser(func_get_args(), $this, $function_name) > 0) {
             return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
         }
         if (!required($EventID) || !numeric($EventID)) {
             $this->_ERROR_CODE = 22042;
         }
         if ($this->_ERROR_CODE == 0 && (!required($AccountID) || !numeric($AccountID))) {
             $this->_ERROR_CODE = 22005;
         }
         if ($this->_ERROR_CODE == 0 && (!required($Today) || !valid_date($Today))) {
             $this->_ERROR_CODE = 22056;
         }
         if ($this->_ERROR_CODE == 0) {
             $Withdrawal = $this->CheckConfirmBuyingStock_CutMoney($EventID, $AccountID, $Today);
             if ($Withdrawal['ErrorCode'] == '0') {
                 // money in bank
                 $query = sprintf("SELECT BankID, BankAccount, BravoCode FROM vw_ListAccountBank_Detail WHERE AccountID='%s' AND BankID ='%s' ", $AccountID, $BankID);
                 $this->_MDB2->disconnect();
                 $this->_MDB2->connect();
                 $bank_rs = $this->_MDB2->extended->getAll($query);
                 $dab_rs = 999;
                 $BankID = 0;
                 $TransactionType = BRAVO_BUYING_STOCK;
                 // phat hanh them cp
                 if ($Withdrawal['AccountNo'] != PAGODA_ACCOUNT) {
                     if (count($bank_rs) > 0) {
                         $i = 0;
                         $BankID = $bank_rs[$i]['bankid'];
                         $BravoCode = $bank_rs[$i]['bravocode'];
                         switch ($BankID) {
                             case DAB_ID:
                                 $dab =& new CDAB();
                                 $dab_rs = $dab->transfertoEPS($bank_rs[$i]['bankaccount'], $Withdrawal['AccountNo'], '3_' . $EventID . '_' . $AccountID, $Withdrawal['Amount'], $Note);
                                 write_my_log_path('transfertoEPS', $function_name . ' BankAccount ' . $bank_rs[$i]['bankaccount'] . '  AccountNo ' . $Withdrawal['AccountNo'] . '  Event_AccountID ' . '3_' . $EventID . ' ' . $AccountID . '  Amount ' . $Withdrawal['Amount'] . ' Description ' . $Note . ' Error ' . $dab_rs, EVENT_PATH);
                                 break;
                             case OFFLINE:
                                 $mdb2 = initWriteDB();
                                 //`sp_VirtualBank_insertBuyingStockDivident`(inAccountID bigint, inBankID int, inAmount double,inTransactionDate date, inNote text(1000), inCreatedBy varchar(100))
                                 $query = sprintf("CALL sp_VirtualBank_insertBuyingStockDivident(%u, %u, %f, '%s', '%s', '%s' )", $AccountID, $BankID, $Withdrawal['Amount'], $Today, $Note, $UpdatedBy);
                                 $rs = $mdb2->extended->getRow($query);
                                 $mdb2->disconnect();
                                 $dab_rs = $rs["varerror"];
                                 break;
                             default:
                                 $dab_rs = 0;
                         }
                     } else {
                         $dab_rs = 9999;
                         $this->_ERROR_CODE = 22155;
                         //TK k co TK Ngan hang nay
                     }
                 } else {
                     $TransactionType = BRAVO_BUYING_STOCK;
                     // phat hanh them cp
                     $dab_rs = 0;
                     $BankID = EXI_ID;
                 }
                 if ($dab_rs == 0) {
                     if ($BankID == OFFLINE) {
                         $query = "SELECT mobilephone,ab.usableamount FROM " . TBL_INVESTOR;
                         $query .= " i INNER JOIN " . TBL_ACCOUNT . " a ON(i.id=a.investorId)";
                         $query .= " INNER JOIN " . TBL_ACCOUNT_BANK . " ab ON(a.id=ab.accountid)";
                         $query .= " WHERE a.accountNo='" . $Withdrawal['AccountNo'] . "' AND ab.bankid=" . OFFLINE;
                         $mdb = initWriteDB();
                         $acc_rs = $mdb->extended->getRow($query);
                         $mdb->disconnect();
                         if (!empty($acc_rs['mobilephone'])) {
                             $message = 'Tai khoan cua quy khach tai KIS da thay doi: -' . number_format($Withdrawal['Amount'], 0, '.', ',') . '. ' . $Note;
                             $message .= '. So du hien tai la: ' . number_format($acc_rs['usableamount'], 0, '.', ',');
                             sendSMS(array('Phone' => $acc_rs['mobilephone'], 'Content' => $message), 'ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu');
                         }
                     }
                     $soap =& new Bravo();
                     $Withdrawal_value = array("TradingDate" => $Today, 'TransactionType' => $TransactionType, "AccountNo" => $Withdrawal['AccountNo'], "Amount" => $Withdrawal['Amount'], "Bank" => $BravoCode, "Branch" => "", "Note" => $Note);
                     //'011C001458'
                     //var_dump($withdraw_value);
                     $ret = $soap->withdraw($Withdrawal_value);
                     if ($ret['table0']['Result'] == 1) {
                         $query = sprintf("CALL sp_UpdateDividendPrivilege_BankID ('%s','%s','%s','%s')", $BankID, $EventID, $AccountID, $UpdatedBy);
                         //echo $query;
                         $result = $this->_MDB2_WRITE->extended->getAll($query);
                         //Can not update
                         if (empty($result) || is_object($result)) {
                             $this->_ERROR_CODE = 22120;
                             write_my_log_path('ErrorCallStore', $query . '  ' . $result->backtrace[0]['args'][4], EVENT_PATH);
                         } else {
                             if (isset($result[0]['varerror'])) {
                                 //p_iDividentPrivilege sai hoac dang ky mua chua xac nhan hoac da cat tien roi
                                 if ($result[0]['varerror'] == -2) {
                                     $this->_ERROR_CODE = 22121;
                                 } else {
                                     if ($result[0]['varerror'] == -3) {
                                         //qua ngay cat tien
                                         $this->_ERROR_CODE = 22149;
                                     } else {
                                         if ($result[0]['varerror'] == -1) {
                                             //Exception
                                             $this->_ERROR_CODE = 22122;
                                         } else {
                                             if ($result[0]['varerror'] < 0) {
                                                 $this->_ERROR_CODE = 22134;
                                                 write_my_log_path($function_name, $query . '  VarError ' . $result[0]['varerror'], EVENT_PATH);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         if ($this->_ERROR_CODE != 0) {
                             $soap->rollback($ret['table1']['Id'], $Today);
                         }
                     } else {
                         switch ($ret['table0']['Result']) {
                             case 0:
                                 $this->_ERROR_CODE = 0;
                                 break;
                             case -2:
                                 //Error - bravo
                                 $this->_ERROR_CODE = 23002;
                                 break;
                             case -1:
                                 //Invalid key
                                 $this->_ERROR_CODE = 23003;
                                 break;
                             case -13:
                                 /*Invalid Transaction Type*/
                                 $this->_ERROR_CODE = 23006;
                                 break;
                             case -15:
                                 /*Invalid CustomerCode*/
                                 $this->_ERROR_CODE = 23005;
                                 break;
                             case -16:
                                 /*Invalid DestCustomerCode*/
                                 $this->_ERROR_CODE = 23004;
                                 break;
                             default:
                                 //Unknown Error
                                 $this->_ERROR_CODE = 23009;
                                 write_my_log_path($function_name, '  Bravo ' . $ret['table0']['Result'], EVENT_PATH);
                                 break;
                         }
                     }
                 } else {
                     switch ($dab_rs) {
                         case '-1':
                             //unauthenticate partner
                             $this->_ERROR_CODE = 22135;
                             break;
                         case '-2':
                             //invalid parameters
                             $this->_ERROR_CODE = 22136;
                             break;
                         case '-3':
                             //invalid date
                             $this->_ERROR_CODE = 22137;
                             break;
                         case '-12':
                             // Tai khoan khong ton tai
                             $this->_ERROR_CODE = 12001;
                             break;
                         case '-4':
                             //no customer found
                             $this->_ERROR_CODE = 22140;
                             break;
                         case '-5':
                             //transfer unsuccessful
                             $this->_ERROR_CODE = 22141;
                             break;
                         case '-13':
                         case '1':
                             //invalid account
                             $this->_ERROR_CODE = 22142;
                             break;
                         case '2':
                             //invalid amount
                             $this->_ERROR_CODE = 22143;
                             break;
                         case '3':
                             //duplicate transfer
                             $this->_ERROR_CODE = 22147;
                             break;
                         case '-14':
                         case '5':
                             //not enough balance
                             $this->_ERROR_CODE = 22144;
                             break;
                         case '6':
                             //duplicate account
                             $this->_ERROR_CODE = 22145;
                             break;
                         case '-15':
                             //can not add history transaction
                             $this->_ERROR_CODE = 22228;
                             break;
                         case '-11':
                         case '99':
                             //unknown error
                             $this->_ERROR_CODE = 22138;
                             break;
                         default:
                             $this->_ERROR_CODE = 22139;
                     }
                 }
             } else {
                 $this->_ERROR_CODE = $Withdrawal['ErrorCode'];
             }
         }
     } catch (Exception $e) {
         write_my_log_path('PHP-Exception', $function_name . ' Caught exception: ' . $e->getMessage() . ' ' . date('Y-m-d h:i:s'), DEBUG_PATH);
         $this->_ERROR_CODE = 23022;
     }
     return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
 }
            $err_text .= "<li class=\"text-danger\">Дата окончания периода использования №2 ТС не может быть меньше даты начала периода использования ТС №2</li>";
        }
        //Првоеряем на соблюдения условия минимального периода
        if (strtotime(date('d.m.Y', strtotime($auto_used_start_2 . "+3 months -1 day"))) > strtotime($auto_used_end_2)) {
            $err_text .= "<li class=\"text-danger\">Минимальный период использования №2 ТС не может быть меньше трёх месяцев</li>";
        }
    }
    //Третий период использования
    if ($auto_used_start_3 && $auto_used_end_3) {
        if (!valid_date($auto_used_start_3)) {
            $err_text .= "<li class=\"text-danger\">Дата начала периода использования №3 ТС указанна неверно</li>";
        }
        if (strtotime($auto_used_start_3) < strtotime($auto_used_end_2)) {
            $err_text .= "<li class=\"text-danger\">Дата начала периода использования №3 ТС не может быть меньше даты окончания периода использования №2 ТС</li>";
        }
        if (!valid_date($auto_used_end_3)) {
            $err_text .= "<li class=\"text-danger\">Дата окончания периода использования №3 ТС указанна неверно</li>";
        }
        if (strtotime($auto_used_start_3) > strtotime($auto_used_end_3)) {
            $err_text .= "<li class=\"text-danger\">Дата окончания периода использования №3 ТС не может быть меньше даты начала периода использования ТС №3</li>";
        }
        //Првоеряем на соблюдения условия минимального периода
        if (strtotime(date('d.m.Y', strtotime($auto_used_start_3 . "+3 months -1 day"))) > strtotime($auto_used_end_3)) {
            $err_text .= "<li class=\"text-danger\">Минимальный период использования №3 ТС не может быть меньше трёх месяцев</li>";
        }
    }
}
//Првоерка формата государственного регистрационного номера ТС
if ($_SESSION['step_1']['place_reg'] == '1' && $auto_reg_number != 'Отсутствует') {
    $num_format = "/^[а-яА-Я][0-9]{3}[а-яА-Я]{2}[0-9]{2,3}\$|^[а-яА-Я]{2}[0-9]{5,6}\$|^[0-9]{4}[а-яА-Я][0-9]{2}\$|^[0-9]{3}[а-яА-Я]{1,2}[0-9]{3,5}\$|^[0-9]{3,4}[а-яА-Я][0-9]{2}\$/u";
    $num_format_2 = "/^[0-9]{4}[а-яА-Я]{2}[0-9]{2,3}\$|^[а-яА-Я]{2}[0-9]{6,7}\$|^[0-9]{2,3}[а-яА-Я]{2}[0-9]{4}\$/u";
Example #23
0
require_once 'functions.php';
if (!canEditEvents($USER)) {
    die("Access denied");
}
foreach ($_POST as $k => $v) {
    $_POST[$k] = mysql_real_escape_string($v);
}
$id = $_POST['id'];
$name = $_POST['name'];
$type = $_POST['type'];
#if ($type < 0 || $type > 4) die("Bad event type"); # TODO
if (!valid_date($_POST['calldate'])) {
    die("Bad call date");
}
if (!valid_date($_POST['donedate'])) {
    die("Bad done date");
}
if (!valid_time($_POST['calltime'])) {
    die("Bad call time");
}
if (!valid_time($_POST['donetime'])) {
    die("Bad done time");
}
$perftime = $_POST['perftime'];
if ($perftime == '') {
    $perftime = $_POST['calltime'];
}
if (!valid_time($perftime)) {
    die("Badd performance time");
}