function checkString($com_code)
{
    include 'database.php';
    $rand = generateRandomString();
    $result = mysqli_query($connect, "SELECT * FROM `comments` WHERE `com_code`='{$com_code}'");
    $row_cnt = mysqli_num_rows($result);
    if ($row_cnt != 0) {
        return $rand;
    } else {
        checkString($rand);
    }
}
Exemple #2
0
            if (checkString($restArray->{'access'}->{'line'})) {
                echo (string) $restArray->{'access'}->{'line'} . "\t";
            }
            if (checkString($restArray->{'access'}->{'station'})) {
                echo (string) $restArray->{'access'}->{'station'} . "\t";
            }
            if (checkString($restArray->{'access'}->{'walk'})) {
                echo (string) $restArray->{'access'}->{'walk'} . "分\t";
            }
            foreach ((array) $restArray->{'code'}->{'category_name_s'} as $v) {
                if (checkString($v)) {
                    echo $v . "\t";
                }
            }
            echo "<br>";
            if (checkString($restArray->{'url'})) {
                echo "<a href=" . $restArray->{'url'} . ">リンク</a>";
            }
            echo "<hr>";
        }
    }
}
//文字列であるかをチェック
function checkString($input)
{
    if (isset($input) && is_string($input)) {
        return true;
    } else {
        return false;
    }
}
Exemple #3
0
            if ($logging) {
                logS2SQuery($_GET['start'], $_GET['end']);
            }
            // find the path
            $path = findS2SPath($start_marker, $end_marker);
        }
    }
}
if ($type == 'location') {
    $loc = $_GET['l'];
    if ($location_string != null || $location_string != "") {
        $loc = $location_string;
    }
    // log
    if ($logging) {
        logLocationQuery($loc);
    }
    if ($debug) {
        echo "location={$loc}<br/>";
    }
    $loc = fixSearchString($loc);
    // check for new york and ny
    $fix_loc = checkString($loc, $city);
    $fix_loc = checkString($fix_loc, $state);
    $locations = getLocations2($fix_loc);
    if (count($locations) == 1) {
        // grab stations
        $stations = findNearestStations2($locations[0]);
    }
}
echo "<!-- type is /" . $type . "/ -->\n";
Exemple #4
0
function saveText()
{
    global $error, $text_row, $text_id;
    $title = checkString($_POST["title"], true, 4, 80, "название перевода");
    $original_title = checkString($_POST["original_title"], true, 4, 80, "оригинальное название перевода");
    $language = intval($_POST["language"]);
    $original_language = intval($_POST["original_language"]);
    $description = mysql_real_escape_string(htmlspecialchars($_POST["description"]));
    $text_type_code = $text_row["type"];
    if ($text_type_code == 0) {
        $isbn = checkString($_POST["isbn"], true, 0, 20, "ISBN");
        $author = checkString($_POST["author"], true, 0, 100, "имя автора");
        $native_author = checkString($_POST["native_author"], true, 0, 100, "оригинальное имя автора");
        $release_date = intval($_POST["release_date"]);
    } else {
        if ($text_type_code == 1) {
            $duration = setDuration($_POST["duration"]);
        }
    }
    if (count($error) > 0) {
        return;
    }
    $query = "UPDATE `text`\n    SET\n      `title` = \"{$title}\",\n      `original_title` = \"{$original_title}\",\n      `language` = {$language},\n      `original_language` = {$original_language},\n      `description` = \"{$description}\"\n    WHERE\n      `text_id` = {$text_id}";
    executeQuery($query);
    if (count($error) > 0) {
        return;
    }
    if ($text_type_code == 0) {
        $query = "UPDATE `book`\n      SET\n        `isbn` = \"{$isbn}\",\n        `author` = \"{$author}\",\n        `native_author` = \"{$native_author}\",\n        `release_date` = {$release_date}\n      WHERE\n        `text_id` = {$text_id}";
        executeQuery($query);
    } else {
        if ($text_type_code == 1) {
            $query = "UPDATE `subtitles` SET `duration` = {$duration} WHERE `text_id` = {$text_id}";
            executeQuery($query);
        }
    }
    if (count($error) == 0) {
        header('Location: edit.php?id=' . $text_id . '&status=ok');
        die;
    }
}
Exemple #5
0
<?php

include_once "../services/connect.php";
include_once "../services/common.php";
$isUpdate = isset($isUpdate) ? $isUpdate : $_POST['myprofile_flag'];
if ($isUpdate) {
    $user_id = isset($user_id) ? $user_id : $_POST['user_id'];
    $first_name = isset($first_name) ? $first_name : $_POST['first_name'];
    $last_name = isset($last_name) ? $last_name : $_POST['last_name'];
    $age = isset($age) ? $age : $_POST['age'];
    $user_id = checkId($user_id);
    $first_name = checkString($first_name);
    $last_name = checkString($last_name);
    $age = checkString($age);
    $update_result = updateProfile($user_id, $first_name, $last_name, $age);
    if ($update_result) {
        $response = '{"status": "ok", "message": "The user profile has been updated successfully!"}';
    } else {
        $response = '{"status": "error", "message": "The user profile could not be updated. Please try again later."}';
    }
    echo $response;
}
function updateProfile($user_id, $first_name, $last_name, $age)
{
    $sql = sprintf("UPDATE user SET first_name = '%s', last_name = '%s', age = '%s' WHERE user_id = %d", $first_name, $last_name, $age, $user_id);
    return executeSql($sql);
}
     }
     // find the path
     $path = findS2SPath($start_marker, $end_marker);
 } else {
     if ($_GET['type'] == 'dir') {
         // get locations for end address
         $saddr = $_GET['saddr'];
         // check for boston and ma
         $saddr = checkString($saddr, $city);
         $saddr = checkString($saddr, $state);
         $starts = getLocations($saddr);
         // get locations for start address
         $daddr = $_GET['daddr'];
         // check for boston and ma
         $daddr = checkString($daddr, $city);
         $daddr = checkString($daddr, $state);
         $ends = getLocations($daddr);
         // log
         if ($logging) {
             logDirectionsQuery($_GET['saddr'], $_GET['daddr']);
         }
         // only one of each, so we can calculate the path
         if (count($starts) == 1 && count($ends) == 1) {
             $start_location = $starts[0];
             $end_location = $ends[0];
             #echo "start_location = " . $start_location . "<br/>";
             #echo "end_location = " . $end_location . "<br/>";
             if ($start_location != false && $end_location != false) {
                 // find three closest starting stations
                 $start_stations = findNearestStations2($start_location);
                 // find three closest ending stations
Exemple #7
0
            return false;
        }
        if (!$checkPair2LettersAppearsAtLeastTwice) {
            $pair = $string[$i] . $string[$i + 1];
            $checkPair2LettersAppearsAtLeastTwice = 2 <= substr_count($string, $pair);
        }
        if (!$checkOneLetterWhichRepeatsWithExactlyOneLetterBetweenThem) {
            $pattern = '/' . $string[$i] . '.' . $string[$i] . '/';
            $checkOneLetterWhichRepeatsWithExactlyOneLetterBetweenThem = 1 === preg_match($pattern, $string);
        }
        if ($checkPair2LettersAppearsAtLeastTwice && $checkOneLetterWhichRepeatsWithExactlyOneLetterBetweenThem) {
            return true;
        }
    }
}
$input = explode("\n", trim(file_get_contents(__DIR__ . '/files/input_05.txt')));
$niceStrings = $niceStrings2 = 0;
foreach ($input as $string) {
    if (checkString(strtolower($string))) {
        $niceStrings++;
    }
    if ($result = checkString2(strtolower($string))) {
        $niceStrings2++;
    }
}
echo sprintf('------ Day 5 ------' . "\r\n");
echo sprintf('See the instruction on http://adventofcode.com/day/5' . "\r\n\r\n");
echo sprintf('--- Part 1 --- ' . "\r\n\r\n");
echo sprintf('%d strings are nice' . "\r\n\r\n", $niceStrings);
echo sprintf('--- Part 2 --- ' . "\r\n\r\n");
echo sprintf('%d strings are nice with the new method' . "\r\n\r\n", $niceStrings2);
Exemple #8
0
    function checkString($subject, $type = 'quotes', $maxLength = 0) {

        if (@is_array($subject)) {

            foreach ($subject as $k => $v)
                $subject[$k] = checkString($v, $type, $maxLength);
        } else {

            $subject = trim($subject);
            if ($maxLength)
                $subject = mb_substr($subject, 0, $maxLength);

            //if ($type=='quotes') $subject = str_replace("'", "\'", $subject);

            if ($type == 'digits')
                $subject = preg_replace('/[^\\d]+/', '', $subject);
            if ($type == 'numeric')
                $subject = preg_replace('/[^\\d]+/', '', $subject);
            if ($type == 'alpha')
                $subject = preg_replace('/[^a-zA-Z]+/', '', $subject);
            if ($type == 'al-num')
                $subject = preg_replace('/[^\\w]+/', '', $subject);
            if ($type == 'mail')
                $subject = mb_substr(preg_replace('/[^-@_.\\w]+/', '', $subject), 0, 100);
            if ($type == 'phone')
                $subject = mb_substr(preg_replace('/[^-,.()\\w\\s]+/', '', $subject), 0, 100);
            if ($type == 'url')
                $subject = mb_substr(preg_replace('/[^-_:\/\/.:\\w]+/', '', $subject), 0, 100);
            if ($type == 'file')
                $subject = mb_strtolower(mb_substr(preg_replace('/[^-_.\\w]/', '', str_replace(" ", "_", $subject)), 0, 100));
            if ($type == 'id')
                $subject = mb_substr(preg_replace('/[^-_a-zA-Z0-9]+/', '', str_replace(" ", "_", $subject)), 0, 32);

            if ($type == 'file' && $subject == '')
                $subject = uniqueID();
        }

        return $subject;
    }
Exemple #9
0
function login($email, $password)
{
    $email = checkString($email);
    $password = checkString($password);
    return doLogin($email, $password);
}
Exemple #10
0
function modelSourceCode($data)
{
    if (isset($data) && is_array($data)) {
        // think this more accurate
        $total = 0;
        $total = count($data);
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['Key'] == 'PRI') {
                $data[0]['tableName'] = str_replace('Id', '', $data[0]['columnName']);
            }
        }
        $str .= "<?php  namespace Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\MultiModel;\n";
        $str .= " use Core\\Validation\\ValidationClass;\n";
        $str .= "\$x = addslashes(realpath(__FILE__));\n";
        $str .= "// auto detect if \\ consider come from windows else / from linux\n";
        $str .= "\$pos = strpos(\$x, \"\\\\\");\n";
        $str .= "if (\$pos !== false) {\n";
        $str .= "    \$d = explode(\"\\\\\", \$x);\n";
        $str .= "} else {  \n";
        $str .= "    \$d = explode(\"/\", \$x);\n";
        $str .= "}\n";
        $str .= "\$newPath = null;\n";
        $str .= "for (\$i = 0; \$i < count(\$d); \$i ++) {\n";
        $str .= "    // if find the library or package then stop\n";
        $str .= "    if (\$d[\$i] == 'library' || \$d[\$i] == 'v3') {\n";
        $str .= "        break;\n";
        $str .= "    }\n";
        $str .= "    \$newPath[] .= \$d[\$i] . \"/\";\n";
        $str .= "}\n";
        $str .= "\$fakeDocumentRoot = null;\n";
        $str .= "for (\$z = 0; \$z < count(\$newPath); \$z ++) {\n";
        $str .= "    \$fakeDocumentRoot .= \$newPath[\$z];\n";
        $str .= "}\n";
        $str .= "\$newFakeDocumentRoot = str_replace(\"//\", \"/\", \$fakeDocumentRoot); // start\n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classValidation.php\"); \n";
        $str .= "/** \n";
        $str .= " * Class " . ucfirst($data[0]['tableName']) . "\n";
        $str .= " * This is " . $data[0]['tableName'] . " model file.This is to ensure strict setting enable for all variable enter to database \n";
        $str .= " * \n";
        $str .= " * @name IDCMS.\n";
        $str .= " * @version 2\n";
        $str .= " * @author hafizan\n";
        $str .= " * @package Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Model;\n";
        $str .= " * @subpackage " . ucwords($data[0]['module']) . " \n";
        $str .= " * @link http://www.hafizan.com\n";
        $str .= " * @license http://www.gnu.org/copyleft/lesser.html LGPL\n";
        $str .= " */\n";
        $str .= "class " . ucfirst($data[0]['tableName']) . "Model extends ValidationClass { \n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                $x = str_replace($data[0]['tableName'], '', $data[$i]['columnName']);
                if ($x == 'Desc') {
                    $x = "Description";
                } else {
                    if ($x == 'Id') {
                        $x = "Primary Key";
                    } else {
                        $findMe = 'Id';
                        $pos = strpos($x, $findMe);
                        // mostly it was a foreign key
                        if ($pos !== false) {
                            $x = ucfirst(str_replace("Id", "", $x));
                        } else {
                        }
                    }
                }
                $str .= " /**\n";
                $str .= "  * " . checkString($x) . "\n";
                $str .= "  * @var " . $data[$i]['field'] . " \n";
                $str .= "  */\n";
                $str .= "  private \$" . $data[$i]['columnName'] . "; \n";
            }
        }
        $str .= " /**\n";
        $str .= "  * Class Loader\n";
        $str .= "  * @see ValidationClass::execute()\n";
        $str .= "  */\n";
        $str .= " public function execute() {\n";
        $str .= "     /**\n";
        $str .= "     *  Basic Information Table\n";
        $str .= "     **/\n";
        $str .= "     \$this->setTableName('" . $data[0]['tableName'] . "');\n";
        for ($d = 0; $d < $total; $d++) {
            if ($data[$d]['columnName'] != 'isDefault' && $data[$d]['columnName'] != 'companyId' && $data[$d]['columnName'] != 'isNew' && $data[$d]['columnName'] != 'isDraft' && $data[$d]['columnName'] != 'isUpdate' && $data[$d]['columnName'] != 'isDelete' && $data[$d]['columnName'] != 'isActive' && $data[$d]['columnName'] != 'isApproved' && $data[$d]['columnName'] != 'isReview' && $data[$d]['columnName'] != 'isPost' && $data[$d]['columnName'] != 'executeBy' && $data[$d]['columnName'] != 'executeTime') {
                $str .= "for (\$i = 1; \$i <= " . $data[0]['targetMaximumTabRecord'] . ";\$i++) {\n";
                $str .= "         if (isset(\$_GET ['" . $data[$d]['columnName'] . "_'.\$i])) {\n";
                $str .= "             \$this->set" . ucfirst($data[$d]['columnName']) . "(\$this->strict(\$_GET ['" . $data[$d]['columnName'] . "_'.\$i] , 'numeric'), \$i);\n";
                $str .= "         }\n";
                $str .= " \t}\n";
            }
        }
        $str .= "    /**\n";
        $str .= "     * All the \$_SESSION Environment\n";
        $str .= "     */\n";
        $str .= "     if (isset(\$_SESSION ['staffId'])) {\n";
        $str .= "         \$this->setExecuteBy(\$_SESSION ['staffId']);\n";
        $str .= "     }\n";
        $str .= "    /**\n";
        $str .= "     * TimeStamp Value.\n";
        $str .= "     */\n";
        $str .= "     if (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "         \$this->setExecuteTime(\"'\" . date(\"Y-m-d H:i:s\") . \"'\");\n";
        $str .= "     } else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "         \$this->setExecuteTime(\"'\" . date(\"Y-m-d H:i:s.u\") . \"'\");\n";
        $str .= "     } else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "         \$this->setExecuteTime(\"to_date('\" . date(\"Y-m-d H:i:s\") . \"','YYYY-MM-DD HH24:MI:SS')\");\n";
        $str .= "     }\n";
        $str .= " }\n";
        $str .= "    /**\n";
        $str .= "     * Create\n";
        $str .= "     * @see ValidationClass::create()\n";
        $str .= "     * @return void\n";
        $str .= "     */ \n";
        $str .= "     public function create() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(1, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t} \n";
        $str .= "    /**\n";
        $str .= "     * Update\n";
        $str .= "     * @see ValidationClass::update()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "     public function update() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(0, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(1, '', 'single');\n";
        $str .= "         \$this->setIsActive(1, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t}\n";
        $str .= "    /** \n";
        $str .= "     * Delete\n";
        $str .= "     * @see ValidationClass::delete()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "\tpublic function delete() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(0, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, '', 'single');\n";
        $str .= "         \$this->setIsDelete(1, '', 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t} \n";
        $str .= "    /**\n";
        $str .= "     * Draft\n";
        $str .= "     * @see ValidationClass::draft()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "\tpublic function draft() {\n";
        $str .= "\t\t\$this->setIsDefault(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsNew(1, 0, 'single');\n";
        $str .= "\t\t\$this->setIsDraft(1, 0, 'single');\n";
        $str .= "\t\t\$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsActive(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsDelete(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsApproved(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsReview(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t}\n";
        $str .= "    /**\n";
        $str .= "     * Approved\n";
        $str .= "     * @see ValidationClass::approved()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "\tpublic function approved() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(1, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t}\n";
        $str .= "    /**\n";
        $str .= "     * Review\n";
        $str .= "     * @see ValidationClass::review()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "     public function review() { \n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(1, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t} \n";
        $str .= "    /**\n";
        $str .= "     * Post\n";
        $str .= "     * @see ValidationClass::post()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "     public function post() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(1, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(1, 0, 'single');\n";
        $str .= "\t}\n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                $str .= "     /** \n";
                if ($data[$i]['Key'] == 'PRI') {
                    $str .= "     * Set Primary Key Value \n";
                } else {
                    $str .= "\t * To Set " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " \n";
                }
                $str .= "     * @param bool|int|string \$value \n";
                $str .= "     * @param int \$key List. \n";
                $str .= "     * @return \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucfirst($data[0]['tableName']) . "\\Model\\" . ucfirst($data[0]['tableName']) . "Model\n";
                $str .= "     */ \n";
                $str .= "     public function set" . ucfirst($data[$i]['columnName']) . "(\$value, \$key) { \n";
                $str .= "            \$this->" . $data[$i]['columnName'] . "[\$key] = \$value;\n";
                $str .= "           return \$this;\n";
                $str .= "    }\n";
                $str .= "    /**\n";
                if ($data[$i]['Key'] == 'PRI') {
                    $str .= "     * Return Primary Key Value\n";
                } else {
                    $str .= "\t * To Return " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " \n";
                }
                $str .= "     * @param int \$key List.\n";
                $str .= "     * @return bool|int|string\n";
                $str .= "     */\n";
                $str .= "    public function get" . ucfirst($data[$i]['columnName']) . "(\$key) {\n";
                $str .= "            return \$this->" . $data[$i]['columnName'] . " [\$key];\n";
                $str .= "\t}\n";
            }
        }
        $str .= "}\n";
        $str .= "?>";
    }
    return $str;
}
<?php

function checkString($this)
{
    #function object
    //filter for the spam list
    $filter_list = array();
    array_push($filter_list, "This", "computer", "microsoft", "windows");
    //for each list to go through array and find strings within the strings
    foreach ($filter_list as $key) {
        //this to search through the string and find the keywords
        if (strpos($this, $key) !== false) {
            echo 'true';
        }
    }
}
$string = "This is totally spam";
checkString($string);
Exemple #12
0
function controllerSourceCode($data, $dataTabDetail = null)
{
    $total = 0;
    if (!is_array($data)) {
        $data = array();
    }
    $service = 0;
    if (isset($dataTabDetail)) {
        $tabCounter = count($dataTabDetail);
    }
    if (isset($data) && is_array($data)) {
        $total = count($data);
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['Key'] == 'PRI') {
                $data[0]['tableName'] = str_replace('Id', '', $data[0]['columnName']);
            }
        }
        $foreignKeyYes = null;
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                $foreignKeyYes = 1;
                break;
            }
        }
        $str .= "<?php namespace Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Controller; \n";
        $str .= "use Core\\ConfigClass;\n";
        $str .= "use Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Model\\" . ucwords($data[0]['tableName']) . "Model;\n";
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $str .= "use Core\\" . ucwords($dataTabDetail[0]['package']) . "\\" . ucwords($dataTabDetail[0]['module']) . "\\" . ucwords($dataTabDetail[0]['tableName']) . "\\MultiModel\\" . ucwords($dataTabDetail[0]['tableName']) . "Model;\n";
                }
            }
        }
        if ($foreignKeyYes == 1) {
            $str .= "use Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Service\\" . ucwords($data[0]['tableName']) . "Service;\n";
        }
        $str .= "use Core\\Document\\Trail\\DocumentTrailClass;\n";
        $str .= "use Core\\RecordSet\\RecordSet;\n";
        $str .= "use Core\\shared\\SharedClass;\n";
        $str .= "if (!isset(\$_SESSION)) { \n";
        $str .= "    session_start(); \n";
        $str .= "} \n";
        $str .= "\$x = addslashes(realpath(__FILE__));\n";
        $str .= "// auto detect if \\ consider come from windows else / from linux\n";
        $str .= "\$pos = strpos(\$x, \"\\\\\");\n";
        $str .= "if (\$pos !== false) {\n";
        $str .= "    \$d = explode(\"\\\\\", \$x);\n";
        $str .= "} else {  \n";
        $str .= "    \$d = explode(\"/\", \$x);\n";
        $str .= "}\n";
        $str .= "\$newPath = null;\n";
        $str .= "for (\$i = 0; \$i < count(\$d); \$i ++) {\n";
        $str .= "    // if find the library or package then stop\n";
        $str .= "    if (\$d[\$i] == 'library' || \$d[\$i] == 'v3') {\n";
        $str .= "        break;\n";
        $str .= "    }\n";
        $str .= "    \$newPath[] .= \$d[\$i] . \"/\";\n";
        $str .= "}\n";
        $str .= "\$fakeDocumentRoot = null;\n";
        $str .= "for (\$z = 0; \$z < count(\$newPath); \$z ++) {\n";
        $str .= "    \$fakeDocumentRoot .= \$newPath[\$z];\n";
        $str .= "}\n";
        $str .= "\$newFakeDocumentRoot = str_replace(\"//\", \"/\", \$fakeDocumentRoot); // start\n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classAbstract.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classRecordSet.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classDate.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classDocumentTrail.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classShared.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"v3/system/document/model/documentModel.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/model/" . $data[0]['tableName'] . "Model.php\"); \n";
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $str .= "require_once (\$newFakeDocumentRoot.\"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/MultiModel/" . $dataTabDetail[0]['tableName'] . "Model.php\"); \n";
                }
            }
        }
        if ($foreignKeyYes == 1) {
            $str .= "require_once (\$newFakeDocumentRoot.\"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/service/" . $data[0]['tableName'] . "Service.php\"); \n";
        }
        $str .= "/** \n";
        $str .= " * Class " . ucfirst($data[0]['tableName']) . "\n";
        $str .= " * this is " . $data[0]['tableName'] . " controller files. \n";
        $str .= " * @name IDCMS \n";
        $str .= " * @version 2 \n";
        $str .= " * @author hafizan \n";
        $str .= " * @package  Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Controller \n";
        $str .= " * @subpackage " . ucwords($data[0]['module']) . " \n";
        $str .= " * @link http://www.hafizan.com \n";
        $str .= " * @license http://www.gnu.org/copyleft/lesser.html LGPL \n";
        $str .= " */ \n";
        $str .= "class " . ucfirst($data[0]['tableName']) . "Class extends ConfigClass { \n";
        // start object
        $str .= "\t/** \n";
        $str .= "\t * Connection to the database \n";
        $str .= "\t * @var \\Core\\Database\\Mysql\\Vendor \n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$q; \n";
        $str .= "\t/** \n";
        $str .= "\t * Php Excel Generate Microsoft Excel 2007 Output.Format : xlsx/pdf \n";
        $str .= "\t * @var \\PHPExcel \n";
        $str .= "\t */ \n";
        $str .= "\tprivate \$excel; \n";
        $str .= "\t/** \n";
        $str .= "\t * Record Pagination \n";
        $str .= "\t * @var \\Core\\RecordSet\\RecordSet \n";
        $str .= "\t */ \n";
        $str .= "\tprivate \$recordSet; \n";
        $str .= "\t/** \n";
        $str .= "\t * Document Trail Audit. \n";
        $str .= "\t * @var \\Core\\Document\\Trail\\DocumentTrailClass \n";
        $str .= "\t */ \n";
        $str .= "\tprivate \$documentTrail; \n";
        $str .= "\t/** \n";
        $str .= "\t * Model \n";
        $str .= "\t * @var \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Model\\" . ucwords($data[0]['tableName']) . "Model \n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$model; \n";
        if ($foreignKeyYes == 1) {
            $str .= "\t/** \n";
            $str .= "\t * Service-Business Application Process or other ajax request \n";
            $str .= "\t * @var \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Service\\" . ucwords($data[0]['tableName']) . "Service \n";
            $str .= "\t */ \n";
            $str .= "\tpublic \$service; \n";
        }
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $str .= "\t/** \n";
                    $str .= "\t * (" . $dataTabDetail[$j] . " Service-Business Application Process or other ajax request \n";
                    $str .= "\t * @var \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Service\\" . ucwords($dataTabDetail[$j][0]['tableName']) . "Service \n";
                    $str .= "\t */ \n";
                    $str .= "\tpublic " . $dataTabDetail[$j] . "Service; \n";
                }
            }
        }
        $str .= "\t/** \n";
        $str .= "\t * System Format \n";
        $str .= "\t * @var \\Core\\shared\\SharedClass\n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$systemFormat; \n";
        // end object
        $str .= "\t/** \n";
        $str .= "\t * Translation Array \n";
        $str .= "\t * @var mixed \n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$translate; \n";
        $str .= "\t/** \n";
        $str .= "\t * Leaf Access  \n";
        $str .= "\t * @var mixed \n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$leafAccess; \n";
        $str .= "\t/** \n";
        $str .= "\t * Translate Label \n";
        $str .= "\t * @var array\n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$t; \n";
        $str .= "\t/** \n";
        $str .= "\t * System Format \n";
        $str .= "\t * @var array\n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$systemFormatArray; \n";
        $str .= "\t/** \n";
        $str .= "\t * Constructor \n";
        $str .= "\t */ \n";
        $str .= "   function __construct() { \n";
        $str .= "       parent::__construct(); \n";
        $str .= "       if(\$_SESSION['companyId']){\n";
        $str .= "           \$this->setCompanyId(\$_SESSION['companyId']);\n";
        $str .= "       }else{\n";
        $str .= "           // fall back to default database if anything wrong\n";
        $str .= "           \$this->setCompanyId(1);\n";
        $str .= "       }\n";
        $str .= "       \$this->translate=array();\n";
        $str .= "       \$this->t=array();\n";
        $str .= "       \$this->leafAccess=array();\n";
        $str .= "       \$this->systemFormat=array();\n";
        $str .= "       \$this->setViewPath(\"./v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/view/" . $data[0]['tableName'] . ".php\"); \n";
        $str .= "       \$this->setControllerPath(\"./v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/controller/" . $data[0]['tableName'] . "Controller.php\");\n";
        if ($foreignKeyYes == 1) {
            $str .= "       \$this->setServicePath(\"./v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/service/" . $data[0]['tableName'] . "Service.php\"); \n";
        }
        $str .= "   } \n";
        $str .= "\t/** \n";
        $str .= "\t * Class Loader \n";
        $str .= "\t */ \n";
        $str .= "\tfunction execute() { \n";
        $str .= "       parent::__construct(); \n";
        $str .= "       \$this->setAudit(1); \n";
        $str .= "       \$this->setLog(1); \n";
        $str .= "       \$this->model  = new " . ucfirst($data[0]['tableName']) . "Model(); \n";
        $str .= "       \$this->model->setVendor(\$this->getVendor()); \n";
        $str .= "       \$this->model->execute(); \n";
        if ($data[0]['targetBusinessWorkFlow'] == 1) {
            $str .= "       \$this->setViewPath(\"./v3/financial/accountReceivable/view/\" . \$this->model->getFrom());";
        }
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$this->q = new \\Core\\Database\\Mysql\\Vendor(); \n";
        $str .= "       } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "           \$this->q = new \\Core\\Database\\Mssql\\Vendor(); \n";
        $str .= "       } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "           \$this->q = new \\Core\\Database\\Oracle\\Vendor(); \n";
        $str .= "       }\n";
        $str .= "       \$this->setVendor(\$this->getVendor()); \n";
        $str .= "       \$this->q->setRequestDatabase(\$this->q->getCoreDatabase()); \n";
        $str .= "       // \$this->q->setApplicationId(\$this->getApplicationId()); \n";
        $str .= "       // \$this->q->setModuleId(\$this->getModuleId()); \n";
        $str .= "       // \$this->q->setFolderId(\$this->getFolderId()); \n";
        $str .= "       \$this->q->setLeafId(\$this->getLeafId()); \n";
        $str .= "       \$this->q->setLog(\$this->getLog()); \n";
        $str .= "       \$this->q->setAudit(\$this->getAudit()); \n";
        $str .= "       \$this->q->connect(\$this->getConnection(), \$this->getUsername(), \$this->getDatabase(), \$this->getPassword()); \n\n";
        $str .= "       \$data = \$this->q->getLeafLogData();\n";
        $str .= "       if (is_array(\$data) && count(\$data)>0 ) {\n";
        $str .= "           \$this->q->getLog(\$data['isLog']);\n";
        $str .= "           \$this->q->setAudit(\$data['isAudit']);\n";
        $str .= "       }\n";
        $str .= "       if(\$this->getAudit()==1){\n";
        $str .= "           \$this->q->setAudit(\$this->getAudit());\n";
        $str .= "           \$this->q->setTableName(\$this->model->getTableName());\n";
        $str .= "           \$this->q->setPrimaryKeyName(\$this->model->getPrimaryKeyName());\n";
        $str .= "       }\n";
        $str .= "       \$translator = new SharedClass();   \n";
        $str .= "       \$translator->setCurrentTable(\$this->model->getTableName()); \n";
        $str .= "       \$translator->setLeafId(\$this->getLeafId()); \n";
        $str .= "       \$translator->execute();\n\n";
        $str .= "       \$this->translate   = \$translator->getLeafTranslation(); // short because code too long  \n";
        $str .= "       \$this->t           = \$translator->getDefaultTranslation(); // short because code too long  \n\n";
        // print title of report
        $str .= "       \$arrayInfo         =   \$translator->getFileInfo(); \n";
        $str .= "       \$applicationNative =   \$arrayInfo['applicationNative']; \n";
        $str .= "       \$folderNative      =   \$arrayInfo['folderNative']; \n";
        $str .= "       \$moduleNative      =   \$arrayInfo['moduleNative']; \n";
        $str .= "       \$leafNative        =   \$arrayInfo['leafNative']; \n";
        $str .= "       \$this->setApplicationId(\$arrayInfo['applicationId']); \n";
        $str .= "       \$this->setModuleId(\$arrayInfo['moduleId']); \n";
        $str .= "       \$this->setFolderId(\$arrayInfo['folderId']); \n";
        $str .= "       \$this->setLeafId(\$arrayInfo['leafId']); \n";
        $str .= "       \$this->setReportTitle(\$applicationNative.\" :: \".\$moduleNative.\" :: \".\$folderNative.\" :: \".\$leafNative); \n\n";
        $str .= "       \$this->service  = new " . ucfirst($data[0]['tableName']) . "Service(); \n";
        $str .= "       \$this->service->q = \$this->q; \n";
        $str .= "       \$this->service->t = \$this->t; \n";
        $str .= "       \$this->service->setVendor(\$this->getVendor()); \n";
        $str .= "       \$this->service->setServiceOutput(\$this->getServiceOutput()); \n";
        $str .= "       \$this->service->execute(); \n\n";
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $str .= "       \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service  = new " . ucfirst($dataTabDetail[$j][0]['tableName']) . "Service(); \n";
                    $str .= "       \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service->q = \$this->q; \n";
                    $str .= "       \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service->t = \$this->t; \n";
                    $str .= "       \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service->setVendor(\$this->getVendor()); \n";
                    $str .= "       \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service->setServiceOutput(\$this->getServiceOutput()); \n";
                    $str .= "       \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service->execute(); \n\n";
                }
            }
        }
        // record set for paging
        $str .= "       \$this->recordSet = new RecordSet(); \n";
        $str .= "       \$this->recordSet->q = \$this->q; \n";
        $str .= "       \$this->recordSet->setCurrentTable(\$this->model->getTableName()); \n";
        $str .= "       \$this->recordSet->setPrimaryKeyName(\$this->model->getPrimaryKeyName()); \n";
        if ($data[0]['targetBusinessWorkFlow'] == 1) {
            $str .= "if (\$this->model->getFrom() == '" . $data[0]['tableName'] . ".php' || \$this->model->getFrom() == '" . $data[0]['tableName'] . "Maintenance.php') {\n";
            $str .= " if (\$this->getVendor() == self::MYSQL) {\n";
            $str .= "   \$this->recordSet->setOverrideMysqlStatement(\" AND `" . strtolower($data[0]['tableName']) . "`.`isActive` = 1 AND `i" . strtolower($data[0]['tableName']) . "`.`isPost` = 0 \");\n";
            $str .= " } else if (\$this->getVendor() == self::MSSQL) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\" AND [" . $data[0]['tableName'] . "].[isActive] = 1 AND [" . $data[0]['tableName'] . "].[isPost] = 0 \");\n";
            $str .= " } else if (\$this->getVendor() == self::ORACLE) {\n";
            $str .= "   \$this->recordSet->setOverrideMysqlStatement(\" AND " . strtoupper($data[0]['tableName']) . ".ISACTIVE = 1 AND " . strtoupper($data[0]['tableName']) . ".ISPOST = 0 \");\n";
            $str .= " }\n";
            $str .= "}\n";
            $str .= "if (\$this->model->getFrom() == '" . $data[0]['tableName'] . "Post.php' || \$this->model->getFrom() == '" . $data[0]['tableName'] . "Posting.php') {\n";
            $str .= " if (\$this->getVendor() == self::MYSQL) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\" AND `" . strtolower($data[0]['tableName']) . "`.`isActive` = 1  AND `" . strtolower($data[0]['tableName']) . "`.`isBalance`   =    1 AND `" . strtolower($data[0]['tableName']) . "`.`isPost` = 0 \");\n";
            $str .= " } else if (\$this->getVendor() == self::MSSQL) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\" AND [" . $data[0]['tableName'] . "].[isActive] = 1  AND [" . $data[0]['tableName'] . "].[isBalance]   =    1 AND [" . $data[0]['tableName'] . "].[isPost] = 0 \");\n";
            $str .= " } else if (\$this->getVendor() == self::ORACLE) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\" AND " . strtoupper($data[0]['tableName']) . ".ISACTIVE = 1 AND " . strtoupper($data[0]['tableName']) . ".ISBALANCE =    1 AND " . strtoupper($data[0]['tableName']) . ".ISPOST = 0 \");\n";
            $str .= " }\n";
            $str .= "}\n";
            $str .= "if (\$this->model->getFrom() == '" . $data[0]['tableName'] . "History.php') {\n";
            $str .= "\tif (\$this->getVendor() == self::MYSQL) {\n";
            $str .= "\t\t\$this->recordSet->setOverrideMysqlStatement(\"  AND `" . strtolower($data[0]['tableName']) . "`.`isActive` = 1 AND `" . strtolower($data[0]['tableName']) . "`.`isBalance`   =    1 AND `" . strtolower($data[0]['tableName']) . "`.`isPost` = 1 \");\n";
            $str .= "\t} else if (\$this->getVendor() == self::MSSQL) {\n";
            $str .= "\t\t\$this->recordSet->setOverrideMysqlStatement(\"  AND [" . $data[0]['tableName'] . "].[isActive] = 1 AND [" . $data[0]['tableName'] . "].[isBalance]   =    1  AND [" . strtoupper($data[0]['tableName']) . "].[isPost] = 1 \");\n";
            $str .= "\t} else if (\$this->getVendor() == self::ORACLE) {\n";
            $str .= "\t\t\$this->recordSet->setOverrideMysqlStatement(\"  AND " . strtoupper($data[0]['tableName']) . ".ISACTIVE = 1 AND " . strtoupper($data[0]['tableName']) . ".ISBALANCE =    1  AND " . strtoupper($data[0]['tableName']) . ".ISPOST = 1 \");\n";
            $str .= "\t}\n";
            $str .= "}\n";
            $str .= "if (\$this->model->getFrom() == '" . $data[0]['tableName'] . "Cancel.php' || \$this->model->getFrom() =='" . $data[0]['tableName'] . "Void.php') {\n";
            $str .= " if (\$this->getVendor() == self::MYSQL) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\"  AND `invoice`.`isActive` = 0  \");\n";
            $str .= " } else if (\$this->getVendor() == self::MSSQL) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\"  AND [invoice].[isActive] = 0 \");\n";
            $str .= " } else if (\$this->getVendor() == self::ORACLE) {\n";
            $str .= "  \$this->recordSet->setOverrideMysqlStatement(\"  AND INVOICE.ISACTIVE = 0 \");\n";
            $str .= " }\n";
            $str .= "}\n";
        }
        $str .= "       \$this->recordSet->execute(); \n\n";
        // document trail.. backup all file to here.. path only
        $str .= "       \$this->documentTrail = new DocumentTrailClass(); \n";
        $str .= "       \$this->documentTrail->q = \$this->q; \n";
        $str .= "       \$this->documentTrail->setVendor(\$this->getVendor()); \n";
        $str .= "       \$this->documentTrail->setStaffId(\$this->getStaffId()); \n";
        $str .= "       \$this->documentTrail->setLanguageId(\$this->getLanguageId()); \n";
        $str .= "       \$this->documentTrail->setApplicationId(\$this->getApplicationId());\n";
        $str .= "       \$this->documentTrail->setModuleId(\$this->getModuleId());\n";
        $str .= "       \$this->documentTrail->setFolderId(\$this->getFolderId());\n";
        $str .= "       \$this->documentTrail->setLeafId(\$this->getLeafId());\n";
        $str .= "       \$this->documentTrail->execute(); \n\n";
        $str .= "       \$this->systemFormat = new SharedClass();  \n";
        $str .= "       \$this->systemFormat->q = \$this->q;  \n";
        $str .= "       \$this->systemFormat->setCurrentTable(\$this->model->getTableName());  \n";
        $str .= "       \$this->systemFormat->execute();  \n\n";
        $str .= "       \$this->systemFormatArray  =   \$this->systemFormat->getSystemFormat();  \n\n";
        $str .= "       \$this->excel = new \\PHPExcel (); \n";
        $str .= "   } \n";
        $str .= "  \n";
        $str .= "\t/**  \n";
        $str .= "\t * Create\n";
        $str .= "\t * @see config::create()  \n";
        $str .= "\t */  \n";
        $str .= "\tpublic function create() {  \n";
        $str .= "       header('Content-Type:application/json; charset=utf-8');  \n";
        $str .= "       \$start = microtime(true);  \n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) {  \n";
        $str .= "           \$sql = \"SET NAMES utf8\";  \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->fast(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       } \n";
        $str .= "       \$this->q->start();  \n";
        $str .= "       \$this->model->create();  \n";
        $str .= "       \$sql=null;\n";
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['Key'] == 'MUL' && $data[$i]['columnName'] != 'companyId') {
                    $str .= "       if(!\$this->model->get" . ucfirst($data[$i]['columnName']) . "()){\n";
                    $str .= "           \$this->model->set" . ucfirst($data[$i]['columnName']) . "(\$this->service->get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "DefaultValue());\n";
                    $str .= "       }\n";
                }
            }
        }
        // optional document number .
        $str .= "        //\$this->model->setDocumentNumber(\$this->getDocumentNumber());\n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) {  \n";
        $mysqlInsertStatement = null;
        $mysqlInsertStatementAField = null;
        $mysqlInsertStatementInsideValue = null;
        $mysqlInsertStatement .= "       \$sql=\"\n            INSERT INTO `" . strtolower($data[0]['tableName']) . "` \n            (\n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                $mysqlInsertStatementAField .= "                 `" . $data[$i]['columnName'] . "`,\n";
            }
        }
        $mysqlInsertStatement .= substr($mysqlInsertStatementAField, 0, -2);
        $mysqlInsertStatement .= "\n       ) VALUES ( \n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] == 'executeTime') {
                    $mysqlInsertStatementInsideValue .= "                 \".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\",\n";
                } else {
                    if ($data[$i]['columnName'] == 'companyId') {
                        $mysqlInsertStatementInsideValue .= "                 '\".\$this->getCompanyId().\"',\n";
                    } else {
                        if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation') {
                            $mysqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\"',\n";
                        } else {
                            $mysqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "(0, 'single').\"',\n";
                        }
                    }
                }
            }
        }
        $mysqlInsertStatement .= substr($mysqlInsertStatementInsideValue, 0, -2);
        $mysqlInsertStatement .= "\n       );\";\n";
        $str .= $mysqlInsertStatement;
        $str .= "\t\t } else if (\$this->getVendor() == self::MSSQL) {  \n";
        $mssqlInsertStatement = null;
        $mssqlInsertStatementAField = null;
        $mssqlInsertStatementField = null;
        $mssqlInsertStatementInsideValue = null;
        $mssqlInsertStatementValue = null;
        $mssqlInsertStatement .= "       \$sql=\"\n            INSERT INTO [" . $data[0]['tableName'] . "] \n            (\n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 0) {
                $mssqlInsertStatementAField .= "                 [" . $data[$i]['columnName'] . "],\n";
            }
        }
        $mssqlInsertStatementField .= substr($mssqlInsertStatementAField, 0, -2);
        $mssqlInsertStatement .= $mssqlInsertStatementField;
        $mssqlInsertStatement .= "\n) VALUES ( \n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] == 'executeTime') {
                    $mssqlInsertStatementInsideValue .= "                 \".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\",\n";
                } elseif ($data[$i]['columnName'] == 'companyId') {
                    $mssqlInsertStatementInsideValue .= "                 '\".\$this->getCompanyId().\"',\n";
                } elseif ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation') {
                    $mssqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\"',\n";
                } else {
                    $mssqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "(0, 'single').\"',\n";
                }
            }
        }
        $mssqlInsertStatementValue .= substr($mssqlInsertStatementInsideValue, 0, -2);
        $mssqlInsertStatement .= $mssqlInsertStatementValue;
        $mssqlInsertStatement .= "\n            );\";\n";
        $str .= $mssqlInsertStatement;
        $str .= "       } else if (\$this->getVendor() == self::ORACLE) {  \n";
        $oracleInsertStatement = null;
        $oracleInsertStatementAField = null;
        $oracleInsertStatementField = null;
        $oracleInsertStatementInsideValue = null;
        $oracleInsertStatementValue = null;
        $oracleInsertStatement .= "            \$sql=\"\n            INSERT INTO " . strtoupper($data[0]['tableName']) . " \n            (\n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                $oracleInsertStatementAField .= "                 " . strtoupper($data[$i]['columnName']) . ",\n";
            }
        }
        $oracleInsertStatementField .= substr($oracleInsertStatementAField, 0, -2);
        $oracleInsertStatement .= $oracleInsertStatementField;
        $oracleInsertStatement .= "\n            ) VALUES ( \n";
        $i = 0;
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] == 'executeTime') {
                    $oracleInsertStatementInsideValue .= "                 \".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\",\n";
                } else {
                    if ($data[$i]['columnName'] == 'companyId') {
                        $oracleInsertStatementInsideValue .= "                 '\".\$this->getCompanyId().\"',\n";
                    } else {
                        if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation') {
                            $oracleInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\"',\n";
                        } else {
                            $oracleInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "(0, 'single').\"',\n";
                        }
                    }
                }
            }
        }
        $oracleInsertStatementValue .= substr($oracleInsertStatementInsideValue, 0, -2);
        $oracleInsertStatement .= $oracleInsertStatementValue;
        $oracleInsertStatement .= "\n            );\";\n";
        $str .= $oracleInsertStatement;
        $str .= "       }  \n";
        $str .= "       try {\n";
        $str .= "           \$this->q->create(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           \$this->q->rollback();\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        $str .= "       \$" . $data[0]['primaryKeyName'] . " = \$this->q->lastInsertId(); \n";
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $str .= " \$this->" . ucfirst($dataTabDetail[$j][0]['tableName']) . "Service->create()\n";
                }
            }
        }
        $str .= "       \$this->q->commit(); \n";
        $str .= "       \$end = microtime(true); \n";
        $str .= "       \$time = \$end - \$start; \n";
        $str .= "       echo json_encode( \n";
        $str .= "           array(\t\"success\" => true, \n";
        $str .= "                   \"message\" => \$this->t['newRecordTextLabel'],  \n";
        $str .= "                   \"staffName\" => \$_SESSION['staffName'],  \n";
        $str .= "                   \"executeTime\" =>date('d-m-Y H:i:s'),  \n";
        $str .= "                   \"totalRecord\"=>\$this->getTotalRecord(),\n";
        $str .= "                   \"" . $data[0]['primaryKeyName'] . "\" => \$" . $data[0]['primaryKeyName'] . ",\n";
        $str .= "                   \"time\"=>\$time)); \n";
        $str .= "       exit(); \n";
        $str .= "\t} \n";
        $str .= "\t/** \n";
        $str .= "    * Read\n";
        $str .= "\t * @see config::read() \n";
        $str .= "\t */ \n";
        $str .= "\tpublic function read() { \n";
        $str .= "       if (\$this->getPageOutput() == 'json' ||  \$this->getPageOutput() =='table') { \n";
        $str .= "           header('Content-Type:application/json; charset=utf-8'); \n";
        $str .= "       } \n";
        $str .= "       \$start = microtime(true); \n";
        $str .= "       if(isset(\$_SESSION['isAdmin'])) { \n";
        // here we can arrange if request wanted to filter by user key in only
        $str .= "           if (\$_SESSION['isAdmin'] == 0) { \n";
        $str .= "               if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "                   \$this->setAuditFilter(\" `" . strtolower($data[0]['tableName']) . "`.`isActive` = 1  AND `" . strtolower($data[0]['tableName']) . "`.`companyId`='\".\$this->getCompanyId().\"' \"); \n";
        $str .= "               } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "                   \$this->setAuditFilter(\" [" . $data[0]['tableName'] . "].[isActive] = 1 AND [" . $data[0]['tableName'] . "].[companyId]='\".\$this->getCompanyId().\"' \"); \n";
        $str .= "               } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "                   \$this->setAuditFilter(\" " . strtoupper($data[0]['tableName']) . ".ISACTIVE = 1  AND " . strtoupper($data[0]['tableName']) . ".COMPANYID='\".\$this->getCompanyId().\"'\"); \n";
        $str .= "               } \n";
        $str .= "           } else if (\$_SESSION['isAdmin'] == 1) { \n";
        $str .= "               if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "                   \$this->setAuditFilter(\"   `" . strtolower($data[0]['tableName']) . "`.`companyId`='\".\$this->getCompanyId().\"'\t\"); \n";
        $str .= "               } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "                   \$this->setAuditFilter(\" [" . $data[0]['tableName'] . "].[companyId]='\".\$this->getCompanyId().\"' \"); \n";
        $str .= "               } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "                   \$this->setAuditFilter(\" " . strtoupper($data[0]['tableName']) . ".COMPANYID='\".\$this->getCompanyId().\"' \"); \n";
        $str .= "               } \n";
        $str .= "           } \n";
        $str .= "       } \n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \"SET NAMES utf8\"; \n";
        $str .= "     try {\n";
        $str .= "       \$this->q->fast(\$sql);\n";
        $str .= "     } catch (\\Exception \$e) {\n";
        $str .= "       echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       }  \n";
        $str .= "       \$sql=null;\n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $mysqlReadStatement = null;
        $mysqlReadInsideStatement = null;
        $mysqlReadStatement .= "\n      \$sql = \"\n       SELECT";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                //exception for some cases
                if ($data[$i]['columnName'] == 'businessPartnerId') {
                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Company";
                } else {
                    if ($data[$i]['columnName'] == 'employeeId') {
                        $field = str_replace("Id", "", $data[$i]['columnName']) . "FirstName";
                    } else {
                        if ($data[$i]['columnName'] == 'staffId') {
                            $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                        } else {
                            if ($data[$i]['columnName'] == 'chartOfAccountId') {
                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Title";
                            } else {
                                if ($data[$i]['columnName'] == 'assetId') {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                } else {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Description";
                                }
                            }
                        }
                    }
                }
                $mysqlReadInsideStatement .= "                    `" . strtolower(str_replace("Id", "", $data[$i]['columnName'])) . "`.`" . $field . "`,\n";
                $mysqlReadInsideStatement .= "                    `" . strtolower($data[0]['tableName']) . "`.`" . $data[$i]['columnName'] . "`,\n";
            } else {
                $mysqlReadInsideStatement .= "                    `" . strtolower($data[0]['tableName']) . "`.`" . $data[$i]['columnName'] . "`,\n";
            }
        }
        $mysqlReadStatement .= $mysqlReadInsideStatement;
        $mysqlReadStatement .= "                    `staff`.`staffName`\n";
        $mysqlReadStatement .= "\t\t  FROM      `" . strtolower($data[0]['tableName']) . "`\n";
        $mysqlReadStatement .= "\t\t  JOIN      `staff`\n";
        $mysqlReadStatement .= "\t\t  ON        `" . strtolower($data[0]['tableName']) . "`.`executeBy` = `staff`.`staffId`\n";
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['Key'] == 'MUL') {
                    // assume in the same package also
                    $mysqlReadStatement .= "\tJOIN\t`" . strtolower(str_replace("Id", "", $data[$i]['columnName'])) . "`\n";
                    $mysqlReadStatement .= "\tON\t\t`" . strtolower(str_replace("Id", "", $data[$i]['columnName'])) . "`.`" . $data[$i]['columnName'] . "` = `" . strtolower($data[0]['tableName']) . "`.`" . $data[$i]['columnName'] . "`\n";
                }
            }
        }
        $mysqlReadStatement .= "\t\t  WHERE     \" . \$this->getAuditFilter(); \n";
        $str .= $mysqlReadStatement;
        $str .= "       if (\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')) { \n";
        $str .= "           \$sql .= \" AND `" . strtolower($data[0]['tableName']) . "`.`\" . \$this->model->getPrimaryKeyName() . \"`='\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"'\";  \n";
        $str .= "       }\n";
        // there was a chance to filter  foreign key value
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                    if ($data[$i]['columnName'] != 'companyId') {
                        $str .= "       if (\$this->model->get" . ucfirst($data[$i]['columnName']) . "()) { \n";
                        $str .= "           \$sql .= \" AND `" . strtolower($data[0]['tableName']) . "`.`" . $data[$i]['columnName'] . "`='\".\$this->model->get" . ucfirst($data[$i]['columnName']) . "().\"'\";  \n";
                        $str .= "       }\n";
                    }
                }
            }
        }
        $str .= " } else if (\$this->getVendor() == self::MSSQL) {  \n";
        $mssqlReadStatement = null;
        $mssqlReadInsideStatement = null;
        $mssqlReadStatement .= "\n\t\t  \$sql = \"\n\t\t  SELECT";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                //exception for some cases
                if ($data[$i]['columnName'] == 'businessPartnerId') {
                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Company";
                } else {
                    if ($data[$i]['columnName'] == 'employeeId') {
                        $field = str_replace("Id", "", $data[$i]['columnName']) . "FirstName";
                    } else {
                        if ($data[$i]['columnName'] == 'staffId') {
                            $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                        } else {
                            if ($data[$i]['columnName'] == 'chartOfAccountId') {
                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Title";
                            } else {
                                if ($data[$i]['columnName'] == 'assetId') {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                } else {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Description";
                                }
                            }
                        }
                    }
                }
                $mssqlReadInsideStatement .= "                    [" . str_replace("Id", "", $data[$i]['columnName']) . "].[" . $field . "],\n";
                $mssqlReadInsideStatement .= "                    [" . $data[0]['tableName'] . "].[" . $data[$i]['columnName'] . "],\n";
            } else {
                $mssqlReadInsideStatement .= "                    [" . $data[0]['tableName'] . "].[" . $data[$i]['columnName'] . "],\n";
            }
        }
        $mssqlReadStatement .= $mssqlReadInsideStatement;
        $mssqlReadStatement .= "                    [staff].[staffName] \n";
        $mssqlReadStatement .= "\t\t  FROM \t[" . $data[0]['tableName'] . "]\n";
        $mssqlReadStatement .= "\t\t  JOIN\t[staff]\n";
        $mssqlReadStatement .= "\t\t  ON\t[" . $data[0]['tableName'] . "].[executeBy] = [staff].[staffId]\n";
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                    // assume in the same package also
                    $mssqlReadStatement .= "\tJOIN\t[" . str_replace("Id", "", $data[$i]['columnName']) . "]\n";
                    $mssqlReadStatement .= "\tON\t\t[" . str_replace("Id", "", $data[$i]['columnName']) . "].[" . $data[$i]['columnName'] . "] = [" . $data[0]['tableName'] . "].[" . $data[$i]['columnName'] . "]\n";
                }
            }
        }
        $mssqlReadStatement .= "\t\t  WHERE     \" . \$this->getAuditFilter(); \n";
        $str .= $mssqlReadStatement;
        $str .= "       if (\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')) { \n";
        $str .= "           \$sql .= \" AND [" . $data[0]['tableName'] . "].[\" . \$this->model->getPrimaryKeyName() . \"]\t\t=\t'\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"'\"; \n";
        $str .= "       } \n";
        // there was a chance to filter  foreign key value
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                    if ($data[$i]['columnName'] != 'companyId') {
                        $str .= "       if (\$this->model->get" . ucfirst($data[$i]['columnName']) . "()) { \n";
                        $str .= "           \$sql .= \" AND [" . $data[0]['tableName'] . "].[" . $data[$i]['columnName'] . "]='\".\$this->model->get" . ucfirst($data[$i]['columnName']) . "().\"'\";  \n";
                        $str .= "       }\n";
                    }
                }
            }
        }
        $str .= "\t\t} else if (\$this->getVendor() == self::ORACLE) {  \n";
        $oracleReadStatement = null;
        $oracleReadInsideStatement = null;
        $oracleReadStatement .= "\n\t\t  \$sql = \"\n\t\t  SELECT";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                //exception for some cases
                if ($data[$i]['columnName'] == 'businessPartnerId') {
                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Company";
                } else {
                    if ($data[$i]['columnName'] == 'employeeId') {
                        $field = str_replace("Id", "", $data[$i]['columnName']) . "FirstName";
                    } else {
                        if ($data[$i]['columnName'] == 'staffId') {
                            $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                        } else {
                            if ($data[$i]['columnName'] == 'chartOfAccountId') {
                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Title";
                            } else {
                                if ($data[$i]['columnName'] == 'assetId') {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                } else {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Description";
                                }
                            }
                        }
                    }
                }
                $oracleReadInsideStatement .= "                    " . strtoupper(str_replace("Id", "", $data[$i]['columnName'])) . "." . strtoupper($field) . " AS  \\\"" . $field . "\\\",\n";
                $oracleReadInsideStatement .= "                    " . strtoupper($data[0]['tableName']) . "." . strtoupper($data[$i]['columnName']) . " AS \\\"" . $data[$i]['columnName'] . "\\\",\n";
            } else {
                $oracleReadInsideStatement .= "                    " . strtoupper($data[0]['tableName']) . "." . strtoupper($data[$i]['columnName']) . " AS \\\"" . $data[$i]['columnName'] . "\\\",\n";
            }
        }
        $oracleReadStatement .= $oracleReadInsideStatement;
        $oracleReadStatement .= "                    STAFF.STAFFNAME AS \\\"staffName\\\" \n";
        $oracleReadStatement .= "\t\t  FROM \t" . strtoupper($data[0]['tableName']) . " \n";
        $oracleReadStatement .= "\t\t  JOIN\tSTAFF \n";
        $oracleReadStatement .= "\t\t  ON\t" . strtoupper($data[0]['tableName']) . ".EXECUTEBY = STAFF.STAFFID \n ";
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                    // assume in the same package also
                    $oracleReadStatement .= "\tJOIN\t" . strtoupper(str_replace("Id", "", $data[$i]['columnName'])) . "\n";
                    $oracleReadStatement .= "\tON\t\t" . strtoupper(str_replace("Id", "", $data[$i]['columnName'])) . "." . strtoupper($data[$i]['columnName']) . " = " . strtoupper($data[0]['tableName']) . "." . strtoupper($data[$i]['columnName']) . "\n";
                }
            }
        }
        $oracleReadStatement .= "         WHERE     \" . \$this->getAuditFilter(); \n";
        $str .= $oracleReadStatement;
        $str .= "           if (\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single'))  {\n";
        $str .= "               \$sql .= \" AND " . strtoupper($data[0]['tableName']) . ". \".strtoupper(\$this->model->getPrimaryKeyName()) . \"='\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"'\"; \n";
        $str .= "           } \n";
        // there was a chance to filter  foreign key value
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                    if ($data[$i]['columnName'] != 'companyId') {
                        $str .= "       if (\$this->model->get" . ucfirst($data[$i]['columnName']) . "()) { \n";
                        $str .= "           \$sql .= \" AND " . strtoupper($data[0]['tableName']) . "." . strtoupper($data[$i]['columnName']) . "='\".\$this->model->get" . ucfirst($data[$i]['columnName']) . "().\"'\";  \n";
                        $str .= "       }\n";
                    }
                }
            }
        }
        $str .= "           }else { \n";
        $str .= "               header('Content-Type:application/json; charset=utf-8');  \n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
        $str .= "               exit(); \n";
        $str .= "\t\t} \n";
        $str .= "\t\t/** \n";
        $str .= "\t\t * filter column based on first character \n";
        $str .= "\t\t */ \n";
        $str .= "\t\tif(\$this->getCharacterQuery()){ \n";
        $str .= "               if(\$this->getVendor()==self::MYSQL){ \n";
        $str .= "                   \$sql.=\" AND `" . strtolower($data[0]['tableName']) . "`.`\".\$this->model->getFilterCharacter().\"` like '\".\$this->getCharacterQuery().\"%'\"; \n";
        $str .= "               } else if(\$this->getVendor()==self::MSSQL){ \n";
        $str .= "                   \$sql.=\" AND [" . $data[0]['tableName'] . "].[\".\$this->model->getFilterCharacter().\"] like '\".\$this->getCharacterQuery().\"%'\"; \n";
        $str .= "               } else if (\$this->getVendor()==self::ORACLE){ \n";
        $str .= "                   \$sql.=\" AND Initcap(" . strtoupper($data[0]['tableName']) . ".\".strtoupper(\$this->model->getFilterCharacter()).\") LIKE Initcap('\".\$this->getCharacterQuery().\"%')\"; \n";
        $str .= "               }\n";
        $str .= "\t\t} \n";
        $str .= "\t\t/** \n";
        $str .= "\t\t * filter column based on Range Of Date \n";
        $str .= "\t\t * Example Day,Week,Month,Year \n";
        $str .= "\t\t */ \n";
        $str .= "\t\tif(\$this->getDateRangeStartQuery()){ \n";
        $str .= "               if(\$this->getVendor()==self::MYSQL){ \n";
        $str .= "                   \$sql.=\$this->q->dateFilter('" . strtolower($data[0]['tableName']) . "',\$this->model->getFilterDate(),\$this->getDateRangeStartQuery(),\$this->getDateRangeEndQuery(),\$this->getDateRangeTypeQuery(),\$this->getDateRangeExtraTypeQuery()); \n";
        $str .= "               } else if(\$this->getVendor()==self::MSSQL){ \n";
        $str .= "                   \$sql.=\$this->q->dateFilter('" . $data[0]['tableName'] . "',\$this->model->getFilterDate(),\$this->getDateRangeStartQuery(),\$this->getDateRangeEndQuery(),\$this->getDateRangeTypeQuery(),\$this->getDateRangeExtraTypeQuery()); \n";
        $str .= "               } else if (\$this->getVendor()==self::ORACLE){ \n";
        $str .= "                   \$sql.=\$this->q->dateFilter('" . strtoupper($data[0]['tableName']) . "',\$this->model->getFilterDate(),\$this->getDateRangeStartQuery(),\$this->getDateRangeEndQuery(),\$this->getDateRangeTypeQuery(),\$this->getDateRangeExtraTypeQuery()); \n";
        $str .= "               }\n";
        $str .= "           } \n";
        $str .= "\t\t/** \n";
        $str .= "\t\t * filter column don't want to filter.Example may contain  sensitive information or unwanted to be search. \n";
        $str .= "\t\t * E.g  \$filterArray=array('`leaf`.`leafId`'); \n";
        $str .= "\t\t * @variables \$filterArray; \n";
        $str .= "\t\t */  \n";
        $str .= "        \$filterArray =null;\n";
        $str .= "        if(\$this->getVendor() ==self::MYSQL) { \n";
        $str .= "\t\t    \$filterArray = array(\"`" . strtolower($data[0]['tableName']) . "`.`" . $data[0]['primaryKeyName'] . "`\",\n                                              \"`staff`.`staffPassword`\"); \n";
        $str .= "        } else if (\$this->getVendor() == self::MSSQL) {\n ";
        $str .= "\t\t    \$filterArray = array(\"[" . strtolower($data[0]['tableName']) . "].[" . $data[0]['primaryKeyName'] . "]\",\n                                              \"[staff].[staffPassword]\"); \n";
        $str .= "        } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "\t\t    \$filterArray = array(\"" . strtoupper($data[0]['tableName']) . "." . strtoupper($data[0]['primaryKeyName']) . "\",\n                                              \"STAFF.STAFFPASSWORD\"); \n";
        $str .= "        }\n";
        $str .= "\t\t\$tableArray = null; \n";
        $str .= "\t\tif(\$this->getVendor()==self::MYSQL){ \n";
        // list all foreign table and link ir up... yeah..
        $listTableForeignKey = null;
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                if (str_replace("Id", "", $data[$i]['columnName']) != 'company') {
                    $listTableForeignKey .= "'" . str_replace("Id", "", $data[$i]['columnName']) . "',";
                }
            }
        }
        $listForeignKeyTable = "," . substr($listTableForeignKey, 0, -1);
        $str .= "\t\t\t\$tableArray = array('staff','" . strtolower($data[0]['tableName']) . "'" . strtolower($listForeignKeyTable) . "); \n";
        $str .= "\t\t} else if(\$this->getVendor()==self::MSSQL){ \n";
        $str .= "\t\t\t\$tableArray = array('staff','" . strtolower($data[0]['tableName']) . "'" . strtolower($listForeignKeyTable) . "); \n";
        $str .= "\t\t} else if (\$this->getVendor()==self::ORACLE){ \n";
        $str .= "\t\t\t\$tableArray = array('STAFF','" . strtoupper($data[0]['tableName']) . "'" . strtoupper($listForeignKeyTable) . "); \n";
        $str .= "\t\t}   \n";
        $str .= "       \$tempSql=null;\n";
        $str .= "\t\tif (\$this->getFieldQuery()) { \n";
        $str .= "               \$this->q->setFieldQuery(\$this->getFieldQuery()); \n";
        $str .= "               if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "                   \$sql .= \$this->q->quickSearch(\$tableArray, \$filterArray); \n";
        $str .= "               } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "                   \$tempSql = \$this->q->quickSearch(\$tableArray, \$filterArray); \n";
        $str .= "                   \$sql .= \$tempSql; \n";
        $str .= "               } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "                   \$tempSql = \$this->q->quickSearch(\$tableArray, \$filterArray); \n";
        $str .= "                   \$sql .= \$tempSql; \n";
        $str .= "               } \n";
        $str .= "\t\t} \n";
        $str .= "       \$tempSql2=null;\n";
        $str .= "\t\tif (\$this->getGridQuery()) { \n";
        $str .= "               \$this->q->setGridQuery(\$this->getGridQuery()); \n";
        $str .= "               if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "                   \$sql .= \$this->q->searching(); \n";
        $str .= "               } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "                   \$tempSql2 = \$this->q->searching(); \n";
        $str .= "                   \$sql .= \$tempSql2; \n";
        $str .= "               } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "                   \$tempSql2 = \$this->q->searching(); \n";
        $str .= "                   \$sql .= \$tempSql2; \n";
        $str .= "               } \n";
        $str .= "\t\t} \n";
        $str .= "       try {\n";
        $str .= "           \$this->q->read(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        $str .= "\t\t\$total = intval(\$this->q->numberRows()); \n";
        $str .= "\t\tif ( \$this->getSortField()) { \n";
        $str .= "               if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "                   \$sql .= \"\tORDER BY `\" . \$this->getSortField() . \"` \" . \$this->getOrder() . \" \"; \n";
        $str .= "               } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "                   \$sql .= \"\tORDER BY [\" . \$this->getSortField() . \"] \" . \$this->getOrder() . \" \"; \n";
        $str .= "               } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "                   \$sql .= \"\tORDER BY \" . strtoupper(\$this->getSortField()) . \" \" . strtoupper(\$this->getOrder()) . \" \"; \n";
        $str .= "               } \n";
        $str .= "\t\t} else {\n";
        $str .= "       \t// @note sql server 2012 must order by first then offset ??\n";
        $str .= "        if(\$this->getVendor() == self::MSSQL){\n";
        $str .= "            \$sql .= \"\tORDER BY [\" . \$this->model->getTableName() . \"].[\" . \$this->model->getPrimaryKeyName() . \"] ASC \";\n";
        $str .= "        }\n";
        $str .= "    }\n";
        $str .= "\t\t\$_SESSION ['sql'] = \$sql; // push to session so can make report via excel and pdf \n";
        $str .= "\t\t\$_SESSION ['start'] = \$this->getStart(); \n";
        $str .= "\t\t\$_SESSION ['limit'] = \$this->getLimit(); \n";
        $str .= "       \$sqlDerived = null;\n";
        $str .= "\t\tif ( \$this->getLimit()) { \n";
        $str .= "\t\t\t// only mysql have limit \n";
        $str .= "\t\t\tif (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "\t\t\t\t\$sqlDerived  = \$sql.\" LIMIT  \" . \$this->getStart() . \",\" . \$this->getLimit() . \" \"; \n";
        $str .= "\t\t\t} else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "              \$sqlDerived =\n";
        $str .= "              \$sql . \" OFFSET \" . \$this->getStart() . \" ROWS\n";
        $str .= "              FETCH NEXT \t\" . \$this->getLimit() . \" ROWS ONLY \"; \n";
        $str .= "\t\t\t } else if (\$this->getVendor() == self::ORACLE) { \n";
        $oracleReadPagingStatement = null;
        // since it derived table why not shorted up  only
        $oracleReadPagingStatement .= "\n\t\t\t\t\t\t\$sqlDerived = \"\n\n\t\t\t\t\t\tSELECT *\n\n\t\t\t\t\t\tFROM \t(\n \t\n\t\t\t\t\t\t\t\t\tSELECT\ta.*,\n\n\t\t\t\t\t\t\t\t\t\t\trownum r\n\n\t\t\t\t\t\t\t\t\tFROM ( \".\$sql.\"\n \n\t\t\t\t\t\t\t\t) a\n\n\t\t\t\t\t\tWHERE \trownum <= '\" . (\$this->getStart() + \$this->getLimit()) . \"' )\n\t\t\t\t\t\tWHERE \tr >=  '\" . (\$this->getStart() + 1) . \"'\";\n";
        $str .= $oracleReadPagingStatement;
        $str .= "\t\t\t } else { \n";
        $str .= "\t\t\t\techo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
        $str .= "\t\t\t\texit(); \n";
        $str .= "\t\t\t} \n";
        $str .= "\t\t} \n";
        $str .= "\t\t/* \n";
        $str .= "\t\t *  Only Execute One Query \n";
        $str .= "\t\t */ \n";
        $str .= "\t\tif (!(\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single'))) { \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->read(\$sqlDerived);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "\t\t} \n";
        $str .= "\t\t\$items = array(); \n";
        $str .= "           \$i = 1; \n";
        $str .= "\t\twhile ((\$row = \$this->q->fetchAssoc()) == TRUE) { \n";
        $str .= "               \$row['total'] = \$total; // small override \n";
        $str .= "               \$row['counter'] = \$this->getStart() + {$i}; \n";
        $str .= "               if (\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')) { \n";
        $str .= "                   \$row['firstRecord'] = \$this->firstRecord('value'); \n";
        $str .= "                   \$row['previousRecord'] = \$this->previousRecord('value', \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')); \n";
        $str .= "                   \$row['nextRecord'] = \$this->nextRecord('value', \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')); \n";
        $str .= "                   \$row['lastRecord'] = \$this->lastRecord('value'); \n";
        $str .= "               }  \n";
        $str .= "               \$items [] = \$row; \n";
        $str .= "               \$i++; \n";
        $str .= "\t\t}  \n";
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $str .= " \$itemDetail = \$this->" . $dataTabDetail[$j][0]['tableName'] . "Service->read();\n";
                    $str .= " \$item[] = array_merge(\$items,\$itemsDetail);\n";
                }
            }
        }
        $str .= "\t\tif (\$this->getPageOutput() == 'html') { \n";
        $str .= "               return \$items; \n";
        // this is for detail table if
        $str .= "           } else if (\$this->getPageOutput() == 'json') { \n";
        $str .= "           if (\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')) { \n";
        $str .= "               \$end = microtime(true); \n";
        $str .= "               \$time = \$end - \$start; \n";
        $str .= "               echo str_replace(array(\"[\",\"]\"),\"\",json_encode(array( \n";
        $str .= "                   'success' => true,  \n";
        $str .= "                   'total' => \$total,  \n";
        $str .= "                   'message' => \$this->t['viewRecordMessageLabel'],  \n";
        $str .= "                   'time' => \$time,  \n";
        $str .= "                   'firstRecord' => \$this->firstRecord('value'),  \n";
        $str .= "                   'previousRecord' => \$this->previousRecord('value', \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')),  \n";
        $str .= "                   'nextRecord' => \$this->nextRecord('value', \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')),  \n";
        $str .= "                   'lastRecord' => \$this->lastRecord('value'), \n";
        $str .= "                   'data' => \$items))); \n";
        $str .= "               exit(); \n";
        $str .= "           } else { \n";
        $str .= "               if (count(\$items) == 0) { \n";
        $str .= "                   \$items = ''; \n";
        $str .= "               } \n";
        $str .= "               \$end = microtime(true); \n";
        $str .= "               \$time = \$end - \$start; \n";
        $str .= "               echo json_encode(array( \n";
        $str .= "                   'success' =>true,  \n";
        $str .= "                   'total' => \$total,  \n";
        $str .= "                   'message' => \$this->t['viewRecordMessageLabel'], \n";
        $str .= "                   'time' => \$time,  \n";
        $str .= "                   'firstRecord' => \$this->recordSet->firstRecord('value'),  \n";
        $str .= "                   'previousRecord' => \$this->recordSet->previousRecord('value', \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')),  \n";
        $str .= "                   'nextRecord' => \$this->recordSet->nextRecord('value', \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single')),  \n";
        $str .= "                   'lastRecord' => \$this->recordSet->lastRecord('value'), \n";
        $str .= "                   'data' => \$items)); \n";
        $str .= "               exit();  \n";
        $str .= "           } \n";
        $str .= "       }\t \n";
        $str .= "       return false;\n";
        $str .= "   } \n";
        $str .= "\t/**\n";
        $str .= "    * Update\n";
        $str .= "\t * @see config::update() \n";
        $str .= "\t */ \n";
        $str .= "   function update() { \n";
        $str .= "       header('Content-Type:application/json; charset=utf-8'); \n";
        $str .= "       \$start = microtime(true); \n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \"SET NAMES utf8\"; \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->fast(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       } \n";
        $str .= "       \$this->q->start(); \n";
        $str .= "       \$this->model->update(); \n";
        $str .= "       // before updating check the id exist or not . if exist continue to update else warning the user \n";
        $str .= "       \$sql=null;\n";
        if ($foreignKeyYes == 1) {
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['Key'] == 'MUL' && $data[$i]['columnName'] != 'companyId') {
                    $str .= "       if(!\$this->model->get" . ucfirst($data[$i]['columnName']) . "()){\n";
                    $str .= "           \$this->model->set" . ucfirst($data[$i]['columnName']) . "(\$this->service->get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "DefaultValue());\n";
                    $str .= "       }\n";
                }
            }
        }
        $str .= "       if (\$this->getVendor() == self::MYSQL) {  \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT\t`\" . \$this->model->getPrimaryKeyName() . \"`\n";
        $str .= "           FROM \t`" . strtolower($data[0]['tableName']) . "` \n";
        $str .= "           WHERE  `companyId`='\".\$this->getCompanyId.\"'";
        $str .= "           AND \t   `" . str_replace("Id", "", $data[0]['primaryKeyName']) . "LineNumber` = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $data[0]['primaryKeyName'])) . "LineNumber(0, 'single') . \"' \"; \n";
        $str .= "       } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT\t[\" . \$this->model->getPrimaryKeyName() . \"] \n";
        $str .= "           FROM \t[" . $data[0]['tableName'] . "] \n";
        $str .= "           WHERE  [companyId] ='\".\$this->getCompanyId.\"'";
        $str .= "           AND \t   [" . str_replace("Id", "", $data[0]['primaryKeyName']) . "LineNumber] = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $data[0]['primaryKeyName'])) . "LineNumber(0, 'single') . \"' \"; \n";
        $str .= "       } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT\t\" . strtoupper(\$this->model->getPrimaryKeyName()) . \" \n";
        $str .= "           FROM \t" . strtoupper($data[0]['tableName']) . " \n";
        $str .= "           WHERE  COMPANYID='\".\$this->getCompanyId.\"'";
        $str .= "           AND \t   " . strtoupper(str_replace("Id", "", $data[0]['primaryKeyName'])) . "LINENUMBER = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $data[0]['primaryKeyName'])) . "LineNumber(0, 'single') . \"' \"; \n";
        $str .= "       }\n";
        $str .= "       \$result = \$this->q->fast(\$sql); \n";
        $str .= "       \$total = \$this->q->numberRows(\$result, \$sql); \n";
        $str .= "       if (\$total == 0) { \n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$this->t['recordNotFoundMessageLabel'])); \n";
        $str .= "           exit(); \n";
        $str .= "       } else { \n";
        $str .= "           if (\$this->getVendor() == self::MYSQL) { \n";
        $mysqlUpdateStatementInsideValue = null;
        $mysqlUpdateStatementValue = null;
        $mysqlUpdateStatement = "               \$sql=\"\n";
        $mysqlUpdateStatement .= "               UPDATE `" . strtolower($data[0]['tableName']) . "` SET \n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] == 'companyId') {
                    //  $mysqlUpdateStatementInsideValue .= "                       `" . $data [$i] ['columnName'] . "` = \".\$_SESSION['companyId'].\",\n";
                } else {
                    if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation' && $data[$i]['columnName'] != 'isReconciled' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                        $mysqlUpdateStatementInsideValue .= "                       `" . $data[$i]['columnName'] . "` = '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\"',\n";
                    } else {
                        if ($data[$i]['columnName'] == 'executeTime') {
                            $mysqlUpdateStatementInsideValue .= "                       `" . $data[$i]['columnName'] . "` = \".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\",\n";
                        } else {
                            $mysqlUpdateStatementInsideValue .= "                       `" . $data[$i]['columnName'] . "` = '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "('0','single').\"',\n";
                        }
                    }
                }
            }
        }
        $mysqlUpdateStatementValue .= substr($mysqlUpdateStatementInsideValue, 0, -2);
        $mysqlUpdateStatement .= $mysqlUpdateStatementValue;
        $mysqlUpdateStatement .= "\n               WHERE    `" . $data[0]['primaryKeyName'] . "`='\".\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "('0','single').\"'\";\n\n";
        $str .= $mysqlUpdateStatement;
        $str .= "           } else if (\$this->getVendor() == self::MSSQL) {  \n";
        $mssqlUpdateStatementInsideValue = null;
        $mssqlUpdateStatementValue = null;
        $mssqlUpdateStatement = "                \$sql=\"\n";
        $mssqlUpdateStatement .= "                UPDATE [" . $data[0]['tableName'] . "] SET \n";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] == 'companyId') {
                    //   $mssqlUpdateStatementInsideValue .= "                       [" . $data [$i] ['columnName'] . "] = \".\$_SESSION['companyId'].\",\n";
                } else {
                    if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation' && $data[$i]['columnName'] != 'isReconciled' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                        $mssqlUpdateStatementInsideValue .= "                       [" . $data[$i]['columnName'] . "] = '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\"',\n";
                    } else {
                        if ($data[$i]['columnName'] == 'executeTime') {
                            $mssqlUpdateStatementInsideValue .= "                       [" . $data[$i]['columnName'] . "] = \".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\",\n";
                        } else {
                            $mssqlUpdateStatementInsideValue .= "                       [" . $data[$i]['columnName'] . "] = '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "(0, 'single').\"',\n";
                        }
                    }
                }
            }
        }
        $mssqlUpdateStatementValue .= substr($mssqlUpdateStatementInsideValue, 0, -2);
        $mssqlUpdateStatement .= $mssqlUpdateStatementValue;
        $mssqlUpdateStatement .= "\n                WHERE   [" . $data[0]['primaryKeyName'] . "]='\".\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "('0','single').\"'\";\n\n";
        $str .= $mssqlUpdateStatement;
        $str .= "           } else if (\$this->getVendor() == self::ORACLE) {  \n";
        $oracleUpdateStatementInsideValue = null;
        $oracleUpdateStatementValue = null;
        $oracleUpdateStatement = "                \$sql=\"\n";
        $oracleUpdateStatement .= "                UPDATE " . strtoupper($data[0]['tableName']) . " SET\n ";
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] == 'companyId') {
                    //       $oracleUpdateStatementInsideValue .= "                       " . strtoupper($data [$i] ['columnName']) . " = '\".\$_SESSION['companyId'].\"',\n";
                } else {
                    if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation' && $data[$i]['columnName'] != 'isReconciled' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                        $oracleUpdateStatementInsideValue .= "                       " . strtoupper($data[$i]['columnName']) . " = '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\"',\n";
                    } else {
                        if ($data[$i]['columnName'] == 'executeTime') {
                            $oracleUpdateStatementInsideValue .= "                       " . strtoupper($data[$i]['columnName']) . " = \".\$this->model->get" . ucFirst($data[$i]['columnName']) . "().\",\n";
                        } else {
                            $oracleUpdateStatementInsideValue .= "                       " . strtoupper($data[$i]['columnName']) . " = '\".\$this->model->get" . ucFirst($data[$i]['columnName']) . "(0, 'single').\"',\n";
                        }
                    }
                }
            }
        }
        $oracleUpdateStatementValue .= substr($oracleUpdateStatementInsideValue, 0, -2);
        $oracleUpdateStatement .= $oracleUpdateStatementValue;
        $oracleUpdateStatement .= "\n                WHERE  " . strtoupper($data[0]['primaryKeyName']) . "='\".\$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "('0','single').\"'\";\n\n";
        $str .= $oracleUpdateStatement;
        $str .= "           } \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->update(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               \$this->q->rollback();\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       } \n";
        $str .= "       \$this->q->commit(); \n";
        $str .= "       \$end = microtime(true); \n";
        $str .= "       \$time = \$end - \$start; \n";
        $str .= "       echo json_encode( \n";
        $str .= "           array(  \"success\" =>true, \n";
        $str .= "               \"message\" => \$this->t['updateRecordTextLabel'], \n";
        $str .= "               \"time\"=>\$time)); \n";
        $str .= "               exit(); \n";
        $str .= "   } \n";
        $str .= "\t/** \n";
        $str .= "    * Delete\n";
        $str .= "\t * @see config::delete() \n";
        $str .= "\t */ \n";
        $str .= "   function delete() { \n";
        $str .= "       header('Content-Type:application/json; charset=utf-8'); \n";
        $str .= "       \$start = microtime(true); \n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \"SET NAMES utf8\"; \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->fast(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       } \n";
        $str .= "       \$this->q->start(); \n";
        $str .= "       \$this->model->delete(); \n";
        $str .= "       // before updating check the id exist or not . if exist continue to update else warning the user \n";
        $str .= "       \$sql=null;\n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT\t`\" . \$this->model->getPrimaryKeyName() . \"` \n";
        $str .= "           FROM \t`" . strtolower($data[0]['tableName']) . "` \n";
        $str .= "           WHERE  \t`\" . \$this->model->getPrimaryKeyName() . \"` = '\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"' \";  \n";
        $str .= "       } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT\t[\" . \$this->model->getPrimaryKeyName() . \"]  \n";
        $str .= "           FROM \t[" . $data[0]['tableName'] . "] \n";
        $str .= "           WHERE  \t[\" . \$this->model->getPrimaryKeyName() . \"] = '\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"' \"; \n";
        $str .= "       } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT\t\" . strtoupper(\$this->model->getPrimaryKeyName()) . \" \n";
        $str .= "           FROM \t" . strtoupper($data[0]['tableName']) . " \n";
        $str .= "           WHERE  \t\" . strtoupper(\$this->model->getPrimaryKeyName()) . \" = '\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"' \"; \n";
        $str .= "       }  \n";
        $str .= "       try {\n";
        $str .= "           \$result    =   \$this->q->fast(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        $str .= "       \$total = \$this->q->numberRows(\$result, \$sql); \n";
        $str .= "       if (\$total == 0) { \n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$this->t['recordNotFoundMessageLabel'])); \n";
        $str .= "           exit(); \n";
        $str .= "       } else { \n";
        $str .= "           if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "               \$sql=\"\n";
        $str .= "               UPDATE  `" . strtolower($data[0]['tableName']) . "` \n";
        $str .= "               SET     `isDefault`     =   '\" . \$this->model->getIsDefault(0, 'single') . \"',\n";
        $str .= "                       `isNew`         =   '\" . \$this->model->getIsNew(0, 'single') . \"',\n";
        $str .= "                       `isDraft`       =   '\" . \$this->model->getIsDraft(0, 'single') . \"',\n";
        $str .= "                       `isUpdate`      =   '\" . \$this->model->getIsUpdate(0, 'single') . \"',\n";
        $str .= "                       `isDelete`      =   '\" . \$this->model->getIsDelete(0, 'single') . \"',\n";
        $str .= "                       `isActive`      =   '\" . \$this->model->getIsActive(0, 'single') . \"',\n";
        $str .= "                       `isApproved`    =   '\" . \$this->model->getIsApproved(0, 'single') . \"',\n";
        $str .= "                       `isReview`      =   '\" . \$this->model->getIsReview(0, 'single') . \"',\n";
        $str .= "                       `isPost`        =   '\" . \$this->model->getIsPost(0, 'single') . \"',\n";
        $str .= "                       `executeBy`     =   '\" . \$this->model->getExecuteBy() . \"',\n";
        $str .= "                       `executeTime`   =   \" . \$this->model->getExecuteTime() . \"\n";
        $str .= "               WHERE   `" . $data[0]['primaryKeyName'] . "`   =  '\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"'\";\n";
        $str .= "           } else if (\$this->getVendor() == self::MSSQL) {  \n";
        $str .= "               \$sql=\"\n";
        $str .= "               UPDATE  [" . $data[0]['tableName'] . "] \n";
        $str .= "               SET     [isDefault]     =   '\" . \$this->model->getIsDefault(0, 'single') . \"',\n";
        $str .= "                       [isNew]         =   '\" . \$this->model->getIsNew(0, 'single') . \"',\n";
        $str .= "                       [isDraft]       =   '\" . \$this->model->getIsDraft(0, 'single') . \"',\n";
        $str .= "                       [isUpdate]      =   '\" . \$this->model->getIsUpdate(0, 'single') . \"',\n";
        $str .= "                       [isDelete]      =   '\" . \$this->model->getIsDelete(0, 'single') . \"',\n";
        $str .= "                       [isActive]      =   '\" . \$this->model->getIsActive(0, 'single') . \"',\n";
        $str .= "                       [isApproved]    =   '\" . \$this->model->getIsApproved(0, 'single') . \"',\n";
        $str .= "                       [isReview]      =   '\" . \$this->model->getIsReview(0, 'single') . \"',\n";
        $str .= "                       [isPost]        =   '\" . \$this->model->getIsPost(0, 'single') . \"',\n";
        $str .= "                       [executeBy]     =   '\" . \$this->model->getExecuteBy() . \"',\n";
        $str .= "                       [executeTime]   =   \" . \$this->model->getExecuteTime() . \"\n";
        $str .= "               WHERE   [" . $data[0]['primaryKeyName'] . "]\t=  '\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"'\";\n";
        $str .= "           } else if (\$this->getVendor() == self::ORACLE) {  \n";
        $str .= "               \$sql=\"\n";
        $str .= "               UPDATE  " . strtoupper($data[0]['tableName']) . " \n";
        $str .= "               SET     ISDEFAULT       =   '\" . \$this->model->getIsDefault(0, 'single') . \"',\n";
        $str .= "                       ISNEW           =   '\" . \$this->model->getIsNew(0, 'single') . \"',\n";
        $str .= "                       ISDRAFT         =   '\" . \$this->model->getIsDraft(0, 'single') .\"',\n";
        $str .= "                       ISUPDATE        =   '\" . \$this->model->getIsUpdate(0, 'single') . \"',\n";
        $str .= "                       ISDELETE        =   '\" . \$this->model->getIsDelete(0, 'single') . \"',\n";
        $str .= "                       ISACTIVE        =   '\" . \$this->model->getIsActive(0, 'single') . \"',\n";
        $str .= "                       ISAPPROVED      =   '\" . \$this->model->getIsApproved(0, 'single') .\"',\n";
        $str .= "                       ISREVIEW        =   '\" .\$this->model->getIsReview(0, 'single') . \"',\n";
        $str .= "                       ISPOST          =   '\" . \$this->model->getIsPost(0, 'single') .\"',\n";
        $str .= "                       EXECUTEBY       =   '\" . \$this->model->getExecuteBy() .\"',\n";
        $str .= "                       EXECUTETIME     =   \" . \$this->model->getExecuteTime() . \"\n";
        $str .= "               WHERE   " . strtoupper($data[0]['primaryKeyName']) . "\t=  '\" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(0, 'single') . \"'\";\n";
        $str .= "           }  \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->update(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               \$this->q->rollback();\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       } \n";
        $str .= "       \$this->q->commit(); \n";
        $str .= "       \$end = microtime(true); \n";
        $str .= "       \$time = \$end - \$start; \n";
        $str .= "       echo json_encode( \n";
        $str .= "           array(  \"success\" => true, \n";
        $str .= "                   \"message\" => \$this->t['deleteRecordTextLabel'], \n";
        $str .= "                   \"time\"=>\$time)); \n";
        $str .= "       exit(); \n";
        $str .= "\t} \n";
        $str .= "     /** \n";
        $str .= "     * To Update flag Status \n";
        $str .= "     */ \n";
        $str .= "     function updateStatus() { \n";
        $str .= "           header('Content-Type:application/json; charset=utf-8'); \n";
        $str .= "\t\t\$start = microtime(true); \n";
        $str .= "           \$sqlLooping=null;\n";
        $str .= "\t\tif (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "               \$sql = \"SET NAMES utf8\"; \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->fast(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "\t\t} \n";
        $str .= "\t\t\$this->q->start(); \n";
        $str .= "\t\t\$loop = intval(\$this->model->getTotal()); \n";
        $str .= "       \$sql=null;\n";
        $str .= "\t\tif (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "               \$sql = \" \n";
        $str .= "               UPDATE `" . strtolower($data[0]['tableName']) . "` \n";
        $str .= "               SET\t   `executeBy`\t\t=\t'\".\$this->model->getExecuteBy().\"',\n";
        $str .= "\t\t\t\t\t   `executeTime`\t=\t\".\$this->model->getExecuteTime().\",\";\n";
        $str .= "\t\t} else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "               \$sql = \" \n";
        $str .= "               UPDATE \t[" . $data[0]['tableName'] . "] \n";
        $str .= "               SET\t   [executeBy]\t\t=\t'\".\$this->model->getExecuteBy().\"',\n";
        $str .= "\t\t\t\t\t   [executeTime]\t=\t\".\$this->model->getExecuteTime().\",\";\n";
        $str .= "\t\t} else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "               \$sql = \" \n";
        $str .= "               UPDATE " . strtoupper($data[0]['tableName']) . " \n";
        $str .= "               SET\t   EXECUTEBY\t\t=\t'\".\$this->model->getExecuteBy().\"',\n";
        $str .= "\t\t\t\t\t   EXECUTETIME\t\t=\t\".\$this->model->getExecuteTime().\",\";\n";
        $str .= "\t\t}  else { \n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
        $str .= "               exit(); \n";
        $str .= "\t\t} \n";
        // starting updating the flag
        $str .= "       if(\$_SESSION) { \n";
        $str .= "           if(\$_SESSION['isAdmin']==1) { \n";
        $systemFlag = array('isDefault', 'isDraft', 'isNew', 'isActive', 'isUpdate', 'isDelete', 'isReview', 'isPost', 'isApproved');
        foreach ($systemFlag as $systemCheck) {
            $str .= "                 if (\$this->model->get" . ucfirst($systemCheck) . "Total() > 0) {\n";
            $str .= "                     if (\$this->getVendor() == self::MYSQL) {\n";
            $str .= "                         \$sqlLooping .= \" `" . $systemCheck . "` = CASE `" . strtolower($data[0]['tableName']) . "`.`\".\$this->model->getPrimaryKeyName() . \"`\"; \n";
            $str .= "                     } else if (\$this->getVendor() == self::MSSQL) {\n";
            $str .= "                         \$sqlLooping .= \"  [" . $systemCheck . "] = CASE [" . $data[0]['tableName'] . "].[\" . \$this->model->getPrimaryKeyName() . \"]\"; \n";
            $str .= "                     } else if (\$this->getVendor() == self::ORACLE) {\n";
            $str .= "                         \$sqlLooping .= \" " . strtoupper($systemCheck) . " = CASE " . strtoupper($data[0]['tableName']) . ".\".strtoupper(\$this->model->getPrimaryKeyName()) . \" \"; \n";
            $str .= "                     } else { \n";
            $str .= "                         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
            $str .= "                         exit();\n";
            $str .= "                     }\n";
            $str .= "                     for (\$i = 0; \$i < \$loop; \$i++) {\n";
            $str .= "                         \$sqlLooping .= \"\n";
            $str .= "                         WHEN \" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(\$i, 'array') . \"\n";
            $str .= "                         THEN \" . \$this->model->get" . ucfirst($systemCheck) . "(\$i, 'array') . \"\";\n";
            $str .= "                     }\n";
            $str .= "                     if (\$this->getVendor() == self::MYSQL) {\n";
            $str .= "                         \$sqlLooping .= \" ELSE `" . $systemCheck . "` END,\";\n";
            $str .= "                     } else if (\$this->getVendor() == self::MSSQL) {\n";
            $str .= "                         \$sqlLooping .= \" ELSE [" . $systemCheck . "] END,\";\n";
            $str .= "                     } else if (\$this->getVendor() == self::ORACLE) {\n";
            $str .= "                         \$sqlLooping .= \" ELSE " . strtoupper($systemCheck) . " END,\";\n";
            $str .= "                     }\n";
            $str .= "\t\t\t} \n";
        }
        $str .= "             } else { \n";
        $str .= "                 if (\$this->model->getIsDeleteTotal() > 0) {\n";
        $str .= "                     if (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "                         \$sqlLooping .=\" `isDelete` = CASE `" . strtolower($data[0]['tableName']) . "`.`\" . \$this->model->getPrimaryKeyName() . \"`\"; \n";
        $str .= "                     } else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "                         \$sqlLooping .= \"  [isDelete] = CASE [" . strtoupper($data[0]['tableName']) . "].[\" . \$this->model->getPrimaryKeyName() . \"]\"; \n";
        $str .= "                     } else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "                         \$sqlLooping .= \" ISDELETE = CASE " . strtoupper($data[0]['tableName']) . ".\".strtoupper(\$this->model->getPrimaryKeyName()) . \" \"; \n";
        $str .= "                     }else { \n";
        $str .= "                         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
        $str .= "                         exit();\n";
        $str .= "                     }\n";
        $str .= "                     for (\$i = 0; \$i < \$loop; \$i++) {\n";
        $str .= "                         \$sqlLooping .= \"\n";
        $str .= "                         WHEN \" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(\$i, 'array') . \"\n";
        $str .= "                         THEN \" . \$this->model->getIsDelete(\$i, 'array') . \" \";\n";
        $str .= "                     }\n";
        $str .= "                     if (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "                         \$sqlLooping .= \" ELSE `isDelete` END,\";\n";
        $str .= "                     } else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "                         \$sqlLooping .= \" ELSE [isDelete] END,\";\n";
        $str .= "                     } else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "                         \$sqlLooping .= \" ELSE ISDELETE END,\";\n";
        $str .= "                     }\n";
        $str .= "                     if (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "                         \$sqlLooping .=\" `isActive` = CASE `" . strtolower($data[0]['tableName']) . "`.`\" . \$this->model->getPrimaryKeyName() . \"`\"; \n";
        $str .= "                     } else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "                         \$sqlLooping .= \"  [isActive] = CASE [" . strtoupper($data[0]['tableName']) . "].[\" . \$this->model->getPrimaryKeyName() . \"]\"; \n";
        $str .= "                     } else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "                         \$sqlLooping .= \" ISACTIVE = CASE " . strtoupper($data[0]['tableName']) . ".\".strtoupper(\$this->model->getPrimaryKeyName()) . \" \"; \n";
        $str .= "                     }else { \n";
        $str .= "                         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
        $str .= "                         exit();\n";
        $str .= "                     }\n";
        $str .= "                     for (\$i = 0; \$i < \$loop; \$i++) {\n";
        $str .= "                         if(\$this->model->getIsDelete(\$i, 'array') ==0 || \$this->model->getIsDelete(\$i, 'array')==false) {\n";
        $str .= "                         \t\$isActive=1;\n";
        $str .= "                         } else {\n";
        $str .= "                         \t\$isActive=0;\n";
        $str .= "                         } \n";
        $str .= "                         \$sqlLooping .= \"\n";
        $str .= "                         WHEN \" . \$this->model->get" . ucfirst($data[0]['primaryKeyName']) . "(\$i, 'array') . \"\n";
        $str .= "                         THEN \" . \$isActive . \" \";\n";
        $str .= "                     }\n";
        $str .= "                     if (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "                         \$sqlLooping .= \" ELSE `isDelete` END,\";\n";
        $str .= "                     } else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "                         \$sqlLooping .= \" ELSE [isDelete] END,\";\n";
        $str .= "                     } else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "                         \$sqlLooping .= \" ELSE ISDELETE END,\";\n";
        $str .= "                     }\n";
        $str .= "\t\t\t\t} \n";
        $str .= "               }\n";
        $str .= "           }\n";
        $str .= "           \$sql .= substr(\$sqlLooping, 0, - 1);\n";
        $str .= "\t\tif (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "               \$sql .= \" \n";
        $str .= "               WHERE `\" . \$this->model->getPrimaryKeyName() . \"` IN (\" . \$this->model->getPrimaryKeyAll() . \")\"; \n";
        $str .= "\t\t} else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "               \$sql .= \" \n";
        $str .= "               WHERE [\" . \$this->model->getPrimaryKeyName() . \"] IN (\" . \$this->model->getPrimaryKeyAll() . \")\"; \n";
        $str .= "\t\t} else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "               \$sql .= \" \n";
        $str .= "               WHERE \" . strtoupper(\$this->model->getPrimaryKeyName()) . \"  IN (\" . \$this->model->getPrimaryKeyAll() . \")\"; \n";
        $str .= "\t\t}  else { \n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel'])); \n";
        $str .= "               exit(); \n";
        $str .= "\t\t} \n";
        $str .= "       \$this->q->setPrimaryKeyAll(\$this->model->getPrimaryKeyAll());\n";
        $str .= "       \$this->q->setMultiId(1);\n";
        $str .= "       try {\n";
        $str .= "           \$this->q->update(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           \$this->q->rollback();\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        $str .= "\t\t\$this->q->commit(); \n";
        $str .= "\t\tif (\$this->getIsAdmin()) { \n";
        $str .= "               \$message = \$this->t['updateRecordTextLabel']; \n";
        $str .= "\t\t} else {\n";
        $str .= "               \$message = \$this->t['deleteRecordTextLabel']; \n";
        $str .= "\t\t} \n";
        $str .= "\t\t\$end = microtime(true); \n";
        $str .= "\t\t\$time = \$end - \$start; \n";
        $str .= "\t\techo json_encode( \n";
        $str .= "               array(  \"success\" =>  true, \n";
        $str .= "                       \"message\" =>  \$message, \n";
        $str .= "                       \"time\"    =>  \$time) \n";
        $str .= "           ); \n";
        $str .= "       exit(); \n";
        $str .= "\t} \n";
        $str .= "\t/** \n";
        $str .= "\t * To check if a key duplicate or not \n";
        $str .= "\t */ \n";
        $str .= "\tfunction duplicate() {\n";
        $str .= "       header('Content-Type:application/json; charset=utf-8'); \n";
        $str .= "       \$start = microtime(true);\n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \"SET NAMES utf8\"; \n";
        $str .= "           try {\n";
        $str .= "               \$this->q->fast(\$sql);\n";
        $str .= "           } catch (\\Exception \$e) {\n";
        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "               exit();\n";
        $str .= "           }\n";
        $str .= "       } \n";
        $str .= "       \$sql=null;\n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT `\".strtolower(\$this->model->getTableName()).\"Code` \n";
        $str .= "           FROM    `\".strtolower(\$this->model->getTableName()).\"` \n";
        $str .= "           WHERE  `\".strtolower(\$this->model->getTableName()).\"Code` \t= \t'\" . \$this->model->get" . ucfirst($data[0]['tableName']) . "Code() . \"' \n";
        $str .= "           AND     `isActive`  =   1\n";
        $str .= "           AND     `companyId` =   '\".\$this->getCompanyId().\"'\"; \n";
        $str .= "       } else if (\$this->getVendor() == self::MSSQL) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "           SELECT  [\".(\$this->model->getTableName().\"Code] \n";
        $str .= "           FROM    [\".(\$this->model->getTableName()).\"] \n";
        $str .= "           WHERE   [\".(\$this->model->getTableName()).\"Code] = \t'\" . \$this->model->get" . ucfirst($data[0]['tableName']) . "Code() . \"' \n";
        $str .= "           AND     [isActive]  =   1 \n";
        $str .= "           AND     [companyId] =\t'\".\$this->getCompanyId().\"'\"; \n";
        $str .= "       } else if (\$this->getVendor() == self::ORACLE) { \n";
        $str .= "           \$sql = \" \n";
        $str .= "               SELECT  \".strtoupper(\$this->model->getTableName()).\"Code AS \\\"" . $data[0]['tableName'] . "Code\\\" \n";
        $str .= "               FROM     \".strtoupper(\$this->model->getTableName()).\" \n";
        $str .= "               WHERE  \".strtoupper(\$this->model->getTableName()).\"CODE\t= \t'\" . \$this->model->get" . ucfirst($data[0]['tableName']) . "Code() . \"' \n";
        $str .= "               AND     ISACTIVE    =   1 \n";
        $str .= "               AND     COMPANYID   =   '\".\$this->getCompanyId().\"'\"; \n";
        $str .= "       } \n";
        $str .= "       try {\n";
        $str .= "           \$this->q->read(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        $str .= "       \$total = intval(\$this->q->numberRows()); \n";
        $str .= "       if (\$total > 0) { \n";
        $str .= "           \$row = \$this->q->fetchArray(); \n";
        $str .= "           \$end = microtime(true); \n";
        $str .= "           \$time = \$end - \$start; \n";
        $str .= "           echo json_encode(\n";
        $str .= "               array(  \"success\" =>true, \n";
        $str .= "                       \"total\" => \$total, \n";
        $str .= "                       \"message\" => \$this->t['duplicateMessageLabel'],  \n";
        $str .= "                       \"referenceNo\" => \$row ['referenceNo'], \n";
        $str .= "                       \"time\"=>\$time)); \n";
        $str .= "           exit(); \n";
        $str .= "       } else { \n";
        $str .= "           \$end = microtime(true); \n";
        $str .= "           \$time = \$end - \$start; \n";
        $str .= "           echo json_encode( \n";
        $str .= "               array(  \"success\" => true, \n";
        $str .= "                       \"total\" => \$total,  \n";
        $str .= "                       \"message\" => \$this->t['duplicateNotMessageLabel'], \n";
        $str .= "                       \"time\"=>\$time)); \n";
        $str .= "           exit(); \n";
        $str .= "       } \n";
        $str .= "\t} \n";
        $str .= "   /**\n";
        $str .= "   * First Record\n";
        $str .= "   * @param string \$value . This return data type. When call by normal read.Value=='value'.When requested by ajax request button Value=='json'\n";
        $str .= "   * @return int\n";
        $str .= "   * @throws \\Exception\n";
        $str .= "   */\n";
        $str .= "   function firstRecord(\$value) {\n";
        $str .= "       return \$this->recordSet->firstRecord(\$value);\n";
        $str .= "   }\n";
        $str .= "   /**\n";
        $str .= "   * Next Record\n";
        $str .= "   * @param string \$value . This return data type. When call by normal read.Value=='value'.When requested by ajax request button Value=='json'\n";
        $str .= "   * @param int \$primaryKeyValue Current  Primary Key Value\n";
        $str .= "   * @return int\n";
        $str .= "   * @throws \\Exception\n";
        $str .= "   */\n";
        $str .= "   function nextRecord(\$value, \$primaryKeyValue) {\n";
        $str .= "       return \$this->recordSet->nextRecord(\$value, \$primaryKeyValue);\n";
        $str .= "   }\n";
        $str .= "   /**\n";
        $str .= "   * Previous Record\n";
        $str .= "   * @param string \$value . This return data type. When call by normal read.Value=='value'.When requested by ajax request button Value=='json'\n";
        $str .= "   * @param int \$primaryKeyValue\n";
        $str .= "   * @return int\n";
        $str .= "   * @throws \\Exception\n";
        $str .= "   */\n";
        $str .= "   function previousRecord(\$value, \$primaryKeyValue) {\n";
        $str .= "       return \$this->recordSet->previousRecord(\$value, \$primaryKeyValue);\n";
        $str .= "   }\n";
        $str .= "   /**\n";
        $str .= "   * Last Record\n";
        $str .= "   * @param string \$value . This return data type. When call by normal read.Value=='value'.When requested by ajax request button Value=='json'\n";
        $str .= "   * @return int\n";
        $str .= "   * @throws \\Exception\n";
        $str .= "   */\n";
        $str .= "   function lastRecord(\$value) {\n";
        $str .= "       return \$this->recordSet->lastRecord(\$value);\n";
        $str .= "   }\n";
        // reset service
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                if ($data[$i]['columnName'] != 'companyId') {
                    $service = 1;
                    break;
                }
            }
        }
        if ($service == 1) {
            $str .= "  /**\n";
            $str .= "   * Set Service\n";
            $str .= "   * @param string \$service . Reset service either option,html,table\n";
            $str .= "   * @return mixed\n";
            $str .= "   */\n";
            $str .= "   function setService(\$service) {\n";
            $str .= "       return \$this->service->setServiceOutput(\$service);\n";
            $str .= "   }\n";
        }
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                if ($data[$i]['columnName'] != 'companyId') {
                    // we only can assumed it was the same package and module otherwise
                    // manual change
                    $str .= "\t/** \n";
                    $str .= "\t * Return  " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " \n";
                    $str .= "    * @return null|string\n";
                    $str .= "\t */\n";
                    $str .= "\tpublic function get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "() { \n";
                    $str .= "       \$this->service->setServiceOutput(\$this->getServiceOutput());\n";
                    $str .= "\t\treturn \$this->service->get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "();  \n";
                    $str .= "\t}\n";
                }
            }
        }
        $str .= "  /**\n";
        $str .= "   * Return Total Record Of The  \n";
        $str .= "   * return int Total Record\n";
        $str .= "   */\n";
        $str .= " private function  getTotalRecord() {\n";
        $str .= "   \$sql=null;\n";
        $str .= "   \$total=0;\n";
        $str .= "     if(\$this->getVendor()==self::MYSQL) { \n";
        $str .= "         \$sql=\"\n";
        $str .= "         SELECT  count(*) AS `total` \n";
        $str .= "         FROM    `\".strtolower(\$this->model->getTableName()).\"`\n";
        $str .= "         WHERE   `isActive`=1\n";
        $str .= "         AND     `companyId`=\" . \$this->getCompanyId() . \" \";\n";
        $str .= "     } else if (\$this->getVendor()==self::MSSQL){ \n";
        $str .= "         \$sql=\"\n";
        $str .= "         SELECT    COUNT(*) AS total \n";
        $str .= "         FROM      [\".(\$this->model->getTableName()).\"]\n";
        $str .= "         WHERE     [isActive]  =   1\n";
        $str .= "         AND       [companyId] =   \" . \$this->getCompanyId(). \" \";\n";
        $str .= "     } else if (\$this->getVendor()==self::ORACLE){ \n";
        $str .= "         \$sql=\"\n";
        $str .= "         SELECT    COUNT(*)    AS  \\\"total\\\" \n";
        $str .= "         FROM      \".strtoupper(\$this->model->getTableName()).\"\n";
        $str .= "         WHERE     ISACTIVE    =   1\n";
        $str .= "         AND       COMPANYID   =   \" . \$this->getCompanyId() . \" \";\n";
        $str .= "     }\n";
        $str .= "       try {\n";
        $str .= "           \$result= \$this->q->fast(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        $str .= "         if(\$result) {\n";
        $str .= "             if(\$this->q->numberRows(\$result) > 0 ) {\n";
        $str .= "             \$row = \$this->q->fetchArray(\$result); \n";
        $str .= "                 \$total =\$row['total'];\n";
        $str .= "             }\n";
        $str .= "         } ";
        $str .= "         return \$total;\n";
        $str .= "   }\n";
        $str .= "\t/** \n";
        $str .= "\t * Reporting\n";
        $str .= "\t * @see config::excel() \n";
        $str .= "\t */\n";
        $str .= "\tfunction excel() { \n";
        $str .= "       header('Content-Type:application/json; charset=utf-8'); \n";
        $str .= "       \$start = microtime(true); \n";
        $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
        $str .= "           \$sql = \"SET NAMES utf8\"; \n";
        $str .= "           \$this->q->fast(\$sql); \n";
        $str .= "       } \n";
        $str .= "       if (\$_SESSION ['start'] == 0) { \n";
        $str .= "           \$sql = str_replace(\$_SESSION ['start'] . \",\" . \$_SESSION ['limit'], \"\", str_replace(\"LIMIT\", \"\", \$_SESSION ['sql'])); \n";
        $str .= "       } else { \n";
        $str .= "           \$sql = \$_SESSION ['sql']; \n";
        $str .= "       } \n";
        $str .= "       try {\n";
        $str .= "           \$this->q->read(\$sql);\n";
        $str .= "       } catch (\\Exception \$e) {\n";
        $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
        $str .= "           exit();\n";
        $str .= "       }\n";
        // basic properties of the report
        // initialize dummy value...
        $str .= "       \$username =null; \n";
        $str .= "       if(isset(\$_SESSION['username'])) { \n";
        $str .= "           \$username=\$_SESSION['username']; \n";
        $str .= "       } else {  \n";
        $str .= "           \$username='******'; \n";
        $str .= "       } \n";
        // this optional also
        // $str .= "\$locale = null;\n";
        // $str .= "\$locale = 'ru';\n";
        // $str .= "\$validLocale = \\PHPExcel_Settings::setLocale(\$locale);\n";
        // $str .= "if (!\$validLocale) { \n";
        // $str .= "	echo \"Unable to set locale to \".\$locale.\" - reverting to en_us<br />\n\"; \n";
        //  $str .= "}\n";
        $str .= "       \$this->excel->getProperties() \n";
        $str .= "                   ->setCreator(\$username) \n";
        $str .= "                   ->setLastModifiedBy(\$username) \n";
        $str .= "                   ->setTitle(\$this->getReportTitle()) \n";
        $str .= "                   ->setSubject('" . $data[0]['tableName'] . "')\n";
        $str .= "                   ->setDescription('Generated by PhpExcel an Idcms Generator') \n";
        $str .= "                   ->setKeywords('office 2007 openxml php') \n";
        $str .= "                   ->setCategory('" . $data[0]['package'] . "/" . $data[0]['module'] . "'); \n";
        $str .= "        \$this->excel->setActiveSheetIndex(0); \n";
        $str .= "       // check file exist or not and return response \n";
        $str .= "       \$styleThinBlackBorderOutline = array('borders' => array('inside' => array('style' => \\PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => '000000')), 'outline' => array('style' => \\PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => '000000')))); \n";
        $str .= "       // header all using  3 line  starting b \n";
        // set range
        // first need to knew what is the last character.
        // initialize dummy value
        $characterArray = array();
        foreach (range('A', 'Z') as $character) {
            $characterArray[] = $character;
        }
        $c = 0;
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation' && $data[$i]['columnName'] != 'isReconciled') {
                    $c++;
                }
            }
        }
        // echo "last character is ".$lastCharacter."\n";
        $characterStart = 'B';
        $characterEnd = $characterArray[$c];
        foreach (range($characterStart, $characterEnd) as $character) {
            $str .= "        \$this->excel->getActiveSheet()->getColumnDimension('" . $character . "')->setAutoSize(TRUE); \n";
        }
        $str .= "        \$this->excel->getActiveSheet()->setCellValue('B2',\$this->getReportTitle()); \n";
        $str .= "        \$this->excel->getActiveSheet()->setCellValue('" . $characterEnd . "2', ''); \n";
        $str .= "        \$this->excel->getActiveSheet()->mergeCells('B2:" . $characterEnd . "2'); \n";
        // looping field
        $str .= "        \$this->excel->getActiveSheet()->setCellValue('B3', 'No.'); \n";
        $n = 0;
        for ($i = 0; $i < $total; $i++) {
            if ($i >= 1) {
                if ($data[$i]['columnName'] != 'companyId' && $data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation' && $data[$i]['columnName'] != 'isReconciled') {
                    $n++;
                    $str .= "        \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$n + 1] . "3', \$this->translate['" . $data[$i]['columnName'] . "Label']); \n";
                }
            }
        }
        $str .= "\t\t// \n";
        $str .= "        \$loopRow = 4; \n";
        $str .= "        \$i = 0; \n";
        $str .= "        \\PHPExcel_Cell::setValueBinder( new \\PHPExcel_Cell_AdvancedValueBinder() );\n";
        $str .= "        \$lastRow=null;\n";
        $str .= "        while ((\$row = \$this->q->fetchAssoc()) == TRUE) { \n";
        $str .= "           //\techo print_r(\$row); \n";
        $str .= "           \$this->excel->getActiveSheet()->setCellValue('B' . \$loopRow, ++\$i); \n";
        // looping field
        $z = 0;
        for ($i = 0; $i < $total; $i++) {
            if ($i > 1) {
                if ($data[$i]['columnName'] == 'executeBy') {
                    $z++;
                    $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,  strip_tags( \$row ['staffName'])); \n";
                } else {
                    if ($data[$i]['columnName'] == 'executeTime') {
                        $z++;
                        $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,   strip_tags(\$row ['" . $data[$i]['columnName'] . "'])); \n";
                        $str .= "           \$this->excel->getActiveSheet()->getStyle()->getNumberFormat('" . $characterArray[$z + 1] . "' . \$loopRow)->setFormatCode(\\PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH);  \n";
                    } else {
                        if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'isSlice' && $data[$i]['columnName'] != 'isConsolidation' && $data[$i]['columnName'] != 'isReconciled') {
                            $z++;
                            switch ($data[$i]['field']) {
                                case 'date':
                                case 'datetime':
                                    $str .= "           \$this->excel->getActiveSheet()->getStyle()->getNumberFormat('" . $characterArray[$z + 1] . "' . \$loopRow)->setFormatCode(\\PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH);  \n";
                                    $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,   strip_tags(\$row ['" . $data[$i]['columnName'] . "'])); \n";
                                    break;
                                case 'int':
                                    if ($data[$i]['Key'] == 'MUL') {
                                        if ($data[$i]['columnName'] != 'companyId') {
                                            //exception for some cases
                                            if ($data[$i]['columnName'] == 'businessPartnerId') {
                                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Company";
                                            } else {
                                                if ($data[$i]['columnName'] == 'employeeId') {
                                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "FirstName";
                                                } else {
                                                    if ($data[$i]['columnName'] == 'staffId') {
                                                        $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                                    } else {
                                                        if ($data[$i]['columnName'] == 'chartOfAccountId') {
                                                            $field = str_replace("Id", "", $data[$i]['columnName']) . "Title";
                                                        } else {
                                                            if ($data[$i]['columnName'] == 'assetId') {
                                                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                                            } else {
                                                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Description";
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,   strip_tags(\$row ['" . $field . "'])); \n";
                                        }
                                    } else {
                                        $str .= "           \$this->excel->getActiveSheet()->getStyle()->getNumberFormat('" . $characterArray[$z + 1] . "' . \$loopRow)->setFormatCode(\\PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);  \n";
                                        $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,   strip_tags(\$row ['" . $data[$i]['columnName'] . "'])); \n";
                                    }
                                    break;
                                case 'double':
                                case 'float':
                                    $str .= "           \$this->excel->getActiveSheet()->getStyle()->getNumberFormat('" . $characterArray[$z + 1] . "' . \$loopRow)->setFormatCode(\\PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);  \n";
                                    $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,   strip_tags(\$row ['" . $data[$i]['columnName'] . "'])); \n";
                                    break;
                                default:
                                    $str .= "           \$this->excel->getActiveSheet()->setCellValue('" . $characterArray[$z + 1] . "' . \$loopRow,   strip_tags(\$row ['" . $data[$i]['columnName'] . "'])); \n";
                            }
                        }
                    }
                }
            }
        }
        $str .= "           \$loopRow++; \n";
        $str .= "           \$lastRow = '" . $characterEnd . "' . \$loopRow;\n";
        $str .= "        } \n";
        $str .= "        \$from = 'B2'; \n";
        $str .= "        \$to = \$lastRow; \n";
        $str .= "        \$formula = \$from . \":\" . \$to;\n";
        $str .= "        \$this->excel->getActiveSheet()->getStyle(\$formula)->applyFromArray(\$styleThinBlackBorderOutline);\n";
        $str .= "        \$extension=null; ";
        $str .= "        \$folder=null; ";
        $str .= "        switch(\$this->getReportMode()) { \n";
        $str .= "           case 'excel':\n";
        $str .= "               //\t\$objWriter = \\PHPExcel_IOFactory::createWriter(\$this->excel, 'Excel2007');\n";
        $str .= "               //optional lock.on request only\n";
        $str .= "               // \$objPHPExcel->getSecurity()->setLockWindows(true);\n";
        $str .= "               // \$objPHPExcel->getSecurity()->setLockStructure(true);\n";
        $str .= "               // \$objPHPExcel->getSecurity()->setWorkbookPassword('PHPExcel');\n";
        $str .= "               \$objWriter = new \\PHPExcel_Writer_Excel2007(\$this->excel); \n";
        $str .= "               \$extension='.xlsx';\n";
        $str .= "               \$folder='excel';\n";
        $str .= "               \$filename = \"" . $data[0]['tableName'] . "\" . rand(0, 10000000) . \$extension;\n";
        $str .= "               \$path = \$this->getFakeDocumentRoot() . \"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/document/\".\$folder.\"/\" . \$filename;\n";
        $str .= "               \$this->documentTrail->createTrail(\$this->getLeafId(), \$path,\$filename);\n";
        $str .= "               \$objWriter->save(\$path);\n";
        $str .= "               \$file = fopen(\$path, 'r');\n";
        $str .= "               if (\$file) { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                       array(  \"success\" => true, \n";
        $str .= "                               \"message\" => \$this->t['fileGenerateMessageLabel'], \n";
        $str .= "                               \"filename\" => \$filename,\n";
        $str .= "                               \"folder\" => \$folder,\n";
        $str .= "                               \"time\"=>\$time));\n";
        $str .= "\t\t\t            exit(); \n";
        $str .= "               } else { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                   array(\t\"success\" => false,\n";
        $str .= "                           \"message\" => \$this->t['fileNotGenerateMessageLabel'],\n";
        $str .= "                           \"time\"=>\$time));\n";
        $str .= "\t\t\t        exit(); \n";
        $str .= "               } \n";
        $str .= "           break;\n";
        $str .= "           case 'excel5':\n";
        $str .= "               \$objWriter = new \\PHPExcel_Writer_Excel5(\$this->excel); \n";
        $str .= "               \$extension='.xls';\n";
        $str .= "               \$folder='excel';\n";
        $str .= "               \$filename = \"" . $data[0]['tableName'] . "\" . rand(0, 10000000) . \$extension;\n";
        $str .= "               \$path = \$this->getFakeDocumentRoot() . \"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/document/\".\$folder.\"/\" . \$filename;\n";
        $str .= "               \$this->documentTrail->createTrail(\$this->getLeafId(), \$path,\$filename);\n";
        $str .= "               \$objWriter->save(\$path);\n";
        $str .= "               \$file = fopen(\$path, 'r');\n";
        $str .= "               if (\$file) { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                       array(  \"success\" => true, \n";
        $str .= "                               \"message\" => \$this->t['fileGenerateMessageLabel'], \n";
        $str .= "                               \"filename\" => \$filename,\n";
        $str .= "                               \"folder\" => \$folder,\n";
        $str .= "                               \"time\"=>\$time));\n";
        $str .= "\t\t\t        exit(); \n";
        $str .= "               } else { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                       array(\t\"success\" => false,\n";
        $str .= "                               \"message\" => \$this->t['fileNotGenerateMessageLabel'],\n";
        $str .= "                               \"time\"=>\$time));\n";
        $str .= "\t\t\t            exit(); \n";
        $str .= "               } \n";
        $str .= "           break;\n";
        $str .= "           case 'pdf':\n";
        // denied as inconsistent driver
        /*
         $str .= "               \$objWriter = new \\PHPExcel_Writer_PDF(\$this->excel); \n";
         $str .= "               \$objWriter->writeAllSheets();\n"; // write all sheet
         $str .= "               \$extension='.pdf';\n";
         // optional one page \$objWriter->setSheetIndex(0);
         $str .= "               \$folder='pdf';\n";
         $str .= "               \$filename = \"" . $data [0] ['tableName'] . "\" . rand(0, 10000000) . \$extension;\n";
         $str .= "               \$path = \$this->getFakeDocumentRoot() . \"v3/" . $data [0] ['package'] . "/" . $data [0] ['module'] . "/document/\".\$folder.\"/\" . \$filename;\n";
         // $str.=" \$this->documentTrail->create_trail(\$this->leafId, \$path,
         // \$filename);\n";
         $str .= "               \$objWriter->save(\$path);\n";
         $str .= "               \$file = fopen(\$path, 'r');\n";
         $str .= "               if (\$file) { \n";
         $str .= "                   \$end = microtime(true);\n";
         $str .= "                   \$time = \$end - \$start;\n";
         $str .= "                   echo json_encode(\n";
         $str .= "                       array(  \"success\" => true, \n";
         $str .= "                               \"message\" => \$this->t['fileGenerateMessageLabel'], \n";
         $str .= "                               \"filename\" => \$filename,\n";
         $str .= "                               \"folder\" => \$folder,\n";
         $str .= "                               \"time\"=>\$time));\n";
         $str .= "			        exit(); \n";
         $str .= "               } else { \n";
         $str .= "                   \$end = microtime(true);\n";
         $str .= "                   \$time = \$end - \$start;\n";
         $str .= "                   echo json_encode(\n";
         $str .= "                       array(	\"success\" => false,\n";
         $str .= "                               \"message\" => \$this->t['fileNotGenerateMessageLabel'],\n";
         $str .= "                                \"time\"=>\$time));\n";
         $str .= "			            exit(); \n";
         $str .= "               } \n";
        */
        $str .= "           break;\n";
        $str .= "           case 'html':\n";
        $str .= "               \$objWriter = new \\PHPExcel_Writer_HTML(\$this->excel); \n";
        $str .= "               // \$objWriter->setUseBOM(true); \n";
        $str .= "               \$extension='.html';\n";
        // if requre calculation put below
        $str .= "               //\$objWriter->setPreCalculateFormulas(false); //calculation off \n";
        $str .= "               \$folder='html';\n";
        $str .= "               \$filename = \"" . $data[0]['tableName'] . "\" . rand(0, 10000000) . \$extension;\n";
        $str .= "               \$path = \$this->getFakeDocumentRoot() . \"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/document/\".\$folder.\"/\" . \$filename;\n";
        $str .= "               \$this->documentTrail->createTrail(\$this->getLeafId(), \$path,\$filename);\n";
        $str .= "               \$objWriter->save(\$path);\n";
        $str .= "               \$file = fopen(\$path, 'r');\n";
        $str .= "               if (\$file) { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                    array( \"success\" => true, \n";
        $str .= "                            \"message\" => \$this->t['fileGenerateMessageLabel'], \n";
        $str .= "                           \"filename\" => \$filename,\n";
        $str .= "                           \"folder\" => \$folder,\n";
        $str .= "                           \"time\"=>\$time));\n";
        $str .= "\t\t\t        exit(); \n";
        $str .= "               } else { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                       array(\t\"success\" => false,\n";
        $str .= "                               \"message\" => \$this->t['fileNotGenerateMessageLabel'],\n";
        $str .= "                               \"time\"=>\$time));\n";
        $str .= "\t\t\t            exit(); \n";
        $str .= "               } \n";
        $str .= "           break;\n";
        $str .= "           case 'csv': \n";
        $str .= "               \$objWriter = new \\PHPExcel_Writer_CSV(\$this->excel); \n";
        $str .= "               // \$objWriter->setUseBOM(true); \n";
        $str .= "               // \$objWriter->setPreCalculateFormulas(false); //calculation off \n";
        $str .= "               \$extension='.csv';\n";
        $str .= "               \$folder='excel';\n";
        $str .= "               \$filename = \"" . $data[0]['tableName'] . "\" . rand(0, 10000000) . \$extension;\n";
        $str .= "               \$path = \$this->getFakeDocumentRoot() . \"v3/" . $data[0]['package'] . "/" . $data[0]['module'] . "/document/\".\$folder.\"/\" . \$filename;\n";
        $str .= "               \$this->documentTrail->createTrail(\$this->getLeafId(), \$path,\$filename);\n";
        $str .= "               \$objWriter->save(\$path);\n";
        $str .= "               \$file = fopen(\$path, 'r');\n";
        $str .= "               if (\$file) { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                       array(  \"success\" => true, \n";
        $str .= "                               \"message\" => \$this->t['fileGenerateMessageLabel'], \n";
        $str .= "                               \"filename\" => \$filename,\n";
        $str .= "                               \"folder\" => \$folder,\n";
        $str .= "                               \"time\"=>\$time));\n";
        $str .= "\t\t\t        exit(); \n";
        $str .= "               } else { \n";
        $str .= "                   \$end = microtime(true);\n";
        $str .= "                   \$time = \$end - \$start;\n";
        $str .= "                   echo json_encode(\n";
        $str .= "                       array(\t\"success\" => false,\n";
        $str .= "                               \"message\" => \$this->t['fileNotGenerateMessageLabel'],\n";
        $str .= "                               \"time\"=>\$time));\n";
        $str .= "\t\t\t                exit(); \n";
        $str .= "               } \n";
        $str .= "           break;\n";
        $str .= "       } \n";
        $str .= "     } \n";
        $str .= "} \n";
        $str .= "if (isset(\$_POST ['method'])) { \n";
        $str .= "    if(isset(\$_POST['output'])) {  \n";
        $str .= "   \$" . $data[0]['tableName'] . "Object = new " . ucfirst($data[0]['tableName']) . "Class (); \n";
        $str .= "\tif(\$_POST['securityToken'] != \$" . $data[0]['tableName'] . "Object->getSecurityToken()) {\n";
        $str .= "\t\theader('Content-Type:application/json; charset=utf-8');\n";
        $str .= "\t\techo json_encode(array(\"success\"=>false,\"message\"=>\"Something wrong with the system.Hola hackers\"));\n";
        $str .= "\t\texit();\n";
        $str .= "\t}\n";
        $str .= "\t/* \n";
        $str .= "\t *  Load the dynamic value \n";
        $str .= "\t */ \n";
        $str .= "\tif (isset(\$_POST ['leafId'])) {\n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->setLeafId(\$_POST ['leafId']); \n";
        $str .= "\t} \n";
        $str .= "\tif (isset(\$_POST ['offset'])) {\n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->setStart(\$_POST ['offset']); \n";
        $str .= "\t} \n";
        $str .= "\tif (isset(\$_POST ['limit'])) {\n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->setLimit(\$_POST ['limit']); \n";
        $str .= "\t} \n";
        $str .= "\t\$" . $data[0]['tableName'] . "Object ->setPageOutput(\$_POST['output']);  \n";
        $str .= "\t\$" . $data[0]['tableName'] . "Object->execute(); \n";
        $str .= "\t/* \n";
        $str .= "\t *  Crud Operation (Create Read Update Delete/Destroy) \n";
        $str .= "\t */ \n";
        $str .= "\tif (\$_POST ['method'] == 'create') { \n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->create(); \n";
        $str .= "\t} \n";
        $str .= "\tif (\$_POST ['method'] == 'save') { \n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->update(); \n";
        $str .= "\t} \n";
        $str .= "\tif (\$_POST ['method'] == 'read') { \n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->read(); \n";
        $str .= "\t} \n";
        $str .= "\tif (\$_POST ['method'] == 'delete') { \n";
        $str .= "\t\t\$" . $data[0]['tableName'] . "Object->delete(); \n";
        $str .= "\t} \n";
        $str .= "\tif (\$_POST ['method'] == 'posting') { \n";
        $str .= "\t//\t\$" . $data[0]['tableName'] . "Object->posting(); \n";
        $str .= "\t} \n";
        $str .= "\tif (\$_POST ['method'] == 'reverse') { \n";
        $str .= "\t//\t\$" . $data[0]['tableName'] . "Object->delete(); \n";
        $str .= "\t} \n";
        $str .= "} } \n";
        $str .= "if (isset(\$_GET ['method'])) {\n";
        $str .= "   \$" . $data[0]['tableName'] . "Object = new " . ucfirst($data[0]['tableName']) . "Class (); \n";
        $str .= "\tif(\$_GET['securityToken'] != \$" . $data[0]['tableName'] . "Object->getSecurityToken()) {\n";
        $str .= "\t\theader('Content-Type:application/json; charset=utf-8');\n";
        $str .= "\t\techo json_encode(array(\"success\"=>false,\"message\"=>\"Something wrong with the system.Hola hackers\"));\n";
        $str .= "\t\texit();\n";
        $str .= "\t}\n";
        $str .= "\t/* \n";
        $str .= "\t *  initialize Value before load in the loader\n";
        $str .= "\t */ \n";
        $str .= "\tif (isset(\$_GET ['leafId'])) {\n";
        $str .= "       \$" . $data[0]['tableName'] . "Object->setLeafId(\$_GET ['leafId']); \n";
        $str .= "\t} \n";
        $str .= "\t/*\n";
        $str .= "\t *  Load the dynamic value\n";
        $str .= "\t */ \n";
        $str .= "\t\$" . $data[0]['tableName'] . "Object->execute(); \n";
        $str .= "\t/*\n";
        $str .= "\t * Update Status of The Table. Admin Level Only \n";
        $str .= "\t */\n";
        $str .= "\tif (\$_GET ['method'] == 'updateStatus') { \n";
        $str .= "       \$" . $data[0]['tableName'] . "Object->updateStatus(); \n";
        $str .= "\t} \n";
        $str .= "\t/* \n";
        $str .= "\t *  Checking Any Duplication  Key \n";
        $str .= "\t */ \n";
        $str .= "\tif (\$_GET['method'] == 'duplicate') { \n";
        $str .= "   \t\$" . $data[0]['tableName'] . "Object->duplicate(); \n";
        $str .= "\t} \n";
        $str .= "\tif (\$_GET ['method'] == 'dataNavigationRequest') { \n";
        $str .= "       if (\$_GET ['dataNavigation'] == 'firstRecord') { \n";
        $str .= "           \$" . $data[0]['tableName'] . "Object->firstRecord('json'); \n";
        $str .= "       } \n";
        $str .= "       if (\$_GET ['dataNavigation'] == 'previousRecord') { \n";
        $str .= "           \$" . $data[0]['tableName'] . "Object->previousRecord('json', 0); \n";
        $str .= "       } \n";
        $str .= "       if (\$_GET ['dataNavigation'] == 'nextRecord') {\n";
        $str .= "           \$" . $data[0]['tableName'] . "Object->nextRecord('json', 0); \n";
        $str .= "       } \n";
        $str .= "       if (\$_GET ['dataNavigation'] == 'lastRecord') {\n";
        $str .= "           \$" . $data[0]['tableName'] . "Object->lastRecord('json'); \n";
        $str .= "       } \n";
        $str .= "\t} \n";
        $str .= "\t/* \n";
        $str .= "\t * Excel Reporting  \n";
        $str .= "\t */ \n";
        $str .= "\tif (isset(\$_GET ['mode'])) { \n";
        $str .= "       \$" . $data[0]['tableName'] . "Object->setReportMode(\$_GET['mode']); \n";
        $str .= "       if (\$_GET ['mode'] == 'excel'\n            ||  \$_GET ['mode'] == 'pdf'\n\t\t\t||  \$_GET['mode']=='csv'\n\t\t\t||  \$_GET['mode']=='html'\n\t\t\t||\t\$_GET['mode']=='excel5'\n\t\t\t||  \$_GET['mode']=='xml') { \n";
        $str .= "\t\t\t\$" . $data[0]['tableName'] . "Object->excel(); \n";
        $str .= "\t\t} \n";
        $str .= "\t} \n";
        // foreign key
        if ($foreignKeyYes == 1) {
            $str .= "\tif (isset(\$_GET ['filter'])) { \n";
            $str .= "       \$" . $data[0]['tableName'] . "Object->setServiceOutput('option');\n";
            for ($i = 0; $i < $total; $i++) {
                if ($data[$i]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                    // we only can assumed it was the same package and module otherwise
                    // manual change
                    if ($data[$i]['columnName'] != 'companyId') {
                        $str .= "       if((\$_GET['filter']=='" . str_replace("Id", "", $data[$i]['columnName']) . "')) { \n";
                        $str .= "           \$" . $data[0]['tableName'] . "Object->get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "(); \n";
                        $str .= "       }\n";
                    }
                }
            }
            $str .= "   }\n";
        }
        $str .= "} \n";
        $str .= "?>\n";
    }
    return $str;
}
Exemple #13
0
function createText()
{
    global $error, $user;
    $title = checkString($_POST["title"], true, 4, 80, "название перевода");
    $original_title = checkString($_POST["original_title"], true, 4, 80, "оригинальное название перевода");
    $language = intval($_POST["language"]);
    $original_language = intval($_POST["original_language"]);
    $text_type_code = intval($_POST["type"]);
    $access = intval($_POST["access"]);
    $description = mysql_real_escape_string(htmlspecialchars($_POST["description"]));
    $uid = $user->uid;
    if ($text_type_code == 0) {
        $isbn = checkString($_POST["isbn"], true, 0, 20, "ISBN");
        $author = checkString($_POST["author"], true, 0, 100, "имя автора");
        $native_author = checkString($_POST["native_author"], true, 0, 100, "оригинальное имя автора");
        $release_date = intval($_POST["release_date"]);
    } else {
        if ($text_type_code == 1) {
            $duration = setDuration($_POST["duration"]);
        }
    }
    if ($text_type_code < 0 || $text_type_code > 2 || $access < 1 || $access > 4) {
        $error = array("Ошибка отправки формы");
    }
    if (count($error) > 0) {
        return;
    }
    $query = "INSERT INTO `text`\n      (`type`,\n      `access`,\n      `creator`,\n      `title`,\n      `original_title`,\n      `language`,\n      `original_language`,\n      `description`)\n    VALUES\n      ({$text_type_code},\n      {$access},\n      {$uid},\n      \"{$title}\",\n      \"{$original_title}\",\n      {$language},\n      {$original_language},\n      \"{$description}\")";
    executeQuery($query);
    if (count($error) > 0) {
        return;
    }
    $text_id = mysql_insert_id();
    if ($text_type_code == 0) {
        $query = "INSERT INTO `book`\n        (`text_id`,\n        `isbn`,\n        `author`,\n        `native_author`,\n        `release_date`)\n      VALUES\n        ({$text_id},\n        \"{$isbn}\",\n        \"{$author}\",\n        \"{$native_author}\",\n        {$release_date})";
        executeQuery($query);
    } else {
        if ($text_type_code == 1) {
            $query = "INSERT INTO `subtitles`\n        (`text_id`,\n        `duration`)\n      VALUES\n        ({$text_id},\n        {$duration})";
            executeQuery($query);
        }
    }
    if (count($error) == 0) {
        header('Location: view.php?id=' . $text_id);
        die;
    }
}
Exemple #14
0
function serviceSourceCode($data, $dataTabDetail = null)
{
    if (isset($dataTabDetail)) {
        $tabCounter = count($dataTabDetail);
    }
    if (isset($data) && is_array($data)) {
        $total = count($data);
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['Key'] == 'PRI') {
                $data[0]['tableName'] = str_replace('Id', '', $data[0]['columnName']);
            }
        }
        $str .= "<?php namespace Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Service; \n";
        $str .= "\tuse Core\\ConfigClass;\n";
        $str .= "\t\$x = addslashes(realpath(__FILE__));\n";
        $str .= "\t// auto detect if \\ consider come from windows else / from linux\n";
        $str .= "\t\$pos = strpos(\$x, \"\\\\\");\n";
        $str .= "\tif (\$pos !== false) {\n";
        $str .= "\t\t\$d = explode(\"\\\\\", \$x);\n";
        $str .= "\t} else {  \n";
        $str .= "\t\t\$d = explode(\"/\", \$x);\n";
        $str .= "\t}\n";
        $str .= "\t\$newPath = null;\n";
        $str .= "\tfor (\$i = 0; \$i < count(\$d); \$i ++) {\n";
        $str .= "\t\t// if find the library or package then stop\n";
        $str .= "\t\tif (\$d[\$i] == 'library' || \$d[\$i] == 'v3') {\n";
        $str .= "\t\t\tbreak;\n";
        $str .= "\t\t}\n";
        $str .= "\t\t\$newPath[] .= \$d[\$i] . \"/\";\n";
        $str .= "\t}\n";
        $str .= "\t\$fakeDocumentRoot = null;\n";
        $str .= "\tfor (\$z = 0; \$z < count(\$newPath); \$z ++) {\n";
        $str .= "\t\t\$fakeDocumentRoot .= \$newPath[\$z];\n";
        $str .= "\t}\n";
        $str .= "\t\$newFakeDocumentRoot = str_replace(\"//\", \"/\", \$fakeDocumentRoot); // start\n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classAbstract.php\"); \n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classShared.php\"); \n";
        $str .= "/** \n";
        $str .= " * Class " . ucfirst($data[0]['tableName']) . "Service\n";
        $str .= " * Contain extra processing function / method.\n";
        $str .= " * @name IDCMS \n";
        $str .= " * @version 2 \n";
        $str .= " * @author hafizan \n";
        $str .= " * @package Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Service\n";
        $str .= " * @subpackage " . ucwords($data[0]['module']) . " \n";
        $str .= " * @link http://www.hafizan.com \n";
        $str .= " * @license http://www.gnu.org/copyleft/lesser.html LGPL \n";
        $str .= " */ \n";
        $str .= "class " . ucfirst($data[0]['tableName']) . "Service extends ConfigClass { \n";
        $str .= "\t/** \n";
        $str .= "\t * Connection to the database \n";
        $str .= "\t * @var \\Core\\Database\\Mysql\\Vendor \n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$q; \n";
        $str .= "\t/** \n";
        $str .= "\t * Translate Label \n";
        $str .= "\t * @var string \n";
        $str .= "\t */ \n";
        $str .= "\tpublic \$t; \n";
        $str .= "\t/** \n";
        $str .= "\t * Constructor \n";
        $str .= "\t */ \n";
        $str .= "   function __construct() { \n";
        $str .= "       parent::__construct(); \n";
        $str .= "       if(\$_SESSION['companyId']){\n";
        $str .= "           \$this->setCompanyId(\$_SESSION['companyId']);\n";
        $str .= "       }else{\n";
        $str .= "           // fall back to default database if anything wrong\n";
        $str .= "           \$this->setCompanyId(1);\n";
        $str .= "       }\n";
        $str .= "   }\n";
        $str .= "\t/** \n";
        $str .= "\t * Class Loader \n";
        $str .= "\t */ \n";
        $str .= "\tfunction execute() { \n";
        $str .= "         parent::__construct(); \n";
        $str .= "\t} \n";
        $str .= "  \n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[0]['foreignKey'] == 1 && $data[$i]['Key'] == 'MUL') {
                if ($data[$i]['columnName'] != 'companyId') {
                    // we only can assumed it was the same package and module otherwise manual change
                    $str .= "  /**\n";
                    $str .= "   * Return " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . "\n";
                    $str .= "   * @return array|string\n";
                    $str .= "   * @throws \\Exception\n";
                    $str .= "\t*/\n";
                    $str .= "\tpublic function get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "() { \n";
                    $str .= "     //initialize dummy value.. no content header.pure html  \n";
                    $str .= "     \$sql=null; \n";
                    $str .= "     \$str=null; \n";
                    $str .= "     \$items=array(); \n";
                    // for temporarily we only take information from identification and also desc only..
                    if ($data[$i]['columnName'] == 'businessPartnerId') {
                        $field = str_replace("Id", "", $data[$i]['columnName']) . "Company";
                        $oracleField = strtoupper(str_replace("Id", "", $data[$i]['columnName']) . "Company");
                    } else {
                        if ($data[$i]['columnName'] == 'employeeId') {
                            $field = str_replace("Id", "", $data[$i]['columnName']) . "FirstName";
                            $oracleField = strtoupper(str_replace("Id", "", $data[$i]['columnName']) . "FirstName");
                        } else {
                            if ($data[$i]['columnName'] == 'staffId') {
                                $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                $oracleField = strtoupper(str_replace("Id", "", $data[$i]['columnName']) . "Name");
                            } else {
                                if ($data[$i]['columnName'] == 'chartOfAccountId') {
                                    $field = str_replace("Id", "", $data[$i]['columnName']) . "Title";
                                    $oracleField = strtoupper(str_replace("Id", "", $data[$i]['columnName']) . "Title");
                                } else {
                                    if ($data[$i]['columnName'] == 'assetId') {
                                        $field = str_replace("Id", "", $data[$i]['columnName']) . "Name";
                                        $oracleField = strtoupper(str_replace("Id", "", $data[$i]['columnName']) . "Name");
                                    } else {
                                        $field = str_replace("Id", "", $data[$i]['columnName']) . "Description";
                                        $oracleField = strtoupper(str_replace("Id", "", $data[$i]['columnName']) . "Description");
                                    }
                                }
                            }
                        }
                    }
                    $str .= "     if(\$this->getVendor()==self::MYSQL) { \n";
                    $str .= "         \$sql =\"  \n";
                    $str .= "         SELECT      `" . $data[$i]['columnName'] . "`,\n";
                    $str .= "                     `" . $field . "`\n";
                    $str .= "         FROM        `" . strtolower(str_replace("Id", "", $data[$i]['columnName'])) . "`\n";
                    $str .= "         WHERE       `isActive`  =   1\n";
                    $str .= "         AND         `companyId` =   '\".\$this->getCompanyId().\"'\n";
                    $str .= "         ORDER BY    `isDefault`;\"; \n";
                    $str .= "     } else if (\$this->getVendor()==self::MSSQL) { \n";
                    $str .= "         \$sql =\" \n";
                    $str .= "         SELECT      [" . $data[$i]['columnName'] . "],\n";
                    $str .= "                     [" . $field . "]\n";
                    $str .= "         FROM        [" . str_replace("Id", "", $data[$i]['columnName']) . "]\n";
                    $str .= "         WHERE       [isActive]  =   1\n";
                    $str .= "         AND         [companyId] =   '\".\$this->getCompanyId().\"'\n";
                    $str .= "         ORDER BY    [isDefault]\"; \n";
                    $str .= "     } else if (\$this->getVendor()==self::ORACLE) { \n";
                    $str .= "         \$sql =\" \n";
                    $str .= "         SELECT      " . strtoupper($data[$i]['columnName']) . " AS \\\"" . $data[$i]['columnName'] . "\\\",\n";
                    $str .= "                     " . $oracleField . " AS \\\"" . $field . "\\\"\n";
                    $str .= "         FROM        " . strtoupper(str_replace("Id", "", $data[$i]['columnName'])) . "  \n";
                    $str .= "         WHERE       ISACTIVE    =   1\n";
                    $str .= "         AND         COMPANYID   =   '\".\$this->getCompanyId().\"'\n";
                    $str .= "         ORDER BY    ISDEFAULT\"; \n";
                    $str .= "     }  else {\n";
                    $str .= "         header('Content-Type:application/json; charset=utf-8');\n";
                    $str .= "         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel']));\n";
                    $str .= "         exit();\n";
                    $str .= "     }\n";
                    $str .= "     try {\n";
                    $str .= "       \$result =\$this->q->fast(\$sql);\n";
                    $str .= "     } catch (\\Exception \$e) {\n";
                    $str .= "       echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                    $str .= "       exit();\n";
                    $str .= "    }\n";
                    $str .= "     if(\$result) { \n";
                    $str .= "\t\t  \$d=1;\n";
                    $str .= "         while((\$row = \$this->q->fetchArray(\$result))==TRUE) { \n";
                    $str .= "             if(\$this->getServiceOutput()=='option'){\n ";
                    $str .= "                 \$str.=\"<option value='\".\$row['" . $data[$i]['columnName'] . "'].\"'>\".\$d.\". \".\$row['" . $field . "'].\"</option>\";\n";
                    $str .= "             } else if (\$this->getServiceOutput()=='html')  { \n";
                    $str .= "                 \$items[] = \$row; \n";
                    $str .= "             }\n";
                    $str .= "\t\t\t  \$d++;\n";
                    $str .= "         }\n";
                    $str .= "         unset(\$d);\n";
                    $str .= "     }\n";
                    $str .= "     if(\$this->getServiceOutput()=='option'){\n ";
                    $str .= "         if (strlen(\$str) > 0) {\n";
                    $str .= "            \$str = \"<option value=''>\".\$this->t['pleaseSelectTextLabel'].\"</option>\" . \$str; \n";
                    $str .= "         } else {\n";
                    $str .= "             \$str= \"<option value=''>\".\$this->t['notAvailableTextLabel'].\"</option>\";\n";
                    $str .= "         }\n";
                    $str .= "         header('Content-Type:application/json; charset=utf-8');\n";
                    $str .= "         echo json_encode(array(\"success\"=>true,\"message\"=>\"complete\",\"data\"=>\$str));\n";
                    $str .= "         exit();\n";
                    $str .= "     } else if (\$this->getServiceOutput()=='html')  { \n";
                    $str .= "         return \$items; \n ";
                    $str .= "     }\n";
                    $str .= "         return false; \n ";
                    $str .= " }\n";
                    $str .= "  /**\n";
                    $str .= "   * Return " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " Default Value\n";
                    $str .= "   * @return int\n";
                    $str .= "   * @throws \\Exception\n";
                    $str .= "\t*/\n";
                    $str .= "\tpublic function get" . ucfirst(str_replace("Id", "", $data[$i]['columnName'])) . "DefaultValue() { \n";
                    $str .= "     //initialize dummy value.. no content header.pure html  \n";
                    $str .= "     \$sql=null; \n";
                    $str .= "\t  \$" . $data[$i]['columnName'] . "=null;\n";
                    // for temporarily we only take information from identification and also desc only..
                    $str .= "     if(\$this->getVendor()==self::MYSQL) { \n";
                    $str .= "         \$sql =\"  \n";
                    $str .= "         SELECT      `" . $data[$i]['columnName'] . "`\n";
                    $str .= "         FROM        \t`" . strtolower(str_replace("Id", "", $data[$i]['columnName'])) . "`\n";
                    $str .= "         WHERE       `isActive`  =   1\n";
                    $str .= "         AND         `companyId` =   '\".\$this->getCompanyId().\"'\n";
                    $str .= "         AND    \t  `isDefault` =\t  1\n";
                    $str .= "         LIMIT 1\"; \n";
                    $str .= "     } else if (\$this->getVendor()==self::MSSQL) { \n";
                    $str .= "         \$sql =\" \n";
                    $str .= "         SELECT      TOP 1 [" . $data[$i]['columnName'] . "],\n";
                    $str .= "         FROM        [" . str_replace("Id", "", $data[$i]['columnName']) . "]\n";
                    $str .= "         WHERE       [isActive]  =   1\n";
                    $str .= "         AND         [companyId] =   '\".\$this->getCompanyId().\"'\n";
                    $str .= "         AND    \t  [isDefault] =   1\"; \n";
                    $str .= "     } else if (\$this->getVendor()==self::ORACLE) { \n";
                    $str .= "         \$sql =\" \n";
                    $str .= "         SELECT      " . strtoupper($data[$i]['columnName']) . " AS \\\"" . $data[$i]['columnName'] . "\\\",\n";
                    $str .= "         FROM        " . strtoupper(str_replace("Id", "", $data[$i]['columnName'])) . "  \n";
                    $str .= "         WHERE       ISACTIVE    =   1\n";
                    $str .= "         AND         COMPANYID   =   '\".\$this->getCompanyId().\"'\n";
                    $str .= "         AND    \t  ISDEFAULT\t  =\t   1\n";
                    $str .= "         AND \t\t  ROWNUM\t  =\t   1\";\n";
                    $str .= "     }  else {\n";
                    $str .= "         header('Content-Type:application/json; charset=utf-8');\n";
                    $str .= "         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel']));\n";
                    $str .= "         exit();\n";
                    $str .= "     }\n";
                    $str .= "     try {\n";
                    $str .= "       \$result =\$this->q->fast(\$sql);\n";
                    $str .= "     } catch (\\Exception \$e) {\n";
                    $str .= "       echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                    $str .= "       exit();\n";
                    $str .= "    }\n";
                    $str .= "     if(\$result) { \n";
                    $str .= "         \$row = \$this->q->fetchArray(\$result); \n";
                    $str .= "\t\t  \$" . $data[$i]['columnName'] . " = \$row['" . $data[$i]['columnName'] . "'];\n";
                    $str .= "\t }\n";
                    $str .= "\t return \$" . $data[$i]['columnName'] . ";\n";
                    $str .= " }\n";
                }
            }
        }
        if (isset($dataTabDetail) && count($dataTabDetail) > 0) {
            for ($j = 0; $j < $tabCounter; $j++) {
                if (isset($dataTabDetail[$j]) && count($dataTabDetail[$j]) > 0) {
                    $total = count($dataTabDetail[$j]);
                    $str .= "class " . ucfirst($dataTabDetail[$j][0]['tableName']) . "Service extends ConfigClass { \n";
                    $str .= "\t/** \n";
                    $str .= "\t * Connection to the database \n";
                    $str .= "\t * @var \\Core\\Database\\Mysql\\Vendor \n";
                    $str .= "\t */ \n";
                    $str .= "\tpublic \$q; \n";
                    $str .= "\t/** \n";
                    $str .= "\t * Translate Label \n";
                    $str .= "\t * @var string \n";
                    $str .= "\t */ \n";
                    $str .= "\tpublic \$t; \n";
                    $str .= "\t/** \n";
                    $str .= "\t * Model \n";
                    $str .= "\t * @var \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Model\\" . ucwords($dataTabDetail[$j][0]['tableName']) . "MultiModel \n";
                    $str .= "\t */ \n";
                    $str .= "\tpublic \$model; \n";
                    $str .= "\t/** \n";
                    $str .= "\t * Constructor \n";
                    $str .= "\t */ \n";
                    $str .= "   function __construct() { \n";
                    $str .= "       parent::__construct(); \n";
                    $str .= "       if(\$_SESSION['companyId']){\n";
                    $str .= "           \$this->setCompanyId(\$_SESSION['companyId']);\n";
                    $str .= "       }else{\n";
                    $str .= "           // fall back to default database if anything wrong\n";
                    $str .= "           \$this->setCompanyId(1);\n";
                    $str .= "       }\n";
                    $str .= "   }\n";
                    $str .= "\t/** \n";
                    $str .= "\t * Class Loader \n";
                    $str .= "\t */ \n";
                    $str .= "\tfunction execute() { \n";
                    $str .= "         parent::__construct(); \n";
                    $str .= "\t} \n";
                    for ($i = 0; $i < $total; $i++) {
                        if ($dataTabDetail[$j][$i]['foreignKey'] == 1) {
                            if ($dataTabDetail[$j][$i]['columnName'] != 'companyId') {
                                // we only can assumed it was the same package and module otherwise manual change
                                $str .= "  /**\n";
                                $str .= "   * Return " . ucfirst(checkString(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']))) . "\n";
                                $str .= "   * @return array|string\n";
                                $str .= "   * @throws \\Exception\n";
                                $str .= "\t*/\n";
                                $str .= "\tpublic function get" . str_replace($dataTabDetail[$j][0]['tableName'], "", str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "() { \n";
                                $str .= "     \$sql=null; \n";
                                $str .= "     \$str=null; \n";
                                $str .= "     \$items=array(); \n";
                                // for temporarily we only take information from identification and also desc only..
                                if ($dataTabDetail[$j][$i]['columnName'] == 'businessPartnerId') {
                                    $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Company";
                                    $oracleField = strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Company");
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'employeeId') {
                                        $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "FirstName";
                                        $oracleField = strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "FirstName");
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] == 'staffId') {
                                            $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                            $oracleField = strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name");
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] == 'chartOfAccountId') {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Title";
                                                $oracleField = strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Title");
                                            } else {
                                                if ($dataTabDetail[$j][$i]['columnName'] == 'assetId') {
                                                    $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                                    $oracleField = strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name");
                                                } else {
                                                    $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Description";
                                                    $oracleField = strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Description");
                                                }
                                            }
                                        }
                                    }
                                }
                                $str .= "     if(\$this->getVendor()==self::MYSQL) { \n";
                                $str .= "         \$sql =\"  \n";
                                $str .= "         SELECT      `" . $dataTabDetail[$j][$i]['columnName'] . "`,\n";
                                $str .= "                     `" . $field . "`\n";
                                $str .= "         FROM        `" . strtolower(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "`\n";
                                $str .= "         WHERE       `isActive`  =   1\n";
                                $str .= "         AND         `companyId` =   '\".\$this->getCompanyId().\"'\n";
                                $str .= "         ORDER BY    `isDefault`;\"; \n";
                                $str .= "     } else if (\$this->getVendor()==self::MSSQL) { \n";
                                $str .= "         \$sql =\" \n";
                                $str .= "         SELECT      [" . $dataTabDetail[$j][$i]['columnName'] . "],\n";
                                $str .= "                     [" . $field . "]\n";
                                $str .= "         FROM        [" . str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "]\n";
                                $str .= "         WHERE       [isActive]  =   1\n";
                                $str .= "         AND         [companyId] =   '\".\$this->getCompanyId().\"'\n";
                                $str .= "         ORDER BY    [isDefault]\"; \n";
                                $str .= "     } else if (\$this->getVendor()==self::ORACLE) { \n";
                                $str .= "         \$sql =\" \n";
                                $str .= "         SELECT      " . strtoupper($dataTabDetail[$j][$i]['columnName']) . " AS \\\"" . $dataTabDetail[$j][$i]['columnName'] . "\\\",\n";
                                $str .= "                     " . $oracleField . " AS \\\"" . $field . "\\\"\n";
                                $str .= "         FROM        " . strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "  \n";
                                $str .= "         WHERE       ISACTIVE    =   1\n";
                                $str .= "         AND         COMPANYID   =   '\".\$this->getCompanyId().\"'\n";
                                $str .= "         ORDER BY    ISDEFAULT\"; \n";
                                $str .= "     }  else {\n";
                                $str .= "         header('Content-Type:application/json; charset=utf-8');\n";
                                $str .= "         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel']));\n";
                                $str .= "         exit();\n";
                                $str .= "     }\n";
                                $str .= "     try {\n";
                                $str .= "       \$result =\$this->q->fast(\$sql);\n";
                                $str .= "     } catch (\\Exception \$e) {\n";
                                $str .= "       echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                                $str .= "       exit();\n";
                                $str .= "    }\n";
                                $str .= "     if(\$result) { \n";
                                $str .= "\t\t  \$d=1;\n";
                                $str .= "         while((\$row = \$this->q->fetchArray(\$result))==TRUE) { \n";
                                $str .= "             if(\$this->getServiceOutput()=='option'){\n ";
                                $str .= "                 \$str.=\"<option value='\".\$row['" . $dataTabDetail[$j][$i]['columnName'] . "'].\"'>\".\$d.\". \".\$row['" . $field . "'].\"</option>\";\n";
                                $str .= "             } else if (\$this->getServiceOutput()=='html')  { \n";
                                $str .= "                 \$items[] = \$row; \n";
                                $str .= "             }\n";
                                $str .= "\t\t\t  \$d++;\n";
                                $str .= "         }\n";
                                $str .= "         unset(\$d);\n";
                                $str .= "     }\n";
                                $str .= "     if(\$this->getServiceOutput()=='option'){\n ";
                                $str .= "         if (strlen(\$str) > 0) {\n";
                                $str .= "            \$str = \"<option value=''>\".\$this->t['pleaseSelectTextLabel'].\"</option>\" . \$str; \n";
                                $str .= "         } else {\n";
                                $str .= "             \$str= \"<option value=''>\".\$this->t['notAvailableTextLabel'].\"</option>\";\n";
                                $str .= "         }\n";
                                $str .= "         header('Content-Type:application/json; charset=utf-8');\n";
                                $str .= "         echo json_encode(array(\"success\"=>true,\"message\"=>\"complete\",\"data\"=>\$str));\n";
                                $str .= "         exit();\n";
                                $str .= "     } else if (\$this->getServiceOutput()=='html')  { \n";
                                $str .= "         return \$items; \n ";
                                $str .= "     }\n";
                                $str .= "         return false; \n ";
                                $str .= " }\n";
                                $str .= "  /**\n";
                                $str .= "   * Return " . checkString(str_replace($dataTabDetail[$j][0]['tableName'], "", str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']))) . " Default Value\n";
                                $str .= "   * @return int\n";
                                $str .= "   * @throws \\Exception\n";
                                $str .= "\t*/\n";
                                $str .= "\tpublic function get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "DefaultValue() { \n";
                                $str .= "     //initialize dummy value.. no content header.pure html  \n";
                                $str .= "     \$sql=null; \n";
                                $str .= "\t  \$" . $dataTabDetail[$j][$i]['columnName'] . "=null;\n";
                                // for temporarily we only take information from identification and also desc only..
                                $str .= "     if(\$this->getVendor()==self::MYSQL) { \n";
                                $str .= "         \$sql =\"  \n";
                                $str .= "         SELECT      `" . $dataTabDetail[$j][$i]['columnName'] . "`\n";
                                $str .= "         FROM        \t`" . strtolower(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "`\n";
                                $str .= "         WHERE       `isActive`  =   1\n";
                                $str .= "         AND         `companyId` =   '\".\$this->getCompanyId().\"'\n";
                                $str .= "         AND    \t  `isDefault` =\t  1\n";
                                $str .= "         LIMIT 1\"; \n";
                                $str .= "     } else if (\$this->getVendor()==self::MSSQL) { \n";
                                $str .= "         \$sql =\" \n";
                                $str .= "         SELECT      TOP 1 [" . $dataTabDetail[$j][$i]['columnName'] . "],\n";
                                $str .= "         FROM        [" . str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "]\n";
                                $str .= "         WHERE       [isActive]  =   1\n";
                                $str .= "         AND         [companyId] =   '\".\$this->getCompanyId().\"'\n";
                                $str .= "         AND    \t  [isDefault] =   1\"; \n";
                                $str .= "     } else if (\$this->getVendor()==self::ORACLE) { \n";
                                $str .= "         \$sql =\" \n";
                                $str .= "         SELECT      " . strtoupper($dataTabDetail[$j][$i]['columnName']) . " AS \\\"" . $dataTabDetail[$j][$i]['columnName'] . "\\\",\n";
                                $str .= "         FROM        " . strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "  \n";
                                $str .= "         WHERE       ISACTIVE    =   1\n";
                                $str .= "         AND         COMPANYID   =   '\".\$this->getCompanyId().\"'\n";
                                $str .= "         AND    \t  ISDEFAULT\t  =\t   1\n";
                                $str .= "         AND \t\t  ROWNUM\t  =\t   1\";\n";
                                $str .= "     }  else {\n";
                                $str .= "         header('Content-Type:application/json; charset=utf-8');\n";
                                $str .= "         echo json_encode(array(\"success\" => false, \"message\" => \$this->t['databaseNotFoundMessageLabel']));\n";
                                $str .= "         exit();\n";
                                $str .= "     }\n";
                                $str .= "     try {\n";
                                $str .= "       \$result =\$this->q->fast(\$sql);\n";
                                $str .= "     } catch (\\Exception \$e) {\n";
                                $str .= "       echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                                $str .= "       exit();\n";
                                $str .= "    }\n";
                                $str .= "     if(\$result) { \n";
                                $str .= "         \$row = \$this->q->fetchArray(\$result); \n";
                                $str .= "\t\t  \$" . $dataTabDetail[$j][$i]['columnName'] . " = \$row['" . $dataTabDetail[$j][$i]['columnName'] . "'];\n";
                                $str .= "\t }\n";
                                $str .= "\t return \$" . $dataTabDetail[$j][$i]['columnName'] . ";\n";
                                $str .= " }\n";
                            }
                        }
                    }
                    $str .= "  \n";
                    $str .= "    /** Create\n";
                    $str .= "  * @see config::create()\n";
                    $str .= "  *  @return void\n";
                    $str .= "  **/\n";
                    // sort of depency injection
                    $str .= " public function create() {\n";
                    // start
                    $str .= " if (\$this->getVendor() == self::MYSQL) {  \n";
                    $str .= "  \$sql = \"SET NAMES utf8\";  \n";
                    $str .= "  try {\n";
                    $str .= "   \$this->q->fast(\$sql);\n";
                    $str .= "  } catch (\\Exception \$e) {\n";
                    $str .= "   echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                    $str .= "   exit();\n";
                    $str .= "  }\n";
                    $str .= " } \n";
                    $str .= "       \$this->model->create();  \n";
                    $str .= "       \$sql=null;\n";
                    if ($foreignKeyYes == 1) {
                        for ($i = 0; $i < $total; $i++) {
                            if ($dataTabDetail[$j][$i]['Key'] == 'MUL' && $dataTabDetail[$j][$i]['columnName'] != 'companyId') {
                                $str .= "       if(!\$this->model->get" . ucfirst($dataTabDetail[$j][$i]['columnName']) . "()){\n";
                                $str .= "           \$this->model->set" . ucfirst($dataTabDetail[$j][$i]['columnName']) . "(\$this->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "DefaultValue());\n";
                                $str .= "       }\n";
                            }
                        }
                    }
                    $str .= "       if (\$this->getVendor() == self::MYSQL) {  \n";
                    $mysqlInsertStatementAField = null;
                    $mysqlInsertStatementInsideValue = null;
                    $mysqlInsertStatement = "       \$sql=\"\n            INSERT INTO `" . strtolower($dataTabDetail[$j][0]['tableName']) . "` \n            (\n";
                    for ($i = 0; $i < $total; $i++) {
                        if ($i >= 1) {
                            $mysqlInsertStatementAField .= "                 `" . $dataTabDetail[$j][$i]['columnName'] . "`,\n";
                        }
                    }
                    $mysqlInsertStatement .= substr($mysqlInsertStatementAField, 0, -2);
                    $mysqlInsertStatement .= "\n       ) VALUES\n";
                    for ($t = 1; $t <= $dataTabDetail[$j][0]['targetMaximumTabRecord']; $t++) {
                        $mysqlInsertStatementInsideValue .= "( \n";
                        for ($i = 0; $i < $total; $i++) {
                            if ($i >= 1) {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'executeTime') {
                                    $mysqlInsertStatementInsideValue .= "                 \".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\",\n";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'companyId' || $dataTabDetail[$j][$i]['columnName'] == 'executeBy') {
                                        $mysqlInsertStatementInsideValue .= "                 '\".\$this->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] != 'isDefault' && $dataTabDetail[$j][$i]['columnName'] != 'isNew' && $dataTabDetail[$j][$i]['columnName'] != 'isDraft' && $dataTabDetail[$j][$i]['columnName'] != 'isUpdate' && $dataTabDetail[$j][$i]['columnName'] != 'isDelete' && $dataTabDetail[$j][$i]['columnName'] != 'isActive' && $dataTabDetail[$j][$i]['columnName'] != 'isApproved' && $dataTabDetail[$j][$i]['columnName'] != 'isReview' && $dataTabDetail[$j][$i]['columnName'] != 'isPost' && $dataTabDetail[$j][$i]['columnName'] != 'isSlice' && $dataTabDetail[$j][$i]['columnName'] != 'isConsolidation') {
                                            $mysqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                        } else {
                                            $mysqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(0, 'single').\"',\n";
                                        }
                                    }
                                }
                            }
                        }
                        $mysqlInsertStatementInsideValue .= "),\n\n";
                    }
                    $mysqlInsertStatement .= substr($mysqlInsertStatementInsideValue, 0, -2);
                    $mysqlInsertStatement .= "\";\n";
                    $str .= $mysqlInsertStatement;
                    $str .= "\t\t } else if (\$this->getVendor() == self::MSSQL) {  \n";
                    $mssqlInsertStatement = null;
                    $mssqlInsertStatementAField = null;
                    $mssqlInsertStatementField = null;
                    $mssqlInsertStatementInsideValue = null;
                    $mssqlInsertStatementValue = null;
                    $mssqlInsertStatement .= "       \$sql=\"\n            INSERT INTO [" . $dataTabDetail[$j][0]['tableName'] . "] \n            (\n";
                    for ($i = 0; $i < $total; $i++) {
                        if ($i >= 0) {
                            $mssqlInsertStatementAField .= "                 [" . $dataTabDetail[$j][$i]['columnName'] . "],\n";
                        }
                    }
                    $mssqlInsertStatementField .= substr($mssqlInsertStatementAField, 0, -2);
                    $mssqlInsertStatement .= $mssqlInsertStatementField;
                    $mssqlInsertStatement .= "\n) VALUES\n";
                    for ($t = 1; $t <= $dataTabDetail[$j][0]['targetMaximumTabRecord']; $t++) {
                        $mssqlInsertStatementInsideValue .= "(\n";
                        for ($i = 0; $i < $total; $i++) {
                            if ($i >= 1) {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'executeTime') {
                                    $mssqlInsertStatementInsideValue .= "                 \".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\",\n";
                                } elseif ($dataTabDetail[$j][$i]['columnName'] == 'companyId' || $dataTabDetail[$j][$i]['columnName'] == 'executeBy') {
                                    $mssqlInsertStatementInsideValue .= "                 '\".\$this->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                } elseif ($dataTabDetail[$j][$i]['columnName'] != 'isDefault' && $dataTabDetail[$j][$i]['columnName'] != 'isNew' && $dataTabDetail[$j][$i]['columnName'] != 'isDraft' && $dataTabDetail[$j][$i]['columnName'] != 'isUpdate' && $dataTabDetail[$j][$i]['columnName'] != 'isDelete' && $dataTabDetail[$j][$i]['columnName'] != 'isActive' && $dataTabDetail[$j][$i]['columnName'] != 'isApproved' && $dataTabDetail[$j][$i]['columnName'] != 'isReview' && $dataTabDetail[$j][$i]['columnName'] != 'isPost' && $dataTabDetail[$j][$i]['columnName'] != 'isSlice' && $dataTabDetail[$j][$i]['columnName'] != 'isConsolidation') {
                                    $mssqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(" . $t . ").\"',\n";
                                } else {
                                    $mssqlInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(0, 'single').\"',\n";
                                }
                            }
                        }
                        $mssqlInsertStatementInsideValue .= "),\n";
                    }
                    $mssqlInsertStatementValue .= substr($mssqlInsertStatementInsideValue, 0, -2);
                    $mssqlInsertStatement .= $mssqlInsertStatementValue;
                    $mssqlInsertStatement .= "\";\n";
                    $str .= $mssqlInsertStatement;
                    $str .= "       } else if (\$this->getVendor() == self::ORACLE) {  \n";
                    $oracleInsertStatement = null;
                    $oracleInsertStatementAField = null;
                    $oracleInsertStatementField = null;
                    $oracleInsertStatementInsideValue = null;
                    $oracleInsertStatementValue = null;
                    $oracleInsertStatement .= "            \$sql=\"\n            INSERT INTO " . strtoupper($dataTabDetail[$j][0]['tableName']) . " \n            (\n";
                    for ($i = 0; $i < $total; $i++) {
                        if ($i >= 1) {
                            $oracleInsertStatementAField .= "                 " . strtoupper($dataTabDetail[$j][$i]['columnName']) . ",\n";
                        }
                    }
                    $oracleInsertStatementField .= substr($oracleInsertStatementAField, 0, -2);
                    $oracleInsertStatement .= $oracleInsertStatementField;
                    $oracleInsertStatement .= "\n            ) VALUES \n";
                    for ($t = 1; $t <= $dataTabDetail[$j][0]['targetMaximumTabRecord']; $t++) {
                        $oracleInsertStatementInsideValue .= "(\n";
                        for ($i = 0; $i < $total; $i++) {
                            if ($i >= 1) {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'executeTime') {
                                    $oracleInsertStatementInsideValue .= "                 \".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\",\n";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'companyId' || $dataTabDetail[$j][$i]['columnName'] == 'executeBy') {
                                        $oracleInsertStatementInsideValue .= "                 '\".\$this->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] != 'isDefault' && $dataTabDetail[$j][$i]['columnName'] != 'isNew' && $dataTabDetail[$j][$i]['columnName'] != 'isDraft' && $dataTabDetail[$j][$i]['columnName'] != 'isUpdate' && $dataTabDetail[$j][$i]['columnName'] != 'isDelete' && $dataTabDetail[$j][$i]['columnName'] != 'isActive' && $dataTabDetail[$j][$i]['columnName'] != 'isApproved' && $dataTabDetail[$j][$i]['columnName'] != 'isReview' && $dataTabDetail[$j][$i]['columnName'] != 'isPost' && $dataTabDetail[$j][$i]['columnName'] != 'isSlice' && $dataTabDetail[$j][$i]['columnName'] != 'isConsolidation') {
                                            $oracleInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(" . $t . ").\"',\n";
                                        } else {
                                            $oracleInsertStatementInsideValue .= "                 '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(0, 'single').\"',\n";
                                        }
                                    }
                                }
                            }
                        }
                        $oracleInsertStatementInsideValue .= "),";
                    }
                    $oracleInsertStatementValue .= substr($oracleInsertStatementInsideValue, 0, -2);
                    $oracleInsertStatement .= $oracleInsertStatementValue;
                    $oracleInsertStatement .= "\";\n";
                    $str .= $oracleInsertStatement;
                    $str .= "       }  \n";
                    $str .= "       try {\n";
                    $str .= "           \$this->q->create(\$sql);\n";
                    $str .= "       } catch (\\Exception \$e) {\n";
                    $str .= "           \$this->q->rollback();\n";
                    $str .= "           echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                    $str .= "           exit();\n";
                    $str .= "       }\n";
                    // end
                    $str .= " }\n";
                    $str .= "    /**\n";
                    $str .= "     * Read\n";
                    $str .= "     * @see config::read()\n";
                    $str .= "     * @return void\n";
                    $str .= "     */\n";
                    $str .= "     public function read() {\n";
                    $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
                    $mysqlReadStatement = null;
                    $mysqlReadInsideStatement = null;
                    $mysqlReadStatement .= "\n      \$sql = \"\n       SELECT";
                    for ($i = 0; $i < $total; $i++) {
                        if ($dataTabDetail[$j][$i]['foreignKey'] == 1 && $dataTabDetail[$j][$i]['Key'] == 'MUL') {
                            //exception for some cases
                            if ($dataTabDetail[$j][$i]['columnName'] == 'businessPartnerId') {
                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Company";
                            } else {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'employeeId') {
                                    $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "FirstName";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'staffId') {
                                        $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] == 'chartOfAccountId') {
                                            $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Title";
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] == 'assetId') {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                            } else {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Description";
                                            }
                                        }
                                    }
                                }
                            }
                            $mysqlReadInsideStatement .= "                    `" . strtolower(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "`.`" . $field . "`,\n";
                            $mysqlReadInsideStatement .= "                    `" . strtolower($dataTabDetail[$j][0]['tableName']) . "`.`" . $dataTabDetail[$j][$i]['columnName'] . "`,\n";
                        } else {
                            $mysqlReadInsideStatement .= "                    `" . strtolower($dataTabDetail[$j][0]['tableName']) . "`.`" . $dataTabDetail[$j][$i]['columnName'] . "`,\n";
                        }
                    }
                    $mysqlReadStatement .= $mysqlReadInsideStatement;
                    $mysqlReadStatement .= "                    `staff`.`staffName`\n";
                    $mysqlReadStatement .= "\t\t  FROM      `" . strtolower($dataTabDetail[$j][0]['tableName']) . "`\n";
                    $mysqlReadStatement .= "\t\t  JOIN      `staff`\n";
                    $mysqlReadStatement .= "\t\t  ON        `" . strtolower($dataTabDetail[$j][0]['tableName']) . "`.`executeBy` = `staff`.`staffId`\n";
                    $mysqlReadStatement .= "\t\t  WHERE    `companyId`= \" . \$this->companyId().\"' \n";
                    $mysqlReadStatement .= "\t\t  AND    `" . str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName']) . "LineNumber` = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LineNumber(" . $i . ") . \"'\"; \n";
                    $str .= $mysqlReadStatement;
                    $str .= " } else if (\$this->getVendor() == self::MSSQL) {  \n";
                    $mssqlReadStatement = null;
                    $mssqlReadInsideStatement = null;
                    $mssqlReadStatement .= "\n\t\t  \$sql = \"\n\t\t  SELECT";
                    for ($i = 0; $i < $total; $i++) {
                        if ($dataTabDetail[$j][$i]['foreignKey'] == 1 && $dataTabDetail[$j][$i]['Key'] == 'MUL') {
                            //exception for some cases
                            if ($dataTabDetail[$j][$i]['columnName'] == 'businessPartnerId') {
                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Company";
                            } else {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'employeeId') {
                                    $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "FirstName";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'staffId') {
                                        $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] == 'chartOfAccountId') {
                                            $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Title";
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] == 'assetId') {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                            } else {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Description";
                                            }
                                        }
                                    }
                                }
                            }
                            $mssqlReadInsideStatement .= "                    [" . str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "].[" . $field . "],\n";
                            $mssqlReadInsideStatement .= "                    [" . $dataTabDetail[$j][0]['tableName'] . "].[" . $dataTabDetail[$j][$i]['columnName'] . "],\n";
                        } else {
                            $mssqlReadInsideStatement .= "                    [" . $dataTabDetail[$j][0]['tableName'] . "].[" . $dataTabDetail[$j][$i]['columnName'] . "],\n";
                        }
                    }
                    $mssqlReadStatement .= $mssqlReadInsideStatement;
                    $mssqlReadStatement .= "                    [staff].[staffName] \n";
                    $mssqlReadStatement .= "\t\t  FROM \t[" . $dataTabDetail[$j][0]['tableName'] . "]\n";
                    $mssqlReadStatement .= "\t\t  JOIN\t[staff]\n";
                    $mssqlReadStatement .= "\t\t  ON\t[" . $dataTabDetail[$j][0]['tableName'] . "].[executeBy] = [staff].[staffId]\n";
                    if ($foreignKeyYes == 1) {
                        for ($i = 0; $i < $total; $i++) {
                            if ($dataTabDetail[$j][$i]['foreignKey'] == 1 && $dataTabDetail[$j][$i]['Key'] == 'MUL') {
                                // assume in the same package also
                                $mssqlReadStatement .= "\tJOIN\t[" . str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "]\n";
                                $mssqlReadStatement .= "\tON\t\t[" . str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "].[" . $dataTabDetail[$j][$i]['columnName'] . "] = [" . $dataTabDetail[$j][0]['tableName'] . "].[" . $dataTabDetail[$j][$i]['columnName'] . "]\n";
                            }
                        }
                    }
                    $mssqlReadStatement .= "\t\t  WHERE    [companyId]='\".\$this->getCompanyId().\"'  AND [" . str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName']) . "LineNumber] = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LineNumber(0, 'single') . \"' \";  \n";
                    $str .= $mssqlReadStatement;
                    $str .= "       if (\$this->model->get" . ucfirst($dataTabDetail[$j][0]['primaryKeyName']) . "(0, 'single')) { \n";
                    $str .= "           \$sql .= \" AND [" . $dataTabDetail[$j][0]['tableName'] . "].[\" . \$this->model->getPrimaryKeyName() . \"]\t\t=\t'\" . \$this->model->get" . ucfirst($dataTabDetail[$j][0]['primaryKeyName']) . "(0, 'single') . \"'\"; \n";
                    $str .= "       } \n";
                    $str .= "\t\t} else if (\$this->getVendor() == self::ORACLE) {  \n";
                    $oracleReadStatement = null;
                    $oracleReadInsideStatement = null;
                    $oracleReadStatement .= "\n\t\t  \$sql = \"\n\t\t  SELECT";
                    for ($i = 0; $i < $total; $i++) {
                        if ($dataTabDetail[$j][$i]['foreignKey'] == 1 && $dataTabDetail[$j][$i]['Key'] == 'MUL') {
                            //exception for some cases
                            if ($dataTabDetail[$j][$i]['columnName'] == 'businessPartnerId') {
                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Company";
                            } else {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'employeeId') {
                                    $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "FirstName";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'staffId') {
                                        $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] == 'chartOfAccountId') {
                                            $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Title";
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] == 'assetId') {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Name";
                                            } else {
                                                $field = str_replace("Id", "", $dataTabDetail[$j][$i]['columnName']) . "Description";
                                            }
                                        }
                                    }
                                }
                            }
                            $oracleReadInsideStatement .= "                    " . strtoupper(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "." . strtoupper($field) . " AS  \\\"" . $field . "\\\",\n";
                            $oracleReadInsideStatement .= "                    " . strtoupper($dataTabDetail[$j][0]['tableName']) . "." . strtoupper($dataTabDetail[$j][$i]['columnName']) . " AS \\\"" . $dataTabDetail[$j][$i]['columnName'] . "\\\",\n";
                        } else {
                            $oracleReadInsideStatement .= "                    " . strtoupper($dataTabDetail[$j][0]['tableName']) . "." . strtoupper($dataTabDetail[$j][$i]['columnName']) . " AS \\\"" . $dataTabDetail[$j][$i]['columnName'] . "\\\",\n";
                        }
                    }
                    $oracleReadStatement .= $oracleReadInsideStatement;
                    $oracleReadStatement .= "                    STAFF.STAFFNAME AS \\\"staffName\\\" \n";
                    $oracleReadStatement .= "\t\t  FROM \t" . strtoupper($dataTabDetail[$j][0]['tableName']) . " \n";
                    $oracleReadStatement .= "\t\t  JOIN\tSTAFF \n";
                    $oracleReadStatement .= "\t\t  ON\t" . strtoupper($dataTabDetail[$j][0]['tableName']) . ".EXECUTEBY = STAFF.STAFFID \n ";
                    $oracleReadStatement .= "         WHERE     COMPANYID='\".\$this->getCompanyId().\"'  AND " . strtoupper(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LINENUMBER = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LineNumber(" . $i . ") . \"' \";\n";
                    $str .= $oracleReadStatement;
                    $str .= "\t\t} \n";
                    $str .= "           try {\n";
                    $str .= "               \$this->q->read(\$sql);\n";
                    $str .= "           } catch (\\Exception \$e) {\n";
                    $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                    $str .= "               exit();\n";
                    $str .= "           }\n";
                    $str .= "\t\t\$items = array(); \n";
                    $str .= "           \$i = 1; \n";
                    $str .= "\t\twhile ((\$row = \$this->q->fetchAssoc()) == TRUE) { \n";
                    $str .= "               \$items [] = \$row; \n";
                    $str .= "               \$i++; \n";
                    $str .= "\t\t}  \n";
                    $str .= "  \t\treturn \$items;\n";
                    $str .= "     }\n";
                    $str .= "    /**\n";
                    $str .= "     * Update\n";
                    $str .= "     * @see config::update()\n";
                    $str .= "     * @return void\n";
                    $str .= "     */ \n";
                    $str .= "     public function update() {\n";
                    $str .= "       if (\$this->getVendor() == self::MYSQL) { \n";
                    $str .= "           \$sql = \"SET NAMES utf8\"; \n";
                    $str .= "           try {\n";
                    $str .= "               \$this->q->fast(\$sql);\n";
                    $str .= "           } catch (\\Exception \$e) {\n";
                    $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                    $str .= "               exit();\n";
                    $str .= "           }\n";
                    $str .= "       } \n";
                    $str .= "       \$this->q->start(); \n";
                    $str .= "       \$this->model->update(); \n";
                    $str .= "       // before updating check the id exist or not . if exist continue to update else warning the user \n";
                    $str .= "       \$sql=null;\n";
                    if ($dataTabDetail[$j][0]['foreignKeyYes'] == 1) {
                        for ($i = 0; $i < $total; $i++) {
                            if ($dataTabDetail[$j][$i]['Key'] == 'MUL' && $dataTabDetail[$j][$i]['columnName'] != 'companyId') {
                                $str .= "       if(!\$this->model->get" . ucfirst($dataTabDetail[$j][$i]['columnName']) . "()){\n";
                                $str .= "           \$this->model->set" . ucfirst($dataTabDetail[$j][$i]['columnName']) . "(\$this->service->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][$i]['columnName'])) . "DefaultValue());\n";
                                $str .= "       }\n";
                            }
                        }
                    }
                    for ($t = 1; $t <= $dataTabDetail[$j][0]['targetMaximumTabRecord']; $t++) {
                        $str .= "           if (\$this->getVendor() == self::MYSQL) { \n";
                        $mysqlUpdateStatementInsideValue = null;
                        $mysqlUpdateStatementValue = null;
                        $mysqlUpdateStatement = "               \$sql=\"\n";
                        $mysqlUpdateStatement .= "               UPDATE `" . strtolower($dataTabDetail[$j][0]['tableName']) . "`\n";
                        $mysqlUpdateStatement .= "               SET ";
                        for ($i = 0; $i < $total; $i++) {
                            if ($i >= 1) {
                                if ($dataTabDetail[$j][$i]['columnName'] != $data[0]['primaryKeyName']) {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'companyId') {
                                        //  $mysqlUpdateStatementInsideValue .= "                       `" . $dataTabDetail [$j][$i] ['columnName'] . "` = \".\$_SESSION['companyId'].\",\n";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] == 'executeBy') {
                                            $mysqlUpdateStatementInsideValue .= "                       `" . $dataTabDetail[$j][$i]['columnName'] . "` = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] != 'isDefault' && $dataTabDetail[$j][$i]['columnName'] != 'isNew' && $dataTabDetail[$j][$i]['columnName'] != 'isDraft' && $dataTabDetail[$j][$i]['columnName'] != 'isUpdate' && $dataTabDetail[$j][$i]['columnName'] != 'isDelete' && $dataTabDetail[$j][$i]['columnName'] != 'isActive' && $dataTabDetail[$j][$i]['columnName'] != 'isApproved' && $dataTabDetail[$j][$i]['columnName'] != 'isReview' && $dataTabDetail[$j][$i]['columnName'] != 'isPost' && $dataTabDetail[$j][$i]['columnName'] != 'isSlice' && $dataTabDetail[$j][$i]['columnName'] != 'isConsolidation' && $dataTabDetail[$j][$i]['columnName'] != 'isReconciled' && $dataTabDetail[$j][$i]['columnName'] != 'executeBy' && $dataTabDetail[$j][$i]['columnName'] != 'executeTime') {
                                                $mysqlUpdateStatementInsideValue .= "                       `" . $dataTabDetail[$j][$i]['columnName'] . "` = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(" . $t . ").\"',\n";
                                            } else {
                                                if ($dataTabDetail[$j][$i]['columnName'] == 'executeTime') {
                                                    $mysqlUpdateStatementInsideValue .= "                       `" . $dataTabDetail[$j][$i]['columnName'] . "` = \".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\",\n";
                                                } else {
                                                    $mysqlUpdateStatementInsideValue .= "                       `" . $dataTabDetail[$j][$i]['columnName'] . "` = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "('0','single').\"',\n";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $mysqlUpdateStatementValue .= substr($mysqlUpdateStatementInsideValue, 0, -2);
                        $mysqlUpdateStatement .= $mysqlUpdateStatementValue;
                        $mysqlUpdateStatement .= "\n               WHERE    `companyId` ='\".\$this->getCompanyId().\"'\n";
                        $mysqlUpdateStatement .= "AND \t   `" . str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName']) . "LineNumber` = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LineNumber(" . $t . ") . \"' \";\n";
                        $str .= $mysqlUpdateStatement;
                        $str .= "           } else if (\$this->getVendor() == self::MSSQL) {  \n";
                        $mssqlUpdateStatementInsideValue = null;
                        $mssqlUpdateStatementValue = null;
                        $mssqlUpdateStatement = "                \$sql=\"\n";
                        $mssqlUpdateStatement .= "                UPDATE [" . $dataTabDetail[$j][0]['tableName'] . "] SET \n";
                        for ($i = 0; $i < $total; $i++) {
                            if ($i >= 1) {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'companyId') {
                                    //   $mssqlUpdateStatementInsideValue .= "                       [" . $dataTabDetail [$j][$i] ['columnName'] . "] = \".\$_SESSION['companyId'].\",\n";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'executeBy') {
                                        $mssqlUpdateStatementInsideValue .= "                       [" . $dataTabDetail[$j][$i]['columnName'] . "] = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] != 'isDefault' && $dataTabDetail[$j][$i]['columnName'] != 'isNew' && $dataTabDetail[$j][$i]['columnName'] != 'isDraft' && $dataTabDetail[$j][$i]['columnName'] != 'isUpdate' && $dataTabDetail[$j][$i]['columnName'] != 'isDelete' && $dataTabDetail[$j][$i]['columnName'] != 'isActive' && $dataTabDetail[$j][$i]['columnName'] != 'isApproved' && $dataTabDetail[$j][$i]['columnName'] != 'isReview' && $dataTabDetail[$j][$i]['columnName'] != 'isPost' && $dataTabDetail[$j][$i]['columnName'] != 'isSlice' && $dataTabDetail[$j][$i]['columnName'] != 'isConsolidation' && $dataTabDetail[$j][$i]['columnName'] != 'isReconciled' && $dataTabDetail[$j][$i]['columnName'] != 'executeBy' && $dataTabDetail[$j][$i]['columnName'] != 'executeTime') {
                                            $mssqlUpdateStatementInsideValue .= "                       [" . $dataTabDetail[$j][$i]['columnName'] . "] = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(" . $t . ").\"',\n";
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] == 'executeTime') {
                                                $mssqlUpdateStatementInsideValue .= "                       [" . $dataTabDetail[$j][$i]['columnName'] . "] = \".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\",\n";
                                            } else {
                                                $mssqlUpdateStatementInsideValue .= "                       [" . $dataTabDetail[$j][$i]['columnName'] . "] = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(0, 'single').\"',\n";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $mssqlUpdateStatementValue .= substr($mssqlUpdateStatementInsideValue, 0, -2);
                        $mssqlUpdateStatement .= $mssqlUpdateStatementValue;
                        $mssqlUpdateStatement .= "\n                WHERE  [companyId]='\".\$this->getCompanyId().\"'  AND [" . str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName']) . "LineNumber] = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LineNumber(" . $t . ") . \"' \"; \n";
                        $str .= $mssqlUpdateStatement;
                        $str .= "           } else if (\$this->getVendor() == self::ORACLE) {  \n";
                        $oracleUpdateStatementInsideValue = null;
                        $oracleUpdateStatementValue = null;
                        $oracleUpdateStatement = "                \$sql=\"\n";
                        $oracleUpdateStatement .= "                UPDATE " . strtoupper($dataTabDetail[$j][0]['tableName']) . " SET\n ";
                        for ($i = 0; $i < $total; $i++) {
                            if ($i >= 1) {
                                if ($dataTabDetail[$j][$i]['columnName'] == 'companyId') {
                                    //       $oracleUpdateStatementInsideValue .= "                       " . strtoupper($dataTabDetail [$j][$i] ['columnName']) . " = '\".\$_SESSION['companyId'].\"',\n";
                                } else {
                                    if ($dataTabDetail[$j][$i]['columnName'] == 'executeBy') {
                                        $oracleUpdateStatementInsideValue .= "                       " . strtoupper($dataTabDetail[$j][$i]['columnName']) . " = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\"',\n";
                                    } else {
                                        if ($dataTabDetail[$j][$i]['columnName'] != 'isDefault' && $dataTabDetail[$j][$i]['columnName'] != 'isNew' && $dataTabDetail[$j][$i]['columnName'] != 'isDraft' && $dataTabDetail[$j][$i]['columnName'] != 'isUpdate' && $dataTabDetail[$j][$i]['columnName'] != 'isDelete' && $dataTabDetail[$j][$i]['columnName'] != 'isActive' && $dataTabDetail[$j][$i]['columnName'] != 'isApproved' && $dataTabDetail[$j][$i]['columnName'] != 'isReview' && $dataTabDetail[$j][$i]['columnName'] != 'isPost' && $dataTabDetail[$j][$i]['columnName'] != 'isSlice' && $dataTabDetail[$j][$i]['columnName'] != 'isConsolidation' && $dataTabDetail[$j][$i]['columnName'] != 'isReconciled' && $dataTabDetail[$j][$i]['columnName'] != 'executeBy' && $dataTabDetail[$j][$i]['columnName'] != 'executeTime') {
                                            $oracleUpdateStatementInsideValue .= "                       " . strtoupper($dataTabDetail[$j][$i]['columnName']) . " = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(" . $t . ").\"',\n";
                                        } else {
                                            if ($dataTabDetail[$j][$i]['columnName'] == 'executeTime') {
                                                $oracleUpdateStatementInsideValue .= "                       " . strtoupper($dataTabDetail[$j][$i]['columnName']) . " = \".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "().\",\n";
                                            } else {
                                                $oracleUpdateStatementInsideValue .= "                       " . strtoupper($dataTabDetail[$j][$i]['columnName']) . " = '\".\$this->model->get" . ucFirst($dataTabDetail[$j][$i]['columnName']) . "(0, 'single').\"',\n";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $oracleUpdateStatementValue .= substr($oracleUpdateStatementInsideValue, 0, -2);
                        $oracleUpdateStatement .= $oracleUpdateStatementValue;
                        $oracleUpdateStatement .= "\n              WHERE COMPANYID='\".\$this->getCompanyId().\"'  AND " . strtoupper(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LINENUMBER = '\" . \$this->model->get" . ucfirst(str_replace("Id", "", $dataTabDetail[$j][0]['primaryKeyName'])) . "LineNumber(" . $t . ") . \"' \"; \n";
                        $str .= $oracleUpdateStatement;
                        $str .= "           } \n";
                        $str .= "           try {\n";
                        $str .= "               \$this->q->update(\$sql);\n";
                        $str .= "           } catch (\\Exception \$e) {\n";
                        $str .= "               \$this->q->rollback();\n";
                        $str .= "               echo json_encode(array(\"success\" => false, \"message\" => \$e->getMessage()));\n";
                        $str .= "               exit();\n";
                        $str .= "           }\n";
                    }
                    $str .= "     }\n";
                    $str .= "    /**\n";
                    $str .= "     * Delete\n";
                    $str .= "     * @see config::delete()\n";
                    $str .= "     * @return void\n";
                    $str .= "     */\n";
                    $str .= "     public function delete() {\n";
                    $str .= "     }\n";
                    $str .= "    /**\n";
                    $str .= "     * Reporting\n";
                    $str .= "     * @see config::excel()\n";
                    $str .= "     * @return void\n";
                    $str .= "     */\n";
                    $str .= "     public function excel() {\n";
                    $str .= "     }\n";
                    $str .= " } \n";
                }
            }
        }
    }
    $str .= "?>";
    return $str;
}
Exemple #15
0
        foreach ((array) $val as $restArray) {
            //			echo '<pre>';
            //			print_r($restArray);
            //			echo '</pre>';
            //			if (checkString($restArray->{'id'})) echo $restArray->{'id'} . "\t";
            $image_url = checkString($restArray->{'image_url'}->{'shop_image1'}) ? (string) $restArray->{'image_url'}->{'shop_image1'} : '';
            if ($image_url == "") {
                continue;
            }
            $result[$i]['restaurant_name'] = checkString($restArray->{'name'}) ? $restArray->{'name'} : '';
            $result[$i]['restaurant_access'] = checkString($restArray->{'access'}->{'line'}) ? (string) $restArray->{'access'}->{'line'} . $restArray->{'access'}->{'station'} : '';
            $result[$i]['restaurant_image'] = $image_url;
            //			if (checkString($restArray->{'access'}->{'station'})) echo (string)$restArray->{'access'}->{'station'} . "\t";
            //			if (checkString($restArray->{'access'}->{'walk'})) echo (string)$restArray->{'access'}->{'walk'} . "分\t";
            foreach ((array) $restArray->{'code'}->{'category_name_s'} as $v) {
                $result[$i]['restaurant_category'] = checkString($v) ? $v : '';
            }
            //			echo "\n";
            $i++;
        }
    }
}
// debug
//echo '<pre>';
//print_r($result);
//echo '</pre>';
$data = json_encode($result);
header('Access-Control-Allow-Origin: *');
header("Content-Type: application/json; charset=utf-8");
echo "[" . $data . "]";
//文字列であるかをチェック
if ($emails) {
    $output = '';
    rsort($emails);
    foreach ($emails as $email_number) {
        $overview = imap_fetch_overview($inbox, $email_number, 0);
        $message = imap_fetchbody($inbox, $email_number, 2);
        $output .= '<div class="body">' . $message . "</div>";
    }
    //echo $output;
}
imap_close($inbox);
/////////////////////////////////////////////////////////////////////////////////
// Function for checking for spam
function checkString($this)
{
    //filter for the spam list
    $filter_list = array();
    array_push($filter_list, "email", "computer", "microsoft", "windows");
    //for each list to go through array and find strings within the strings
    foreach ($filter_list as $key) {
        //this to search through the string and find the keywords
        if (strpos($this, $key) !== false) {
            header('Location: http://localhost/objects/result_bad.html');
        } else {
            header('Location: http://localhost/objects/result_good.html');
        }
    }
}
// $string = "This is totally spam";
checkString($output);
Exemple #17
0
function modelSourceCode($data)
{
    if (isset($data) && is_array($data)) {
        // think this more accurate
        $total = 0;
        $total = count($data);
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['Key'] == 'PRI') {
                $data[0]['tableName'] = str_replace('Id', '', $data[0]['columnName']);
            }
        }
        $str .= "<?php  namespace Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Model;\n";
        $str .= " use Core\\Validation\\ValidationClass;\n";
        $str .= "\$x = addslashes(realpath(__FILE__));\n";
        $str .= "// auto detect if \\ consider come from windows else / from linux\n";
        $str .= "\$pos = strpos(\$x, \"\\\\\");\n";
        $str .= "if (\$pos !== false) {\n";
        $str .= "    \$d = explode(\"\\\\\", \$x);\n";
        $str .= "} else {  \n";
        $str .= "    \$d = explode(\"/\", \$x);\n";
        $str .= "}\n";
        $str .= "\$newPath = null;\n";
        $str .= "for (\$i = 0; \$i < count(\$d); \$i ++) {\n";
        $str .= "    // if find the library or package then stop\n";
        $str .= "    if (\$d[\$i] == 'library' || \$d[\$i] == 'v3') {\n";
        $str .= "        break;\n";
        $str .= "    }\n";
        $str .= "    \$newPath[] .= \$d[\$i] . \"/\";\n";
        $str .= "}\n";
        $str .= "\$fakeDocumentRoot = null;\n";
        $str .= "for (\$z = 0; \$z < count(\$newPath); \$z ++) {\n";
        $str .= "    \$fakeDocumentRoot .= \$newPath[\$z];\n";
        $str .= "}\n";
        $str .= "\$newFakeDocumentRoot = str_replace(\"//\", \"/\", \$fakeDocumentRoot); // start\n";
        $str .= "require_once (\$newFakeDocumentRoot.\"library/class/classValidation.php\"); \n";
        $str .= "/** \n";
        $str .= " * Class " . ucfirst($data[0]['tableName']) . "\n";
        $str .= " * This is " . $data[0]['tableName'] . " model file.This is to ensure strict setting enable for all variable enter to database \n";
        $str .= " * \n";
        $str .= " * @name IDCMS.\n";
        $str .= " * @version 2\n";
        $str .= " * @author hafizan\n";
        $str .= " * @package Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucwords($data[0]['tableName']) . "\\Model;\n";
        $str .= " * @subpackage " . ucwords($data[0]['module']) . " \n";
        $str .= " * @link http://www.hafizan.com\n";
        $str .= " * @license http://www.gnu.org/copyleft/lesser.html LGPL\n";
        $str .= " */\n";
        $str .= "class " . ucfirst($data[0]['tableName']) . "Model extends ValidationClass { \n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                $x = str_replace($data[0]['tableName'], '', $data[$i]['columnName']);
                if ($x == 'Desc') {
                    $x = "Description";
                } else {
                    if ($x == 'Id') {
                        $x = "Primary Key";
                    } else {
                        $findMe = 'Id';
                        $pos = strpos($x, $findMe);
                        // mostly it was a foreign key
                        if ($pos !== false) {
                            $x = ucfirst(str_replace("Id", "", $x));
                        } else {
                        }
                    }
                }
                $str .= " /**\n";
                $str .= "  * " . checkString($x) . "\n";
                $str .= "  * @var " . $data[$i]['field'] . " \n";
                $str .= "  */\n";
                $str .= "  private \$" . $data[$i]['columnName'] . "; \n";
            }
        }
        $str .= " /**\n";
        $str .= "  * Class Loader\n";
        $str .= "  * @see ValidationClass::execute()\n";
        $str .= "  */\n";
        $str .= " public function execute() {\n";
        $str .= "     /**\n";
        $str .= "     *  Basic Information Table\n";
        $str .= "     **/\n";
        $str .= "     \$this->setTableName('" . $data[0]['tableName'] . "');\n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['Key'] == 'PRI') {
                $str .= "     \$this->setPrimaryKeyName('" . $data[$i]['columnName'] . "');\n";
                $str .= "     \$this->setMasterForeignKeyName('" . $data[$i]['columnName'] . "');\n";
            }
        }
        $str .= "     \$this->setFilterCharacter('" . $data[0]['tableName'] . "Description');\n";
        $str .= "     //\$this->setFilterCharacter('" . $data[0]['tableName'] . "Note');\n";
        $str .= "     \$this->setFilterDate('executeTime');\n";
        $str .= "     /**\n";
        $str .= "     * All the \$_POST Environment\n";
        $str .= "     */ \n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                if ($data[$i]['Key'] == 'PRI') {
                    $str .= "     if (isset(\$_POST ['" . $data[$i]['columnName'] . "'])) { \n ";
                    $str .= "         \$this->set" . ucfirst($data[$i]['columnName']) . "(\$this->strict(\$_POST ['" . $data[$i]['columnName'] . "'], '" . $data[$i]['field'] . "'), 0, 'single'); \n ";
                    $str .= "     } \n ";
                } else {
                    $str .= "     if (isset(\$_POST ['" . $data[$i]['columnName'] . "'])) { \n ";
                    $str .= "         \$this->set" . ucfirst($data[$i]['columnName']) . "(\$this->strict(\$_POST ['" . $data[$i]['columnName'] . "'], '" . $data[$i]['field'] . "')); \n ";
                    $str .= "     } \n ";
                }
            }
        }
        $str .= "     /**\n";
        $str .= "     * All the \$_GET Environment\n";
        $str .= "     */\n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime') {
                if ($data[$i]['Key'] == 'PRI') {
                    $str .= "     if (isset(\$_GET ['" . $data[$i]['columnName'] . "'])) { \n ";
                    $str .= "         \$this->set" . ucfirst($data[$i]['columnName']) . "(\$this->strict(\$_GET ['" . $data[$i]['columnName'] . "'], '" . $data[$i]['field'] . "'), 0, 'single'); \n ";
                    $str .= "     } \n ";
                } else {
                    $str .= "     if (isset(\$_GET ['" . $data[$i]['columnName'] . "'])) { \n ";
                    $str .= "         \$this->set" . ucfirst($data[$i]['columnName']) . "(\$this->strict(\$_GET ['" . $data[$i]['columnName'] . "'], '" . $data[$i]['field'] . "')); \n ";
                    $str .= "     } \n ";
                }
            }
        }
        for ($i = 0; $i < $total; $i++) {
            $str .= "     if (isset(\$_GET ['" . $data[$i]['columnName'] . "'])) {\n";
            if ($data[$i]['Key'] == 'PRI') {
                $str .= "         \$this->setTotal(count(\$_GET ['" . $data[$i]['columnName'] . "']));\n";
            }
            $str .= "         if (is_array(\$_GET ['" . $data[$i]['columnName'] . "'])) {\n";
            $str .= "             \$this->" . $data[$i]['columnName'] . " = array();\n";
            $str .= "         }\n";
            $str .= "\t}\n";
        }
        $str .= "\tif (isset(\$_GET ['isDefault'])) {\n";
        $str .= "         \$this->setIsDefaultTotal(count(\$_GET['isDefault']));\n";
        $str .= "         if (is_array(\$_GET ['isDefault'])) {\n";
        $str .= "             \$this->isDefault = array();\n";
        $str .= "         }\n";
        $str .= "     }\n";
        $str .= "     if (isset(\$_GET ['isNew'])) {\n";
        $str .= "         \$this->setIsNewTotal(count(\$_GET['isNew']));\n";
        $str .= "         if (is_array(\$_GET ['isNew'])) {\n";
        $str .= "             \$this->isNew = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isDraft'])) {\n";
        $str .= "         \$this->setIsDraftTotal(count(\$_GET['isDraft']));\n";
        $str .= "         if (is_array(\$_GET ['isDraft'])) {\n";
        $str .= "             \$this->isDraft = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isUpdate'])) {\n";
        $str .= "         \$this->setIsUpdateTotal(count(\$_GET['isUpdate']));\n";
        $str .= "         if (is_array(\$_GET ['isUpdate'])) {\n";
        $str .= "             \$this->isUpdate = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isDelete'])) {\n";
        $str .= "         \$this->setIsDeleteTotal(count(\$_GET['isDelete']));\n";
        $str .= "         if (is_array(\$_GET ['isDelete'])) {\n";
        $str .= "             \$this->isDelete = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isActive'])) {\n";
        $str .= "         \$this->setIsActiveTotal(count(\$_GET['isActive']));\n";
        $str .= "         if (is_array(\$_GET ['isActive'])) {\n";
        $str .= "             \$this->isActive = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isApproved'])) {\n";
        $str .= "         \$this->setIsApprovedTotal(count(\$_GET['isApproved']));\n";
        $str .= "         if (is_array(\$_GET ['isApproved'])) {\n";
        $str .= "             \$this->isApproved = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isReview'])) {\n";
        $str .= "         \$this->setIsReviewTotal(count(\$_GET['isReview']));\n";
        $str .= "         if (is_array(\$_GET ['isReview'])) {\n";
        $str .= "             \$this->isReview = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\tif (isset(\$_GET ['isPost'])) {\n";
        $str .= "         \$this->setIsPostTotal(count(\$_GET['isPost']));\n";
        $str .= "         if (is_array(\$_GET ['isPost'])) {\n";
        $str .= "             \$this->isPost = array();\n";
        $str .= "         }\n";
        $str .= "\t}\n";
        $str .= "\t\$primaryKeyAll = '';\n";
        $str .= "\tfor (\$i = 0; \$i < \$this->getTotal(); \$i++) {\n";
        $str .= "         if (isset(\$_GET ['" . $data[0]['primaryKeyName'] . "'])) {\n";
        $str .= "             \$this->set" . ucfirst($data[0]['primaryKeyName']) . "(\$this->strict(\$_GET ['" . $data[0]['primaryKeyName'] . "'] [\$i], 'numeric'), \$i, 'array');\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isDefault'])) {\n";
        $str .= "             if (\$_GET ['isDefault'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsDefault(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isDefault'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsDefault(0, \$i, 'array');\n";
        $str .= "\t\t}\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isNew'])) {\n";
        $str .= "             if (\$_GET ['isNew'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsNew(1, \$i, 'array');\n";
        $str .= "\t\t} else if (\$_GET ['isNew'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsNew(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isDraft'])) {\n";
        $str .= "             if (\$_GET ['isDraft'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsDraft(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isDraft'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsDraft(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isUpdate'])) {\n";
        $str .= "             if (\$_GET ['isUpdate'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsUpdate(1, \$i, 'array');\n";
        $str .= "             } if (\$_GET ['isUpdate'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsUpdate(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isDelete'])) {\n";
        $str .= "             if (\$_GET ['isDelete'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsDelete(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isDelete'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsDelete(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isActive'])) {\n";
        $str .= "             if (\$_GET ['isActive'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsActive(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isActive'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsActive(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isApproved'])) {\n";
        $str .= "             if (\$_GET ['isApproved'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsApproved(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isApproved'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsApproved(0, \$i, 'array');\n";
        $str .= "             } \n";
        $str .= "         } \n";
        $str .= "         if (isset(\$_GET ['isReview'])) {\n";
        $str .= "             if (\$_GET ['isReview'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsReview(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isReview'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsReview(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         if (isset(\$_GET ['isPost'])) {\n";
        $str .= "             if (\$_GET ['isPost'] [\$i] == 'true') {\n";
        $str .= "                 \$this->setIsPost(1, \$i, 'array');\n";
        $str .= "             } else if (\$_GET ['isPost'] [\$i] == 'false') {\n";
        $str .= "                 \$this->setIsPost(0, \$i, 'array');\n";
        $str .= "             }\n";
        $str .= "         }\n";
        $str .= "         \$primaryKeyAll .= \$this->get" . ucfirst($data[0]['primaryKeyName']) . "(\$i, 'array') . \",\";\n";
        $str .= "     }\n";
        $str .= "     \$this->setPrimaryKeyAll((substr(\$primaryKeyAll, 0, - 1)));\n";
        $str .= "    /**\n";
        $str .= "     * All the \$_SESSION Environment\n";
        $str .= "     */\n";
        $str .= "     if (isset(\$_SESSION ['staffId'])) {\n";
        $str .= "         \$this->setExecuteBy(\$_SESSION ['staffId']);\n";
        $str .= "     }\n";
        $str .= "    /**\n";
        $str .= "     * TimeStamp Value.\n";
        $str .= "     */\n";
        $str .= "     if (\$this->getVendor() == self::MYSQL) {\n";
        $str .= "         \$this->setExecuteTime(\"'\" . date(\"Y-m-d H:i:s\") . \"'\");\n";
        $str .= "     } else if (\$this->getVendor() == self::MSSQL) {\n";
        $str .= "         \$this->setExecuteTime(\"'\" . date(\"Y-m-d H:i:s.u\") . \"'\");\n";
        $str .= "     } else if (\$this->getVendor() == self::ORACLE) {\n";
        $str .= "         \$this->setExecuteTime(\"to_date('\" . date(\"Y-m-d H:i:s\") . \"','YYYY-MM-DD HH24:MI:SS')\");\n";
        $str .= "     }\n";
        $str .= " }\n";
        $str .= "    /**\n";
        $str .= "     * Create\n";
        $str .= "     * @see ValidationClass::create()\n";
        $str .= "     * @return void\n";
        $str .= "     */ \n";
        $str .= "     public function create() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(1, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t} \n";
        $str .= "    /**\n";
        $str .= "     * Update\n";
        $str .= "     * @see ValidationClass::update()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "     public function update() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(0, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(1, '', 'single');\n";
        $str .= "         \$this->setIsActive(1, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t}\n";
        $str .= "    /** \n";
        $str .= "     * Delete\n";
        $str .= "     * @see ValidationClass::delete()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "\tpublic function delete() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(0, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, '', 'single');\n";
        $str .= "         \$this->setIsDelete(1, '', 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t} \n";
        $str .= "    /**\n";
        $str .= "     * Draft\n";
        $str .= "     * @see ValidationClass::draft()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "\tpublic function draft() {\n";
        $str .= "\t\t\$this->setIsDefault(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsNew(1, 0, 'single');\n";
        $str .= "\t\t\$this->setIsDraft(1, 0, 'single');\n";
        $str .= "\t\t\$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsActive(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsDelete(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsApproved(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsReview(0, 0, 'single');\n";
        $str .= "\t\t\$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t}\n";
        $str .= "    /**\n";
        $str .= "     * Approved\n";
        $str .= "     * @see ValidationClass::approved()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "\tpublic function approved() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(1, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t}\n";
        $str .= "    /**\n";
        $str .= "     * Review\n";
        $str .= "     * @see ValidationClass::review()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "     public function review() { \n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(0, 0, 'single');\n";
        $str .= "         \$this->setIsReview(1, 0, 'single');\n";
        $str .= "         \$this->setIsPost(0, 0, 'single');\n";
        $str .= "\t} \n";
        $str .= "    /**\n";
        $str .= "     * Post\n";
        $str .= "     * @see ValidationClass::post()\n";
        $str .= "     * @return void\n";
        $str .= "     */\n";
        $str .= "     public function post() {\n";
        $str .= "         \$this->setIsDefault(0, 0, 'single');\n";
        $str .= "         \$this->setIsNew(1, 0, 'single');\n";
        $str .= "         \$this->setIsDraft(0, 0, 'single');\n";
        $str .= "         \$this->setIsUpdate(0, 0, 'single');\n";
        $str .= "         \$this->setIsActive(0, 0, 'single');\n";
        $str .= "         \$this->setIsDelete(0, 0, 'single');\n";
        $str .= "         \$this->setIsApproved(1, 0, 'single');\n";
        $str .= "         \$this->setIsReview(0, 0, 'single');\n";
        $str .= "         \$this->setIsPost(1, 0, 'single');\n";
        $str .= "\t}\n";
        for ($i = 0; $i < $total; $i++) {
            if ($data[$i]['Key'] == 'PRI') {
                $str .= "     /** \n";
                $str .= "     * Set Primary Key Value \n";
                $str .= "     * @param int|array \$value \n";
                $str .= "     * @param array[int]int \$key List Of Primary Key. \n";
                $str .= "     * @param array[int]string \$type  List Of Type.0 As 'single' 1 As 'array' \n";
                $str .= "     * @return \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucfirst($data[0]['tableName']) . "\\Model\\" . ucfirst($data[0]['tableName']) . "Model\n";
                $str .= "     */ \n";
                $str .= "     public function set" . ucfirst($data[$i]['columnName']) . "(\$value, \$key, \$type) { \n";
                $str .= "        if (\$type == 'single') { \n";
                $str .= "           \$this->" . $data[$i]['columnName'] . " = \$value;\n";
                $str .= "           return \$this;\n";
                $str .= "        } else if (\$type == 'array') {\n";
                $str .= "            \$this->" . $data[$i]['columnName'] . "[\$key] = \$value;\n";
                $str .= "           return \$this;\n";
                $str .= "        } else {\n";
                $str .= "            echo json_encode(array(\"success\" => false, \"message\" => \"Cannot Identify Type String Or Array:set" . ucfirst($data[$i]['columnName']) . "?\"));\n";
                $str .= "            exit(); \n";
                $str .= "        }\n";
                $str .= "    }\n";
                $str .= "    /**\n";
                $str .= "     * Return Primary Key Value\n";
                $str .= "     * @param array[int]int \$key List Of Primary Key.\n";
                $str .= "     * @param array[int]string \$type  List Of Type.0 As 'single' 1 As 'array'\n";
                $str .= "     * @return bool|array|string\n";
                $str .= "     */\n";
                $str .= "    public function get" . ucfirst($data[$i]['columnName']) . "(\$key, \$type) {\n";
                $str .= "        if (\$type == 'single') {\n";
                $str .= "            return \$this->" . $data[$i]['columnName'] . ";\n";
                $str .= "        } else if (\$type == 'array') {\n";
                $str .= "            return \$this->" . $data[$i]['columnName'] . " [\$key];\n";
                $str .= "        } else {\n";
                $str .= "            echo json_encode(array(\"success\" => false, \"message\" => \"Cannot Identify Type String Or Array:get" . ucfirst($data[$i]['columnName']) . " ?\"));\n";
                $str .= "            exit();\n";
                $str .= "        }\n";
                $str .= "\t}\n";
            } else {
                if ($data[$i]['columnName'] != 'isDefault' && $data[$i]['columnName'] != 'isNew' && $data[$i]['columnName'] != 'isDraft' && $data[$i]['columnName'] != 'isUpdate' && $data[$i]['columnName'] != 'isDelete' && $data[$i]['columnName'] != 'isActive' && $data[$i]['columnName'] != 'isApproved' && $data[$i]['columnName'] != 'isReview' && $data[$i]['columnName'] != 'isPost' && $data[$i]['columnName'] != 'executeBy' && $data[$i]['columnName'] != 'executeTime' && $data[$i]['columnName'] != $data[0]['primaryKeyName']) {
                    $y = str_replace($data[0]['tableName'], '', $data[$i]['columnName']);
                    $findMe = 'Id';
                    $pos = strpos($y, $findMe);
                    // mostly it was a foreign key
                    if ($pos !== false) {
                        $y = ucfirst(str_replace("Id", "", $y));
                    }
                    if ($y == 'Desc') {
                        $y = 'Description';
                    }
                    // $y = $this->checkString($y);
                    $str .= "\t/**\n";
                    $str .= "\t * To Return " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " \n";
                    $str .= "\t * @return " . $data[$i]['field'] . " \$" . $data[$i]['columnName'] . "\n";
                    $str .= "\t */ \n";
                    $str .= "\tpublic function get" . ucfirst($data[$i]['columnName']) . "()\n";
                    $str .= "\t{\n";
                    $str .= "\t    return \$this->" . $data[$i]['columnName'] . ";\n";
                    $str .= "\t}\n";
                    $str .= "\t/**\n";
                    $str .= "\t * To Set " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " \n";
                    $str .= "\t * @param " . $data[$i]['field'] . " \$" . $data[$i]['columnName'] . " " . checkString(str_replace($data[0]['tableName'], "", str_replace("Id", "", $data[$i]['columnName']))) . " \n";
                    $str .= "\t * @return \\Core\\" . ucwords($data[0]['package']) . "\\" . ucwords($data[0]['module']) . "\\" . ucfirst($data[0]['tableName']) . "\\Model\\" . ucfirst($data[0]['tableName']) . "Model\n";
                    $str .= "\t */\n";
                    $str .= "\tpublic function set" . ucfirst($data[$i]['columnName']) . "(\$" . $data[$i]['columnName'] . ")\n";
                    $str .= "\t{\n";
                    $str .= "         \$this->" . $data[$i]['columnName'] . " = \$" . $data[$i]['columnName'] . ";\n";
                    $str .= "         return \$this;\n";
                    $str .= "\t} \n";
                }
            }
        }
        $str .= "}\n";
        $str .= "?>";
    }
    return $str;
}
Exemple #18
0
$steps->Then('/^(STDOUT|STDERR) should not be empty$/', function ($world, $stream) {
    if ('' === rtrim($world->result->{$stream}, "\n")) {
        throw new Exception($world->result);
    }
});
$steps->Then('/^the (.+) file should (exist|not exist|be:|contain:|not contain:)$/', function ($world, $path, $action, $expected = null) {
    $path = $world->replace_variables($path);
    // If it's a relative path, make it relative to the current test dir
    if ('/' !== $path[0]) {
        $path = $world->variables['RUN_DIR'] . "/{$path}";
    }
    switch ($action) {
        case 'exist':
            if (!file_exists($path)) {
                throw new Exception($world->result);
            }
            break;
        case 'not exist':
            if (file_exists($path)) {
                throw new Exception($world->result);
            }
            break;
        default:
            if (!file_exists($path)) {
                throw new Exception("{$path} doesn't exist.");
            }
            $action = substr($action, 0, -1);
            $expected = $world->replace_variables((string) $expected);
            checkString(file_get_contents($path), $expected, $action);
    }
});
Exemple #19
0
     goBack('Shipping Address: City');
     return false;
 }
 if (!(isset($_POST['state']) && checkState($_POST['state']))) {
     goBack('Shipping Address: State');
     return false;
 }
 if (!(isset($_POST['zip']) && checkZip($_POST['zip']))) {
     goBack('Shipping Address: Zip');
     return false;
 }
 if (isset($_POST['favorite_cheese']) && strlen($_POST['favorite_cheese']) && !checkString($_POST['favorite_cheese'], 20)) {
     goBack('Favorite Cheese');
     return false;
 }
 if (isset($_POST['source']) && strlen($_POST['source']) && !checkString($_POST['source'], 60)) {
     goBack('Where did you hear about us?');
     return false;
 }
 $custom_fields = array($is_gift = isset($_POST['is_gift']) ? 'yes' : 'no', $age = $_POST['age'], $gender = $_POST['gender'], $favorite_cheese = isset($_POST['favorite_cheese']) ? $_POST['favorite_cheese'] : '', $billing_first_name = $_POST['billing_first_name'], $billing_last_name = $_POST['billing_last_name'], $billing_address1 = $_POST['billing_address1'], $billing_address2 = isset($_POST['billing_address2']) ? $_POST['billing_address2'] : '', $billing_city = $_POST['billing_city'], $billing_state = $_POST['billing_state'], $billing_zip = $_POST['billing_zip'], $source = isset($_POST['source']) ? $_POST['source'] : '');
 $custom_string = implode('|', $custom_fields);
 $all_fields = array();
 $all_fields['first_name'] = $_POST['first_name'];
 $all_fields['last_name'] = $_POST['last_name'];
 $all_fields['address1'] = $_POST['address1'];
 $all_fields['address2'] = $_POST['address2'];
 $all_fields['city'] = $_POST['city'];
 $all_fields['state'] = $_POST['state'];
 $all_fields['zip'] = $_POST['zip'];
 $all_fields['email'] = $_POST['email'];
 $all_fields['night_phone_a'] = $_POST['night_phone_a'];
Exemple #20
0
     // № текущей страницы
     $c['ob'] = checkRequest("ob");
     // order_by
     $c['od'] = checkRequest("od");
     // order_desc
     // Сортировка по умолчанию
     if (strlen($c['ob']) < 1) {
         $c['ob'] = $default_order;
         $c['od'] = 0;
     }
 }
 switch ($stage) {
     // Поисковая выдача
     case "search":
         // Автопереход заявку #id
         if ($c['search'] == checkString($c['search'])) {
             if (getListRowCount('{"id":"' . $c['search'] . '"}') == 1) {
                 $template = 'helpdesk/ticket_edit.twig';
                 $c['id'] = $c['search'];
                 header("Location: ./?stage=edit&id=" . $c['id']);
             }
         }
         $c['pagename'] = 'Поиск "' . $c['search'] . '" :: Задачник';
         //            $c['r']   = $CNF["rows_in_page"];
         $row_count = getSearchListRowCount($c['search']);
         $row_count2 = getSearchListRowCount(switchLayout($c['search']));
         if ($row_count2 > $row_count) {
             $c['changedSearchText'] = switchLayout($c['search']);
         }
         //
         $c['row_count'] = getSearchListRowCount($c['search']);
Exemple #21
0
                if (checkString($restArray->{'access'}->{'line'})) {
                    echo '<small class="small_c">[' . (string) $restArray->{'access'}->{'line'} . "\t";
                }
                if (checkString($restArray->{'access'}->{'station'})) {
                    echo (string) $restArray->{'access'}->{'station'} . "\t";
                }
                if (checkString($restArray->{'access'}->{'walk'})) {
                    echo (string) $restArray->{'access'}->{'walk'} . "分]</small><br>";
                }
                if (checkString($restArray->{'opentime'})) {
                    echo '<small>【営業時間】' . $restArray->{'opentime'} . '<br>';
                }
                if (checkString($restArray->{'holiday'})) {
                    echo '【休み】' . $restArray->{'holiday'} . '</small><br>';
                }
                if (checkString($restArray->{'tel'})) {
                    echo '<small><span class="glyphicon glyphicon-earphone" aria-hidden="true"></span></small> ' . $restArray->{'tel'} . "</p>";
                }
                echo '</div></div></a></div>';
            }
        }
    }
}
//文字列であるかをチェック
function checkString($input)
{
    if (isset($input) && is_string($input)) {
        return true;
    } else {
        return false;
    }
Exemple #22
0
    switch ($action) {
        case 'exist':
            if (!$test($path)) {
                throw new Exception($world->result);
            }
            break;
        case 'not exist':
            if ($test($path)) {
                throw new Exception($world->result);
            }
            break;
        default:
            if (!$test($path)) {
                throw new Exception("{$path} doesn't exist.");
            }
            $action = substr($action, 0, -1);
            $expected = $world->replace_variables((string) $expected);
            if ('file' == $type) {
                $contents = file_get_contents($path);
            } else {
                if ('directory' == $type) {
                    $files = glob(rtrim($path, '/') . '/*');
                    foreach ($files as &$file) {
                        $file = str_replace($path . '/', '', $file);
                    }
                    $contents = implode(PHP_EOL, $files);
                }
            }
            checkString($contents, $expected, $action);
    }
});
Exemple #23
0
function checkRequest($str, $default = false)
{
    $result = isset($_REQUEST[$str]) ? checkString($_REQUEST[$str]) : $default;
    return $result;
}
Exemple #24
0
        $response = errorResponse("The user id provided is not valid");
    }
} else {
    if ($module_id) {
        if (checkId($module_id)) {
            $response = moduleByModuleId($module_id);
        } else {
            $response = errorResponse("The module id provided is not valid");
        }
    } else {
        if ($new_module) {
            $user_id = intval($_POST['user_id']);
            $module_id = intval($_POST['module_id']);
            $progress = checkString($_POST['progress']);
            $is_complete = checkString($_POST['is_complete']);
            $date_completed = checkString($_POST['date_completed']);
            if (checkId($user_id) && checkId($module_id)) {
                $response = moduleUserProgress($user_id, $module_id, $progress, $is_complete, $date_completed);
            }
        } else {
            $response = allModules($user_id);
        }
    }
}
echo $response;
function moduleByUserId($user_id)
{
    $result = getModuleByUserId($user_id);
    return formJson($result, "progress", 0);
}
function getModuleByUserId($user_id)
Exemple #25
0
    echo $_POST['start_number'];
}
?>
"
                        >
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="submit" value="Submit" name="submit">
                    </td>
                </tr>
            </table>
        </form>
        
        <div class="resultBox">
            <h3><u>Result :</u></h3>
            <p>
                <?php 
if (isset($start_number)) {
    //echo $data;
    echo checkString($start_number);
}
?>
            </p>
        </div>
    </div>
</body>
</html>
Exemple #26
0
$output = '<rss version="2.0">';
$output .= '<channel>';
$output .= '<title>HouseMD</title>';
$output .= '<description>RSS feed for most recent ' . $rssType . "'s</description>";
$output .= '<link>http://cems.uwe.ac.uk/~dj2-foley</link>';
$output .= '<copyright>Daniel Foley, Daniel Hamilton, Stuart Gray</copyright>';
//file_get_contents('database_script/album_review/' . $array[$startPoint]['album_review'])
//This is the main dynamic bit, temporary data for now
for ($i = 0; $i < $size; $i++) {
    $description = "Track";
    if ($rssType == "album") {
        $description = uwe_file_get_contents($DATABASE_SCRIPT_DIR . $DS_ALBUM_REVIEW_DIR . $array[$i]['review_file']);
    }
    //BODY OF RSS FEED
    $output .= '<item>';
    $output .= "<title>" . checkString($array[$i][$rssType . $fieldName]) . "</title>";
    $output .= '<description>' . $description . '</description>';
    $output .= '<link>http://cems.uwe.ac.uk/~dj2-foley/tracklist.php?album=' . urlencode($array[$i][$rssType . $fieldName]) . '</link>';
    $output .= '</item> ';
}
//CLOSE RSS FEED
$output .= '</channel>';
$output .= '</rss>';
//SEND COMPLETE RSS FEED TO BROWSER
echo $output;
// Function for removing illegal characters //
function checkString($inputString)
{
    $inputString = str_replace("&", "and", $inputString);
    $inputString = str_replace("<", " ", $inputString);
    $inputString = str_replace(">", " ", $inputString);