Example #1
0
function sql($sql, $type = "query", $fetchmode = 'default')
{
    global $db;
    if (empty($db) || !is_object($db) || get_class($db) != "DB") {
        $dbh = FreePBX::Create()->Database();
        $db = new DB($dbh);
    }
    switch ($fetchmode) {
        case 'DB_FETCHMODE_ASSOC':
            //You guessed it, looking for string constants!
        //You guessed it, looking for string constants!
        case DB_FETCHMODE_ASSOC:
            //simulate craptacular function from previous versions
            //that didn't even work correctly! sweet :-/
            //(The integer shouldnt go there)
            if ($type == 'getAssoc') {
                $results = $db->{$type}($sql, true);
            } else {
                $results = $db->{$type}($sql, array(), DB_FETCHMODE_ASSOC);
            }
            break;
        case DB_FETCHMODE_ORDERED:
            $results = $db->{$type}($sql, array(), DB_FETCHMODE_ORDERED);
            break;
        case 'default':
            $results = $db->sql($sql, $type);
            break;
        default:
            throw new Exception("Unknown SQL fetchmode of {$fetchmode}");
            break;
    }
    return $results;
}
Example #2
0
 public function list_saved_form()
 {
     F3::set('data', 'daved data on the  row');
     $user = F3::get("SESSION.onlineUser");
     $datas = DB::sql("select v.id,v.form_type,v.date,u.username from vehicle v, user_form u where u.vehicle_id=v.id and v.status ='saved' and u.username='******'");
     F3::set('data', $datas);
 }
Example #3
0
 function lst()
 {
     $from = $this->get('POST.from');
     $to = $this->get('POST.to');
     $admin = $this->get('POST.admin');
     $list = DB::sql("select status, count(status) as no from admin_log where admin_id='" . $admin_id . "'  and date between '" . $from . "' and '" . $to . "' + interval 1  group by status");
     $this->set("list", $list);
 }
Example #4
0
 public function items($term)
 {
     if ($term == '') {
         return false;
     }
     $term = $this->clean($term);
     // Query
     return DB::sql($this->query['items'], array('term' => $term)) ?: false;
 }
Example #5
0
 function transfer_feedback()
 {
     $id = F3::get("PARAMS.id");
     $vehicle = new Axon("vehicle");
     $vehicle->load(array('id=:id', array(':id' => $id)));
     $zone_id = $vehicle->zone_id;
     $wheeler = $vehicle->wheeler;
     $dates = $vehicle->date;
     $date = DB::sql("SELECT DATE_ADD( date, INTERVAL 15 DAY ) AS ds FROM vehicle WHERE id='{$id}' and date='{$dates}'");
     $dt = new Form_elements();
     $nepDate = $dt->dateConvertEn($date[0]["ds"]);
     // var_dump($date[0]["ds"]);die;
     //echo $nepDate;die;
     $zone = Admin::getZone($vehicle->zone_id);
     $symbol = Admin::getSymbolType($vehicle->vehicle_symbol_type);
     $vehicleNo = $zone . $vehicle->lot_number . $symbol . $vehicle->number;
     $zone = new Axon("zonal_office");
     if ($zone->found(array('zone_id=:id and wheeler=:vid', array(':id' => $zone_id, ':vid' => $wheeler))) > 0) {
         $zone->load(array('zone_id=:id and wheeler=:vid', array(':id' => $zone_id, ':vid' => $wheeler)));
         $photos = new Axon("owner_photo");
         if ($photos->found(array('vehicle_id =:id', array(':id' => $id)))) {
             $photos->load(array('vehicle_id =:id', array(':id' => $id)));
             F3::set('pic', $photos);
         } else {
             F3::set('pic', 'no photo available');
         }
         F3::set('date', $nepDate);
         F3::set('refer', $id);
         F3::set('vehicle', $vehicleNo);
         F3::set('value', $zone->name);
         F3::set('navUser', 'userNav');
         F3::set('template', 'feedbacktransfer');
         echo Template::serve("template/layout.html");
     } else {
         $photos = new Axon("owner_photo");
         if ($photos->found(array('vehicle_id =:id', array(':id' => $id)))) {
             $photos->load(array('vehicle_id =:id', array(':id' => $id)));
             F3::set('pic', $photos);
         } else {
             F3::set('pic', 'no photo available');
         }
         F3::set('date', $nepDate);
         F3::set('refer', $id);
         F3::set('navUser', 'userNav');
         F3::set('value', 'no office available');
         F3::set('template', 'feedbacktransfer');
         echo Template::serve("template/layout.html");
     }
 }
Example #6
0
 public function types()
 {
     return DB::sql($this->query['types']);
 }
Example #7
0
File: user.php Project: pshreez/PHP
 function transfer()
 {
     if (!F3::get('SESSION.onlineUser')) {
         F3::reroute("/");
     }
     $dateNep = new Form_elements();
     //transfer information of the vehicle
     $id = date('siGjnty') . rand(1, 100);
     $ip_address = $_SERVER['REMOTE_ADDR'];
     $wheeler = F3::get("POST.wheeler");
     $zone_id = F3::get("POST.zone_id");
     $lot_number = F3::get("POST.lot_number");
     $vehicle_symbol_type = $wheeler == 21 ? F3::get("POST.vehicle_symbol_type_two") : F3::get("POST.vehicle_symbol_type_four");
     $number = F3::get("POST.number");
     $vehicleid = $this->vehicleid($wheeler, $zone_id, $lot_number, $vehicle_symbol_type, $number);
     $reason = F3::get("POST.reason");
     $dates = F3::get("POST.date");
     $date = $dateNep->dateConvertEn($dates);
     $remarks = F3::get("POST.remarks");
     $witness_name = F3::get("POST.witness_name");
     $witness_address = F3::get("POST.witness_address");
     $citizenship_no = F3::get("POST.citizenship_no");
     //owner information
     $owner_type = F3::get("POST.owner_type");
     $first_name = F3::get("POST.first_name");
     $last_name = F3::get("POST.last_name");
     $father_name = F3::get("POST.father_name");
     $grandfather_name = F3::get("POST.grandfather_name");
     $dob = F3::get("POST.dob");
     $reg_num = F3::get("POST.reg_num");
     $email = F3::get("POST.email");
     $mobile = F3::get("POST.mobileno");
     $p_zone_id = F3::get("POST.p_zone_id");
     $p_district_id = F3::get("POST.p_district_id");
     $p_metropolitan = F3::get("POST.p_metropolitan");
     $p_ward_no = F3::get("POST.p_ward_no");
     $p_address = F3::get("POST.p_address");
     $p_house_no = F3::get("POST.p_house_no");
     $p_phone = F3::get("POST.p_phone");
     $temp_zone_id = F3::get("POST.temp_zone_id");
     $temp_district_id = F3::get("POST.temp_district_id");
     $temp_metropolitan = F3::get("POST.temp_metropolitan");
     $temp_ward_no = F3::get("POST.temp_ward_no");
     $temp_address = F3::get("POST.temp_address");
     $temp_house_no = F3::get("POST.temp_house_no");
     $temp_phone = F3::get("POST.temp_phone");
     $nabalik_guardian_name = F3::get("POST.nabalik_guardian_name");
     $nabalik_relation = F3::get("POST.nabalik_relation");
     $nabalik_identity_no = F3::get("POST.nabalik_identity_no");
     $nabalik_district = F3::get("POST.nabalik_district");
     $nabalik_year = F3::get("POST.nabalik_year");
     $nabalik_address = F3::get("POST.nabalik_address");
     $bank_name = F3::get("POST.bank_name");
     $creditor_name = F3::get("POST.creditor_name");
     $creditor_district = F3::get("POST.creditor_district");
     $creditor_year = F3::get("POST.creditor_year");
     $creditor_address = F3::get("POST.creditor_address");
     $per_nagarikta = F3::get("POST.per_nagarikta");
     $per_identificationno = F3::get("POST.per_identificationno");
     $per_district = F3::get("POST.per_district");
     $per_year = F3::get("POST.per_year");
     $indian_identificationno = F3::get("POST.indian_identificationno");
     $other_identificationno = F3::get("POST.other_identificationno");
     $captcha = F3::get("POST.code");
     if ($captcha == F3::get("SESSION.captcha")) {
         $this->pictureFolder($id);
         $sqls[] = "INSERT INTO vehicle (id,wheeler,vehicleid,zone_id,lot_number,vehicle_symbol_type,number,ip_address,form_type) VALUES('{$id}','{$wheeler}','{$vehicleid}','{$zone_id}',' {$lot_number}','{$vehicle_symbol_type} ','{$number}','{$ip_address}','namsari')";
         $sqls[] = "INSERT INTO owner (vehicleid,owner_type,first_name,last_name, father_name,grandfather_name,\n        dob,reg_num,email,mobileno,p_zone_id,p_district_id, p_metropolitan,p_ward_no,\n        p_address, p_house_no, p_phone, temp_zone_id,temp_district_id, temp_metropolitan,\n        temp_ward_no, temp_address,temp_house_no, temp_phone, nabalik_guardian_name,nabalik_relation,\n        nabalik_identity_no, nabalik_district, nabalik_year, nabalik_address, bank_name, creditor_name,\n        creditor_district, creditor_year, creditor_address,per_nagarikta,per_identificationno,per_district,per_year,indian_identificationno,other_identificationno)\n        VALUES( '{$id}','{$owner_type}','{$first_name}','{$last_name}','{$father_name}','{$grandfather_name}',\n       '{$dob}','{$reg_num}','{$email}','{$mobile}','{$p_zone_id}','{$p_district_id}','{$p_metropolitan}','{$p_ward_no}','{$p_address}',\n        '{$p_house_no}', '{$p_phone}','{$temp_zone_id}','{$temp_district_id}','{$temp_metropolitan}','{$temp_ward_no}',\n        '{$temp_address}',' {$temp_house_no}',' {$temp_phone}', '{$nabalik_guardian_name}',' {$nabalik_relation}',\n        '{$nabalik_identity_no}','{$nabalik_district}','{$nabalik_year}','{$nabalik_address}','{$bank_name}',\n        '{$creditor_name}','{$creditor_district}','{$creditor_year}','{$creditor_address}','{$per_nagarikta}',\n        '{$per_identificationno}','{$per_district}','{$per_year}','{$indian_identificationno}' ,'{$other_identificationno}')";
         $sqls[] = "INSERT INTO namsari (vehicle_id,reason,date,remarks,witness_name,witness_address,citizenship_no) VALUES('{$id}','{$reason}','{$date}','{$remarks}','{$witness_name}','{$witness_address}','{$citizenship_no}')";
         DB::sql($sqls);
         F3::reroute("/feedbackt/{$id}");
     } else {
         F3::set('error', 'The captcha you have entered is wrong');
         $this->transfer_ownership();
     }
 }
Example #8
0
 function namsari_save()
 {
     if (!F3::get('SESSION.onlineUser')) {
         F3::reroute("/");
     }
     //transfer information of the vehicle
     $id = date('siGjnty') . rand(1, 100);
     $user = F3::get("SESSION.onlineUser");
     $ip_address = $_SERVER['REMOTE_ADDR'];
     $wheeler = F3::get("POST.wheeler");
     $zone_id = F3::get("POST.zone_id");
     $lot_number = F3::get("POST.lot_number");
     $vehicle_symbol_type = $wheeler == 21 ? F3::get("POST.vehicle_symbol_type_two") : F3::get("POST.vehicle_symbol_type_four");
     // var_dump($vehicle_symbol_type);die;
     $number = F3::get("POST.number");
     $vehicleid = User::vehicleid($wheeler, $zone_id, $lot_number, $vehicle_symbol_type, $number);
     $status = 'saved';
     //namsari reason
     $reason = F3::get("POST.reason");
     $date = F3::get("POST.date");
     $remarks = F3::get("POST.remarks");
     $witness_name = F3::get("POST.witness_name");
     $witness_address = F3::get("POST.witness_address");
     $citizenship_no = F3::get("POST.citizenship_no");
     //owner information
     $owner_type = F3::get("POST.owner_type");
     $first_name = F3::get("POST.first_name");
     $last_name = F3::get("POST.last_name");
     $father_name = F3::get("POST.father_name");
     $grandfather_name = F3::get("POST.grandfather_name");
     $dob = F3::get("POST.dob");
     $reg_num = F3::get("POST.reg_num");
     $email = F3::get("POST.email");
     $mobile = F3::get("POST.mobileno");
     $p_zone_id = F3::get("POST.p_zone_id");
     $p_district_id = F3::get("POST.p_district_id");
     $p_metropolitan = F3::get("POST.p_metropolitan");
     $p_ward_no = F3::get("POST.p_ward_no");
     $p_address = F3::get("POST.p_address");
     $p_house_no = F3::get("POST.p_house_no");
     $p_phone = F3::get("POST.p_phone");
     $temp_zone_id = F3::get("POST.temp_zone_id");
     $temp_district_id = F3::get("POST.temp_district_id");
     $temp_metropolitan = F3::get("POST.temp_metropolitan");
     $temp_ward_no = F3::get("POST.temp_ward_no");
     $temp_address = F3::get("POST.temp_address");
     $temp_house_no = F3::get("POST.temp_house_no");
     $temp_phone = F3::get("POST.temp_phone");
     $nabalik_guardian_name = F3::get("POST.nabalik_guardian_name");
     $nabalik_relation = F3::get("POST.nabalik_relation");
     $nabalik_identity_no = F3::get("POST.nabalik_identity_no");
     $nabalik_district = F3::get("POST.nabalik_district");
     $nabalik_year = F3::get("POST.nabalik_year");
     $nabalik_address = F3::get("POST.nabalik_address");
     $bank_name = F3::get("POST.bank_name");
     $creditor_name = F3::get("POST.creditor_name");
     $creditor_district = F3::get("POST.creditor_district");
     $creditor_year = F3::get("POST.creditor_year");
     $creditor_address = F3::get("POST.creditor_address");
     $per_nagarikta = F3::get("POST.per_nagarikta");
     $per_identificationno = F3::get("POST.per_identificationno");
     $per_district = F3::get("POST.per_district");
     $per_year = F3::get("POST.per_year");
     $indian_identificationno = F3::get("POST.indian_identificationno");
     $other_identificationno = F3::get("POST.other_identificationno");
     $captcha = F3::get("POST.code");
     $photo = new User();
     $picture = $photo->pictureFolder($id);
     $sqls[] = "INSERT INTO vehicle (id,wheeler,vehicleid,zone_id,lot_number,vehicle_symbol_type,number,ip_address,form_type,status) VALUES('{$id}','{$wheeler}','{$vehicleid}','{$zone_id}',' {$lot_number}','{$vehicle_symbol_type} ','{$number}','{$ip_address}','namsari','{$status}')";
     $sqls[] = "INSERT INTO owner (vehicleid,owner_type,first_name,last_name, father_name,grandfather_name,\n        dob,reg_num,email,mobileno,p_zone_id,p_district_id, p_metropolitan,p_ward_no,\n        p_address, p_house_no, p_phone, temp_zone_id,temp_district_id, temp_metropolitan,\n        temp_ward_no, temp_address,temp_house_no, temp_phone, nabalik_guardian_name,nabalik_relation,\n        nabalik_identity_no, nabalik_district, nabalik_year, nabalik_address, bank_name, creditor_name,\n        creditor_district, creditor_year, creditor_address,per_nagarikta,per_identificationno,per_district,per_year,indian_identificationno,other_identificationno)\n        VALUES( '{$id}','{$owner_type}','{$first_name}','{$last_name}','{$father_name}','{$grandfather_name}',\n       '{$dob}','{$reg_num}','{$email}','{$mobile}','{$p_zone_id}','{$p_district_id}','{$p_metropolitan}','{$p_ward_no}','{$p_address}',\n        '{$p_house_no}', '{$p_phone}','{$temp_zone_id}','{$temp_district_id}','{$temp_metropolitan}','{$temp_ward_no}',\n        '{$temp_address}',' {$temp_house_no}',' {$temp_phone}', '{$nabalik_guardian_name}',' {$nabalik_relation}',\n        '{$nabalik_identity_no}','{$nabalik_district}','{$nabalik_year}','{$nabalik_address}','{$bank_name}',\n        '{$creditor_name}','{$creditor_district}','{$creditor_year}','{$creditor_address}','{$per_nagarikta}',\n        '{$per_identificationno}','{$per_district}','{$per_year}','{$indian_identificationno}' ,'{$other_identificationno}')";
     $sqls[] = "INSERT INTO namsari (vehicle_id,reason,date,remarks,witness_name,witness_address,citizenship_no) VALUES('{$id}','{$reason}','{$date}','{$remarks}','{$witness_name}','{$witness_address}','{$citizenship_no}')";
     $sqls[] = "INSERT INTO user_form(username,vehicle_id) VALUES('{$user}','{$id}')";
     DB::sql($sqls);
     $data = 'saved=';
     $data .= $id;
     F3::reroute("/user/home/{$data}");
 }
Example #9
0
 public static function field($tb_name)
 {
     $sql = "SHOW FULL FIELDS FROM " . $tb_name;
     self::$sql = $sql;
     return self::execute($sql);
 }
Example #10
0
 function dateConvertEn($date)
 {
     $sql = DB::sql("select nepali_year,month_code, datediff('" . $date . "', eng_start_date) +1 dt from calendar where '" . $date . "' between eng_start_date and eng_end_date");
     $dt = $sql[0]["nepali_year"] . '-' . $sql[0]["month_code"] . '-' . $sql[0]['dt'];
     return $dt;
 }
Example #11
0
 public function prefix($sql, $exec = 0)
 {
     if (strpos($sql, 'JOIN') !== false || strpos($sql, 'ALTER TABLE') !== false) {
         $sql = str_replace('{{', BDPREFIX, $sql);
         $sql = str_replace('}}', '', $sql);
     } elseif (strpos($sql, 'INSERT') !== false && strpos($sql, 'SELECT') !== false) {
         $sql = str_replace('{{', BDPREFIX, $sql);
         $sql = str_replace('}}', '', $sql);
     } else {
         $sql = preg_replace(array('/{{/', '/}}/'), array(BDPREFIX, ''), $sql, 1);
     }
     $site = $_SESSION['site'];
     if (Funcs::$uri[0] == ONESSA_DIR) {
         $site = $_SESSION['OneSSA']['site'];
     }
     if ($exec == 0) {
         if (strpos($sql, BDPREFIX . 'tree') !== false && strpos($sql, BDPREFIX . 'tree t ') === false) {
             if (strpos($sql, 'WHERE') !== false) {
                 $sql = str_replace('WHERE', 'WHERE ' . BDPREFIX . 'tree.site=' . $site . ' AND', $sql);
             } else {
                 $sql = str_replace(BDPREFIX . 'tree', BDPREFIX . 'tree WHERE ' . BDPREFIX . 'tree.site=' . $site . '', $sql);
             }
         } elseif (strpos($sql, BDPREFIX . 'tree t ') !== false) {
             if (strpos($sql, 'WHERE') !== false) {
                 $sql = str_replace('WHERE', 'WHERE t.site=' . $site . ' AND', $sql);
             }
         }
     }
     DB::$sql = $sql;
     DB::$count++;
     return $sql;
 }
Example #12
0
File: app.php Project: pshreez/PHP
 function viewData()
 {
     if (!F3::get('SESSION.sid')) {
         F3::reroute('/home');
     }
     $id = F3::get('PARAMS.pid');
     $poll = DB::sql(" SELECT  tbl_poll.user_id,tbl_option.name,tbl_poll.expiry_date,tbl_poll.created_date,tbl_poll.published_date,tbl_poll.keyword,tbl_poll.id,tbl_poll.user_id,tbl_user.fullname,tbl_user.image,tbl_poll.question,tbl_option.value FROM tbl_user LEFT join tbl_poll  ON tbl_user.id=tbl_poll.user_id left join tbl_option on tbl_poll.id=tbl_option.poll_id where tbl_poll.id={$id} ");
     $i = 0;
     $data = DB::SQL("select tbl_poll.*, options.* from tbl_poll,(select name, value, COALESCE(votes, 0) as votes from tbl_option left outer join (SELECT option_name, count(option_name) as votes, poll_id from tbl_vote  where poll_id={$id} group by option_name) as vote on tbl_option.name = vote.option_name where tbl_option.poll_id ={$id}) as options where tbl_poll.id={$id}");
     $vote = DB::SQL("select count(option_name) as vote from tbl_vote  where poll_id={$id}");
     //  var_dump($data);die;
     $dt = array();
     $totalValue = $vote[0]["vote"];
     if ($totalValue != 0) {
         // loop over poll options
         foreach ($data as $datas) {
             $cent = $datas["votes"] / $totalValue * 100;
             array_push($dt, array($datas["name"], stripslashes($datas["value"]), $datas["votes"], $cent));
         }
     } else {
         foreach ($data as $datas) {
             array_push($dt, array($datas["name"], stripslashes($datas["value"]), $datas["votes"]));
         }
     }
     // var_dump($dt);
     $question = $data[0]["question"];
     if (!strpos($poll[0]["question"], '?')) {
         $poll[0]["question"] .= "?";
     }
     $date = DATE('Y-m-d');
     F3::set('date', $date);
     F3::set('user_id', $poll[0]["user_id"]);
     F3::set('id', $poll[0]["id"]);
     F3::set('published_date', $poll[0]["published_date"]);
     F3::set('expiry_date', $poll[0]["expiry_date"]);
     F3::set('created_date', $poll[0]["created_date"]);
     F3::set('keyword', $poll[0]["keyword"]);
     $question = ucfirst($poll[0]["question"]);
     F3::set('user_id', $poll[0]["user_id"]);
     F3::set('fullname', $poll[0]["fullname"]);
     F3::set('image', $poll[0]["image"]);
     F3::set('question', $question);
     F3::set('options', $dt);
     F3::set('title', 'Poll Detail');
 }
Example #13
0
 function axon()
 {
     $this->set('title', 'SQL/Axon');
     $this->expect(is_null($this->get('ERROR')), 'No errors expected at this point', 'ERROR variable is set: ' . $this->get('ERROR.text'));
     $this->set('DB', new DB('sqlite::memory:'));
     $this->expect(extension_loaded('pdo_sqlite'), 'SQLite PDO available', 'SQLite PDO is not active - unable to continue');
     if (extension_loaded('pdo_sqlite')) {
         DB::sql(array('DROP TABLE IF EXISTS products;', 'CREATE TABLE products (' . 'item INTEGER,' . 'description VARCHAR(255),' . 'quantity INTEGER,' . 'PRIMARY KEY (item)' . ');'));
         $product = new Axon('products');
         $this->expect(is_object($product), 'Axon created', 'Unable to instantiate Axon');
         unset($product);
         $product = Axon::instance('products');
         $this->expect(is_a($product, 'Axon'), 'Axon instance created', 'Unable to instantiate Axon');
         unset($product);
         $product = new axon('products');
         $this->expect(is_object($product), 'Axon created (case-insensitive)', 'Unable to instantiate Axon (case-insensitive)');
         $this->expect($product->dry(), 'Axon in dry state', 'Axon is in hydrated state');
         $product->item = 111;
         $product->description = 'Coca Cola';
         $product->quantity = 3;
         $this->expect(!$product->dry(), 'Axon hydrated manually', 'Axon should be hydrated by now');
         $product->save();
         $this->expect(!$product->dry(), 'Axon expected to remain hydrated', 'Axon should be dry');
         // MySQL always reports an _id of 0 if primary key
         // is not an auto-increment field
         $this->expect($product->_id, 'Last insert ID available; SQLite returns ' . $product->_id, 'No last insert ID available');
         $product->load(array('item=:item', array(':item' => 111)));
         $this->expect($product->item == 111 && $product->description == 'Coca Cola' && $product->quantity == 3, 'Auto-hydration succeeded (SQLite converts numbers to strings)', 'Auto-hydration failed');
         $result = $product->findOne(array('item=:item', array(':item' => 111)));
         $this->expect($result->item == 111 && $result->description == 'Coca Cola' && $result->quantity == 3, 'findOne returned the correct record', 'findOne return value is incorrect');
         $result = $product->find(array('item=:item', array(':item' => 111)));
         $this->expect(get_class($result[0]) == 'Axon' && $result[0]->item == 111 && $result[0]->description == 'Coca Cola' && $result[0]->quantity == 3, 'find returned an array of Axon objects', 'find return type is incorrect');
         $product->quantity++;
         $product->save();
         $product->load(array('item=:item', array(':item' => 111)));
         $this->expect($product->item == 111 && $product->description == 'Coca Cola' && $product->quantity == 4, 'Axon saved - database update succeeded', 'Database update failed');
         $product->copyTo('POST');
         $this->expect($this->get('POST.item') == 111 && $this->get('POST.description') == 'Coca Cola' && $this->get('POST.quantity') == 4, 'Axon properties copied to framework variable', 'Unable to copy Axon properties to framework variable');
         $_POST['description'] = 'Pepsi';
         $product->copyFrom('POST');
         $this->expect($product->item == 111 && $product->description == 'Pepsi' && $product->quantity == 4, 'Axon properties populated by framework variable', 'Unable to fill Axon properties with contents of framework variable');
         $this->set('POST.item', 999);
         $this->set('POST.description', 'Pepsi');
         $this->set('POST.quantity', 11);
         $product->copyFrom('POST', 'item|quantity');
         $this->expect($product->item == 999 && $product->description == 'Pepsi' && $product->quantity == 11, 'Axon properties populated by selected fields in framework variable', 'Unable to fill Axon properties with contents of framework variable');
         $product->reset();
         $this->expect($product->dry(), 'Axon reset completed', 'Axon should be dry');
         $product->item = 222;
         $product->description = 'Mobile Phone';
         $product->quantity = 9;
         $this->expect(!$product->dry(), 'Axon rehydrated manually', 'Axon should hydrated by now');
         $product->save();
         $this->expect(!$product->dry(), 'Axon expected to remain hydrated', 'Axon should not be dry');
         $product->load('item=111');
         $this->expect($product->item == 111 && $product->description == 'Coca Cola' && $product->quantity == 4, 'First record still there', 'First record is missing');
         $product->load('item=222');
         $this->expect($product->item == 222 && $product->description == 'Mobile Phone' && $product->quantity == 9, 'Second record found', 'Second record is missing');
         $product->def('total', 'SUM(quantity)');
         $this->expect($product->isdef('total') === TRUE, 'Virtual field created', 'Problem creating virtual field');
         $product->load();
         $this->expect($product->total == 13, 'Computed value of aggregate value using a virtual field works', 'Virtual field implementation faulty');
         $product->undef('total');
         $this->expect($product->isdef('total') === FALSE, 'Virtual field destroyed', 'Problem destroying virtual field');
         $product->load('item=111');
         $product->erase();
         $product->load('item=111');
         $this->expect($product->dry(), 'First record deleted', 'First record still exists');
         $product->load('item=222');
         $this->expect($product->item == 222 && $product->description == 'Mobile Phone' && $product->quantity == 9, 'Second record still there', 'Second record is missing');
         $product->reset();
         $product->item = 111;
         $product->description = 'Lots of dough';
         $product->quantity = 666;
         $product->save();
         $product->load('quantity>0');
         $this->expect($product->found() == 2, 'New record added - multirecord criteria specified for loading', 'New record was not added');
         $product->skip(1);
         $this->expect(!$product->dry(), 'One more record expected to be retrieved', 'Axon is dry');
         $this->expect($product->item == 222 && $product->description == 'Mobile Phone' && $product->quantity == 9, 'Forward navigation', 'Forward navigation failed');
         $product->skip(-1);
         $this->expect($product->item == 111 && $product->description == 'Lots of dough' && $product->quantity == 666, 'Backward navigation', 'Backward navigation failed');
         $product->skip(-1);
         $this->expect($product->dry(), 'Axon is dry when navigating before the start of the record set', 'Navigation failure');
         $this->set('QUIET', TRUE);
         $product->skip(-1);
         $this->expect(!is_null($this->get('ERROR')), 'Navigating past dry state triggers an error', 'Navigation error handling issue');
         $this->set('QUIET', FALSE);
         $this->clear('ERROR');
         $product->load('quantity>0');
         $product->skip(2);
         $this->expect($product->dry(), 'Axon is dry when navigating beyond the end of the record set', 'Navigation failure');
         $this->set('QUIET', TRUE);
         $product->skip();
         $this->expect(!is_null($this->get('ERROR')), 'Navigating past dry state triggers an error', 'Navigation error handling issue');
         $this->set('QUIET', FALSE);
         $this->clear('ERROR');
         $db = $this->get('DB');
         $result = $db->exec('SELECT * FROM products WHERE item=:item', array(':item' => 111));
         $this->expect($result[0]['item'] == 111 && $result[0]['description'] == 'Lots of dough' && $result[0]['quantity'] == 666, 'Late-binding of parameters to values in SQL statements', 'Late-binding issue encountered');
         $product->load('item=111');
         $product->description = 'quoted "string"';
         $product->save();
         $result = $product->findOne('item=111');
         $this->expect($result->description == 'quoted "string"', 'Double-quoted strings are left untouched', 'Double-quoted strings altered');
     }
     echo $this->render('basic/results.htm');
 }
Example #14
0
 function approveNamsari()
 {
     if (!F3::get('SESSION.asid')) {
         F3::reroute("/admin");
     }
     $vehicle = F3::get("PARAMS.id");
     $sql = DB::SQL("select vehicleid from vehicle where id=111");
     $wheeler = F3::get("POST.wheeler");
     $zone_id = F3::get("POST.zone_id");
     $lot_number = F3::get("POST.lot_number");
     $vehicle_symbol_type = $wheeler == 21 ? F3::get("POST.vehicle_symbol_type_two") : F3::get("POST.vehicle_symbol_type_four");
     $number = F3::get("POST.number");
     $user = new User();
     $vehicleid = $user->vehicleid($wheeler, $zone_id, $lot_number, $vehicle_symbol_type, $number);
     //table namsari
     $reason = F3::get("POST.reason");
     $date = F3::get("POST.date");
     $remarks = F3::get("POST.remarks");
     $witness_name = F3::get("POST.witness_name");
     $witness_address = F3::get("POST.witness_address");
     $citizenship_no = F3::get("POST.citizenship_no");
     //owner table
     $owner_type = F3::get("POST.owner_type");
     $first_name = F3::get("POST.first_name");
     $last_name = F3::get("POST.last_name");
     $father_name = F3::get("POST.father_name");
     $grandfather_name = F3::get("POST.grandfather_name");
     $dob = F3::get("POST.dob");
     $reg_num = F3::get("POST.reg_num");
     $email = F3::get("POST.email");
     $mobile = F3::get("POST.mobileno");
     $p_zone_id = F3::get("POST.p_zone_id");
     $p_district_id = F3::get("POST.p_district_id");
     $p_metropolitan = F3::get("POST.p_metropolitan");
     $p_ward_no = F3::get("POST.p_ward_no");
     $p_address = F3::get("POST.p_address");
     $p_house_no = F3::get("POST.p_house_no");
     $p_phone = F3::get("POST.p_phone");
     $temp_zone_id = F3::get("POST.temp_zone_id");
     $temp_district_id = F3::get("POST.temp_district_id");
     $temp_metropolitan = F3::get("POST.temp_metropolitan");
     $temp_ward_no = F3::get("POST.temp_ward_no");
     $temp_address = F3::get("POST.temp_address");
     $temp_house_no = F3::get("POST.temp_house_no");
     $temp_phone = F3::get("POST.temp_phone");
     $nabalik_guardian_name = F3::get("POST.nabalik_guardian_name");
     $nabalik_relation = F3::get("POST.nabalik_relation");
     $nabalik_identity_no = F3::get("POST.nabalik_identity_no");
     $nabalik_district = F3::get("POST.nabalik_district");
     $nabalik_year = F3::get("POST.nabalik_year");
     $nabalik_address = F3::get("POST.nabalik_address");
     $bank_name = F3::get("POST.bank_name");
     $creditor_name = F3::get("POST.creditor_name");
     $creditor_district = F3::get("POST.creditor_district");
     $creditor_year = F3::get("POST.creditor_year");
     $creditor_address = F3::get("POST.creditor_address");
     $per_nagarikta = F3::get("POST.per_nagarikta");
     $per_identificationno = F3::get("POST.per_identificationno");
     $per_district = F3::get("POST.per_district");
     $per_year = F3::get("POST.per_year");
     $indian_identificationno = F3::get("POST.indian_identificationno");
     $other_identificationno = F3::get("POST.other_identificationno");
     //online edit by the operator
     $onlineSql[] = "update vehicle set wheeler='{$wheeler}',vehicleid='{$vehicleid}',zone_id='{$zone_id}',lot_number='{$lot_number}',\n        vehicle_symbol_type='{$vehicle_symbol_type}', number='{$number}', status='approved'  where id='" . $vehicle . "'";
     $onlineSql[] = "update namsari set reason='{$reason}',date='{$date}',remarks='{$remarks}',witness_name='{$witness_name}',witness_address='{$witness_address}',citizenship_no='{$citizenship_no}'where id='" . $vehicle . "'";
     $onlineSql[] = "update owner set owner_type='{$owner_type}',first_name='{$first_name}',last_name='{$last_name}', father_name='{$father_name}',\n        grandfather_name='{$grandfather_name}',dob='{$dob}',reg_num='{$reg_num}',email='{$email}',mobileno='{$mobile}',p_zone_id='{$p_zone_id}',p_district_id='{$p_district_id}',\n        p_metropolitan='{$p_metropolitan}',p_ward_no='{$p_ward_no}',p_address='{$p_address}', p_house_no='{$p_house_no}', p_phone='{$p_phone}',\n        temp_zone_id='{$temp_zone_id}',temp_district_id='{$temp_district_id}', temp_metropolitan='{$temp_metropolitan}', temp_ward_no='{$temp_ward_no}', temp_address='{$temp_address}',temp_house_no='{$temp_house_no}',\n        temp_phone='{$temp_phone}', nabalik_guardian_name='{$nabalik_guardian_name}',nabalik_relation='{$nabalik_relation}',\n        nabalik_identity_no='{$nabalik_identity_no}', nabalik_district='{$nabalik_district}', nabalik_year='{$nabalik_year}', nabalik_address='{$nabalik_address}',\n        bank_name='{$bank_name}', creditor_name='{$creditor_name}',\n        creditor_district='{$creditor_district}', creditor_year='{$creditor_year}', creditor_address='{$creditor_address}',per_nagarikta='{$per_nagarikta}',\n        per_identificationno='{$per_identificationno}',per_district='{$per_district}',per_year='{$per_year}',indian_identificationno='{$indian_identificationno}' ,other_identificationno='{$other_identificationno}' where vehicleid='" . $vehicle . "'";
     //
     //
     $zone = Admin::getZone($zone_id);
     $symbol = Admin::getSymbolType($vehicle_symbol_type);
     $vehicleNo = $zone . $lot_number . $symbol . $number;
     F3::set('DB', new DB(F3::get("db_param.live_host"), F3::get("db_param.live_user"), F3::get("db_param.live_password")));
     $old_owner_id = DB::sql("select owner_id from vehicle where id='" . $vehicleid . "'");
     //check whether id is int
     if (count($old_owner_id) > 0) {
         $sqls[] = "INSERT INTO owner\n        (name,caste,dob,email,owner_type_id,father_name,g_father_name,mobileno,p_district,p_zone_id,\n        p_nagarpalika,p_wardno, p_tole,p_gharno,p_phone,t_district,t_zone_id,t_nagarpalika,t_wardno,t_tole,\n        t_gharno,t_phone,nab_guardian_name,nab_relation,nab_identificationno,nab_district,nab_year,nab_address,per_nagarikta, per_identificationno,\n        per_district,per_year,bank_name,bank_identificationno,bank_district, bank_year,bank_address) VALUES\n        ('{$first_name}', '{$last_name}','{$dob}','{$email}','{$owner_type}','{$father_name}','{$grandfather_name}', '{$mobile}',' {$p_district_id}',' {$p_zone_id}',\n        '{$p_metropolitan}', '{$p_ward_no}','{$p_address}', '{$p_house_no}', '{$p_phone}', ' {$temp_district_id}','{$temp_zone_id}', '{$temp_metropolitan}',' {$temp_ward_no}','{$temp_address}',\n        ' {$temp_house_no}',' {$temp_phone}', '{$nabalik_guardian_name}',' {$nabalik_relation}', '{$nabalik_identity_no}', '{$nabalik_district}', '{$nabalik_year}', '{$nabalik_address}','{$per_nagarikta}','{$per_identificationno}',\n        '{$per_district}', '{$per_year}', '{$bank_name}', '{$creditor_name}',' {$creditor_district}', '{$creditor_year}','{$creditor_address}')";
         $sqls[] = "insert into namsari_info\n        (vehicle_id,reason,date,comments, sakshi_name,sakshi_address,sakshi_identification,new_ownerid, old_ownerid,status)\n         values  ('{$vehicleid}','{$reason}','{$date}','{$remarks}','{$witness_name}','{$witness_address}','{$citizenship_no}',(select last_insert_id()),'" . $old_owner_id[0]['owner_id'] . "','initial')";
         //set db to remote
         DB::sql($sqls);
         $photo_name = DB::sql("select new_ownerid from namsari_info where vehicle_id='" . $vehicleid . "' order by new_ownerid desc");
         //update photo
         $onlineSql[] = "update owner_photo set picture='" . $photo_name[0]['new_ownerid'] . ".jpg' where vehicle_id='" . $vehicle . "'";
         //set db to old one
         F3::set('DB', new DB(F3::get("local_param.local_host"), F3::get("local_param.local_user"), F3::get("local_param.local_password")));
         DB::SQL($onlineSql);
         rename("photo/" . $vehicle . ".jpg", "photo/" . $photo_name[0]['new_ownerid'] . ".jpg");
         AdminLog::add($vehicleNo, "namsari", "approved");
         //success message
         F3::set('nav', 'navigation');
         F3::set('message', 'The data has been approved');
         F3::set('templateAdmin', 'approve');
         echo Template::serve("template/layout.html");
     } else {
         F3::set('message', 'The data doesnot exist');
         F3::set('nav', 'navigation');
         F3::set('templateAdmin', 'approve');
         echo Template::serve("template/layout.html");
     }
 }
Example #15
0
 function prepare($sql)
 {
     global $dbh;
     self::$sql = $sql;
     return $dbh->prepare($sql);
 }