text:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Customers extends MX_Controller
{

    function __construct()
    {
        parent::__construct();

        // check if user logged in
        if (!$this->ion_auth->logged_in()) {
            redirect('auth/login');
        }

        $this->load->library('form_validation');
        $this->load->model('customers_model');

    }

    function index()
    {

        $data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
        $data['success_message'] = $this->session->flashdata('success_message');
        $data['payment_types'] = $this->customers_model->getAllPayment_types();
        $data['credit_allowances'] = $this->customers_model->getAllCredit_allowances();
        $data['region_days'] = $this->customers_model->getAllRegion_days();

        $meta['page_title'] = $this->lang->line("customers");
        $data['page_title'] = $this->lang->line("customers");
        $this->load->view('commons/header', $meta);
        $this->load->view('content', $data);
        $this->load->view('commons/footer');
    }

    function getdatatableajax()
    {

        $this->load->library('datatables');
        $this->datatables
            ->select("id, surname, name, home_number, email,region,type,blue,status")
            ->from("customers")

            ->add_column("Actions",
                "
                lang->line("edit_customer") . "' href='index.php?module=customers&view=edit&id=$1'>
				lang->line("delete_customer") . "' href='index.php?module=customers&view=delete&id=$1' onClick=\"return confirm('" . $this->lang->line('alert_x_customer') . "')\">
				$2
				 ", "id,status")
            ->unset_column('id')
            ->unset_column('status');

        echo $this->datatables->generate();

    }

    function add()
    {

        $groups = array('owner', 'admin', 'salesman');
        if (!$this->ion_auth->in_group($groups)) {
            $this->session->set_flashdata('message', $this->lang->line("access_denied"));
            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
            redirect('module=home', 'refresh');
        }

        //validate form input

        $this->form_validation->set_rules('surname', $this->lang->line("surname"), 'required|xss_clean');
        $this->form_validation->set_rules('name', $this->lang->line("name"), 'required|xss_clean');
        $this->form_validation->set_rules('email', $this->lang->line("email_address"), 'valid_email');
        $this->form_validation->set_rules('company', $this->lang->line("company"), 'xss_clean');
        $this->form_validation->set_rules('id_number', $this->lang->line("id_number"), 'required|xss_clean');
        $this->form_validation->set_rules('dob', $this->lang->line("dob"), 'required|xss_clean');
        $this->form_validation->set_rules('training_date', $this->lang->line("training_date"), 'required|xss_clean');
        $this->form_validation->set_rules('religion', $this->lang->line("religion"), 'xss_clean');
        $this->form_validation->set_rules('work_number', $this->lang->line("work_number"), 'xss_clean');
        //    $this->form_validation->set_rules('coordinator_name', $this->lang->line("coordinator_name"), 'required|xss_clean'); // Hyder - issue #31 - 4 June 2014 - comment on purpose - optional field
        $this->form_validation->set_rules('credit_allowance', $this->lang->line("credit_allowance"), 'required|xss_clean');
        $this->form_validation->set_rules('place_of_work', $this->lang->line("place_of_work"), 'xss_clean');
        $this->form_validation->set_rules('no_of_work', $this->lang->line("no_of_work"), 'xss_clean');
        $this->form_validation->set_rules('payment_type', $this->lang->line("payment_type"), 'required|xss_clean');
        $this->form_validation->set_rules('proof_of_address', $this->lang->line("proof_of_address"), 'xss_clean');
        $this->form_validation->set_rules('authorization_letter', $this->lang->line("authorization_letter"), 'xss_clean');
        $this->form_validation->set_rules('cf4', $this->lang->line("ccf4"), 'xss_clean');
        $this->form_validation->set_rules('cf5', $this->lang->line("ccf5"), 'xss_clean');
        $this->form_validation->set_rules('cf6', $this->lang->line("ccf6"), 'xss_clean');
        $this->form_validation->set_rules('address', $this->lang->line("address"), 'required|xss_clean');
        $this->form_validation->set_rules('region', $this->lang->line("region"), 'required|xss_clean');
        $this->form_validation->set_rules('alternative_address', $this->lang->line("alternative_address"), 'xss_clean');
        //	$this->form_validation->set_rules('postal_code', $this->lang->line("postal_code"), 'required|xss_clean'); // Hyder - issue #31 - 4 June 2014 - comment on purpose - optional field
        //	$this->form_validation->set_rules('country', $this->lang->line("country"), 'required|xss_clean');
        $this->form_validation->set_rules('home_number', $this->lang->line("home_number"), 'xss_clean|min_length[7]|max_length[16]');
        $this->form_validation->set_rules('mobile_number', $this->lang->line("mobile_number"), 'required|xss_clean|min_length[7]|max_length[16]');
        $this->form_validation->set_rules('emergency_number', $this->lang->line("emergency_number"), 'xss_clean|min_length[7]|max_length[16]');

        if ($this->form_validation->run() == true) {
            //$payment_type_id = $this->input->post('payment_type');
            //$region_id = $this->input->post('region');

            $inv_dob = trim($this->input->post('dob'));
            $inv_training_date = trim($this->input->post('training_date'));
            if (JS_DATE == 'dd-mm-yyyy' || JS_DATE == 'dd/mm/yyyy') {
                $dob = substr($inv_dob, -4) . "-" . substr($inv_dob, 3, 2) . "-" . substr($inv_dob, 0, 2);
                $training_date = substr($inv_training_date, -4) . "-" . substr($inv_training_date, 3, 2) . "-" . substr($inv_training_date, 0, 2);
            } else {
                $dob = substr($inv_dob, -4) . "-" . substr($inv_dob, 0, 2) . "-" . substr($inv_dob, 3, 2);
                $training_date = substr($inv_training_date, -4) . "-" . substr($inv_training_date, 0, 2) . "-" . substr($inv_training_date, 3, 2);
            }

            // Hyder - issue #31 - 4 June 2014 - START

            if ($this->input->post('team_leader') == '0') {
                $type = 'teamleader';
                $teamleaderid = 0;

            } else {
                $type = 'consultant';
                $teamleaderid = $this->input->post('team_leader');
            }

            // Hyder - issue #31 - 4 June 2014 - END

            $data = array('surname' => $this->input->post('surname'),
                'name' => $this->input->post('name'),
                'email' => $this->input->post('email'),
                'company' => $this->input->post('company'),
                'id_number' => $this->input->post('id_number'),
                'dob' => $dob,
                'training_date' => $training_date,
                'religion' => $this->input->post('religion'),
                'work_number' => $this->input->post('work_number'),
                'coordinator_name' => $this->input->post('coordinator_name'),
                'credit_allowance' => $this->input->post('credit_allowance'),
                'place_of_work' => $this->input->post('place_of_work'),
                'no_of_work' => $this->input->post('no_of_work'),
                'payment_type' => $this->input->post('payment_type'),
                'proof_of_address' => $this->input->post('proof_of_address'),
                'authorization_letter' => $this->input->post('authorization_letter'),
                'cf4' => $this->input->post('cf4'),
                'cf5' => $this->input->post('cf5'),
                'cf6' => $this->input->post('cf6'),
                'address' => $this->input->post('address'),
                'region' => $this->input->post('region'),
                'alternative_address' => $this->input->post('alternative_address'),
                'postal_code' => $this->input->post('postal_code'),
                //	'country' => $this->input->post('country'),
                'home_number' => $this->input->post('home_number'),
                'mobile_number' => $this->input->post('mobile_number'),
                'emergency_number' => $this->input->post('emergency_number'),
                'type' => $type,
                'status' => 'pending',
                'teamleaderid' => $teamleaderid,
                'blue' => $this->input->post('blue'), // Hyder - issue #29 - 8 June 2014

            );

        }

        if ($this->form_validation->run() == true && $this->customers_model->addCustomer($data)) { //check to see if we are creating the customer

            //redirect them back to the admin page
            $this->session->set_flashdata('success_message', $this->lang->line("customer_added"));
            redirect("module=customers", 'refresh');
        } else { //display the create customer form
            //set the flash data error message if there is one

            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));

            $data['surname'] = array('name' => 'surname',
                'id' => 'surname',
                'type' => 'text',
                'value' => $this->form_validation->set_value('surname'),
            );
            $data['name'] = array('name' => 'name',
                'id' => 'name',
                'type' => 'text',
                'value' => $this->form_validation->set_value('name'),
            );
            $data['email'] = array('name' => 'email',
                'id' => 'email',
                'type' => 'text',
                'value' => $this->form_validation->set_value('email'),
            );
            $data['company'] = array('name' => 'company',
                'id' => 'company',
                'type' => 'text',
                'value' => $this->form_validation->set_value('company'),
            );
            $data['cui'] = array('name' => 'cui',
                'id' => 'cui',
                'type' => 'text',
                'value' => $this->form_validation->set_value('cui', '-'),
            );
            $data['reg'] = array('name' => 'reg',
                'id' => 'reg',
                'type' => 'text',
                'value' => $this->form_validation->set_value('reg', '-'),
            );
            $data['cnp'] = array('name' => 'cnp',
                'id' => 'cnp',
                'type' => 'text',
                'value' => $this->form_validation->set_value('cnp', '-'),
            );
            $data['serie'] = array('name' => 'serie',
                'id' => 'serie',
                'type' => 'text',
                'value' => $this->form_validation->set_value('serie', '-'),
            );
            $data['account_no'] = array('name' => 'account_no',
                'id' => 'account_no',
                'type' => 'text',
                'value' => $this->form_validation->set_value('account_no', '-'),
            );
            $data['bank'] = array('name' => 'bank',
                'id' => 'bank',
                'type' => 'text',
                'value' => $this->form_validation->set_value('bank', '-'),
            );
            $data['address'] = array('name' => 'address',
                'id' => 'address',
                'type' => 'text',
                'value' => $this->form_validation->set_value('address'),
            );
            $data['region'] = array('name' => 'region',
                'id' => 'region',
                'type' => 'text',
                'value' => $this->form_validation->set_value('region'),
            );
            $data['alternative_address'] = array('name' => 'alternative_address',
                'id' => 'alternative_address',
                'type' => 'text',
                'value' => $this->form_validation->set_value('alternative_address'),
            );
            $data['postal_code'] = array('name' => 'postal_code',
                'id' => 'postal_code',
                'type' => 'text',
                'value' => $this->form_validation->set_value('postal_code'),
            );
            /*	$data['country'] = array('name' => 'country',
                    'id' => 'country',
                    'type' => 'text',
                    'value' => $this->form_validation->set_value('country'),
                );*/
            $data['home_number'] = array('name' => 'home_number',
                'id' => 'home_number',
                'type' => 'text',
                'value' => $this->form_validation->set_value('home_number'),
            );
            $data['mobile_number'] = array('name' => 'mobile_number',
                'id' => 'mobile_number',
                'type' => 'text',
                'value' => $this->form_validation->set_value('mobile_number'),
            );
            $data['emergency_number'] = array('name' => 'emergency_number',
                'id' => 'emergency_number',
                'type' => 'text',
                'value' => $this->form_validation->set_value('emergency_number'),
            );
            $data['dob'] = array('name' => 'dob',
                'id' => 'dob',
                'type' => 'text',
                'value' => $this->form_validation->set_value('dob'),
            );
            $data['training_date'] = array('name' => 'training_date',
                'id' => 'training_date',
                'type' => 'text',
                'value' => $this->form_validation->set_value('training_date'),
            );
            $data['id_number'] = array('name' => 'id_number',
                'id' => 'id_number',
                'type' => 'text',
                'value' => $this->form_validation->set_value('id_number'),
            );
            $data['religion'] = array('name' => 'religion',
                'id' => 'religion',
                'type' => 'text',
                'value' => $this->form_validation->set_value('religion'),
            );
            $data['work_number'] = array('name' => 'work_number',
                'id' => 'work_number',
                'type' => 'text',
                'value' => $this->form_validation->set_value('work_number'),
            );
            $data['coordinator_name'] = array('name' => 'coordinator_name',
                'id' => 'coordinator_name',
                'type' => 'text',
                'value' => $this->form_validation->set_value('coordinator_name'),
            );
            $data['credit_allowance'] = array('name' => 'credit_allowance',
                'id' => 'credit_allowance',
                'type' => 'text',
                'value' => $this->form_validation->set_value('credit_allowance'),
            );
            $data['place_of_work'] = array('name' => 'place_of_work',
                'id' => 'place_of_work',
                'type' => 'text',
                'value' => $this->form_validation->set_value('place_of_work'),
            );
            $data['no_of_work'] = array('name' => 'no_of_work',
                'id' => 'no_of_work',
                'type' => 'text',
                'value' => $this->form_validation->set_value('no_of_work'),
            );
            $data['payment_type'] = array('name' => 'payment_type',
                'id' => 'payment_type',
                'type' => 'text',
                'value' => $this->form_validation->set_value('payment_type'),
            );
            $data['proof_of_address'] = array('name' => 'proof_of_address',
                'id' => 'proof_of_address',
                'type' => 'text',
                'value' => $this->form_validation->set_value('proof_of_address'),
            );
            $data['authorization_letter'] = array('name' => 'authorization_letter',
                'id' => 'authorization_letter',
                'type' => 'text',
                'value' => $this->form_validation->set_value('authorization_letter'),
            );

            $data['teamleaders'] = $this->customers_model->get_teamleaders(); // Hyder - issue #31 - 4 June 2014
            $data['payment_types'] = $this->customers_model->getAllPayment_types();
            $data['credit_allowances'] = $this->customers_model->getAllCredit_allowances();
            $meta['page_title'] = $this->lang->line("new_customer");
            $data['region_days'] = $this->customers_model->getAllRegion_days();
            $data['page_title'] = $this->lang->line("new_customer");

            $this->load->view('commons/header', $meta);
            $this->load->view('add', $data);
            $this->load->view('commons/footer');

        }
    }

    function edit($id = NULL)
    {
        if ($this->input->get('id')) {
            $id = $this->input->get('id');
        }
        $groups = array('owner', 'admin', 'salesman');
        if (!$this->ion_auth->in_group($groups)) {
            $this->session->set_flashdata('message', $this->lang->line("access_denied"));
            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
            redirect('module=home', 'refresh');
        }

        //validate form input
        $this->form_validation->set_rules('surname', $this->lang->line("surname"), 'required|xss_clean');
        $this->form_validation->set_rules('name', $this->lang->line("name"), 'required|xss_clean');
        $this->form_validation->set_rules('email', $this->lang->line("email_address"), 'valid_email');
        $this->form_validation->set_rules('company', $this->lang->line("company"), 'xss_clean');
        $this->form_validation->set_rules('id_number', $this->lang->line("id_number"), 'required|xss_clean');
        $this->form_validation->set_rules('dob', $this->lang->line("dob"), 'required|xss_clean');
        $this->form_validation->set_rules('training_date', $this->lang->line("training_date"), 'required|xss_clean');
        //	$this->form_validation->set_rules('religion', $this->lang->line("religion"), 'xss_clean'); // Hyder - issue #31 - 4 June 2014 - comment on purpose - optional field
        $this->form_validation->set_rules('work_number', $this->lang->line("work_number"), 'xss_clean'); // Hyder - issue #31 - 4 June 2014
        //  $this->form_validation->set_rules('coordinator_name', $this->lang->line("coordinator_name"), 'required|xss_clean');
        $this->form_validation->set_rules('credit_allowance', $this->lang->line("credit_allowance"), 'required|xss_clean');
        $this->form_validation->set_rules('place_of_work', $this->lang->line("place_of_work"), 'xss_clean');
        $this->form_validation->set_rules('no_of_work', $this->lang->line("no_of_work"), 'xss_clean');
        $this->form_validation->set_rules('payment_type', $this->lang->line("payment_type"), 'required|xss_clean');
        $this->form_validation->set_rules('proof_of_address', $this->lang->line("proof_of_address"), 'xss_clean');
        $this->form_validation->set_rules('authorization_letter', $this->lang->line("authorization_letter"), 'xss_clean');
        $this->form_validation->set_rules('cf4', $this->lang->line("ccf4"), 'xss_clean');
        $this->form_validation->set_rules('cf5', $this->lang->line("ccf5"), 'xss_clean');
        $this->form_validation->set_rules('cf6', $this->lang->line("ccf6"), 'xss_clean');
        $this->form_validation->set_rules('address', $this->lang->line("address"), 'required|xss_clean');
        $this->form_validation->set_rules('region', $this->lang->line("region"), 'required|xss_clean');
        //	$this->form_validation->set_rules('alternative_address', $this->lang->line("alternative_address"), 'xss_clean'); // Hyder - issue #31 - 4 June 2014 - comment on purpose - optional field
        $this->form_validation->set_rules('postal_code', $this->lang->line("postal_code"), 'required|xss_clean');
        //	$this->form_validation->set_rules('country', $this->lang->line("country"), 'xss_clean');
        $this->form_validation->set_rules('home_number', $this->lang->line("home_number"), 'xss_clean|min_length[7]|max_length[16]');
        $this->form_validation->set_rules('mobile_number', $this->lang->line("mobile_number"), 'required|xss_clean|min_length[7]|max_length[16]');
        $this->form_validation->set_rules('emergency_number', $this->lang->line("emergency_number"), 'xss_clean|min_length[7]|max_length[16]');

        if ($this->form_validation->run() == true) {

            // Hyder - issue #31 - 4 June 2014 - START

            if ($this->input->post('team_leader') == '0') {
                $type = 'teamleader';
                $teamleaderid = 0;

            } else {
                $type = 'consultant';
                $teamleaderid = $this->input->post('team_leader');
            }
            // Hyder - issue #31 - 4 June 2014 - END

            $payment_type_id = $this->input->post('payment_type');
            $credit_allowance_id = $this->input->post('credit_allowance');
            $region_id = $this->input->post('region');
            $data = array('surname' => $this->input->post('surname'),
                'name' => $this->input->post('name'),
                'email' => $this->input->post('email'),
                'company' => $this->input->post('company'),
                'id_number' => $this->input->post('id_number'),
                'dob' => $this->input->post('dob'),
                'training_date' => $this->input->post('training_date'),
                'religion' => $this->input->post('religion'),
                'work_number' => $this->input->post('work_number'),
                //  'coordinator_name' => $this->input->post('coordinator_name'), ; // Hyder - issue #31 - 4 June 2014 - comment on purpose - optional field
                'credit_allowance' => $this->input->post('credit_allowance'),
                'place_of_work' => $this->input->post('place_of_work'),
                'no_of_work' => $this->input->post('no_of_work'),
                'payment_type' => $this->input->post('payment_type'),
                'proof_of_address' => $this->input->post('proof_of_address'),
                'authorization_letter' => $this->input->post('authorization_letter'),
                'cf4' => $this->input->post('cf4'),
                'cf5' => $this->input->post('cf5'),
                'cf6' => $this->input->post('cf6'),
                'address' => $this->input->post('address'),
                'region' => $this->input->post('region'),
                'alternative_address' => $this->input->post('alternative_address'),
                'postal_code' => $this->input->post('postal_code'),
                //	'country' => $this->input->post('country'),
                'home_number' => $this->input->post('home_number'),
                'mobile_number' => $this->input->post('mobile_number'),
                'emergency_number' => $this->input->post('emergency_number'),
                'type' => $type,
                'blue' => $this->input->post('blue'),
                'teamleaderid' => $teamleaderid
            );

        }

        if ($this->form_validation->run() == true && $this->customers_model->updateCustomer($id, $data)) {
            $this->session->set_flashdata('success_message', $this->lang->line("customer_updated"));
            redirect("module=customers", 'refresh');
        } else {
            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
            $data['teamleaders'] = $this->customers_model->get_teamleaders(); // Hyder - issue #31 - 4 June 2014
            $data['customer'] = $this->customers_model->getCustomerByID($id);
            $data['payment_types'] = $this->customers_model->getAllPayment_types();
            $data['credit_allowances'] = $this->customers_model->getAllCredit_allowances();
            $data['region_days'] = $this->customers_model->getAllRegion_days();
            $meta['page_title'] = $this->lang->line("update_customer");
            $data['id'] = $id;
            $data['page_title'] = $this->lang->line("update_customer");
            $this->load->view('commons/header', $meta);
            $this->load->view('edit', $data);
            $this->load->view('commons/footer');

        }
    }

    function add_by_csv()
    {

        $groups = array('owner', 'admin');
        if (!$this->ion_auth->in_group($groups)) {
            $this->session->set_flashdata('message', $this->lang->line("access_denied"));
            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
            redirect('module=products', 'refresh');
        }

        $this->form_validation->set_rules('userfile', $this->lang->line("upload_file"), 'xss_clean');

        if ($this->form_validation->run() == true) {

            if (DEMO) {
                $this->session->set_flashdata('message', $this->lang->line("disabled_in_demo"));
                redirect('module=home', 'refresh');
            }

            if (isset($_FILES["userfile"])) /*if($_FILES['userfile']['size'] > 0)*/ {

                $this->load->library('upload');

                $config['upload_path'] = 'assets/uploads/csv/';
                $config['allowed_types'] = 'csv';
                $config['max_size'] = '200';
                $config['overwrite'] = TRUE;

                $this->upload->initialize($config);

                if (!$this->upload->do_upload()) {

                    $error = $this->upload->display_errors();
                    $this->session->set_flashdata('message', $error);
                    redirect("module=suppliers&view=add_by_csv", 'refresh');
                }

                $csv = $this->upload->file_name;

                $arrResult = array();
                $handle = fopen("assets/uploads/csv/" . $csv, "r");
                if ($handle) {
                    while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) {
                        $arrResult[] = $row;
                    }
                    fclose($handle);
                }
                $titles = array_shift($arrResult);

                $keys = array('name', 'email', 'home_number', 'mobile_number', 'emergency_number', 'dob', 'training_date', 'company', 'address', 'region', 'alternative_address', 'postal_code', 'country', 'id_number', 'religion', 'work_number', 'coordinator_name', 'credit_allowance', 'place_of_work', 'no_of_work', 'payment_type', 'proof_of_address', 'authorization_letter');

                $final = array();

                foreach ($arrResult as $key => $value) {
                    $final[] = array_combine($keys, $value);
                }
                $rw = 2;
                foreach ($final as $csv) {
                    if ($this->customers_model->getCustomerByEmail($csv['email'])) {
                        $this->session->set_flashdata('message', $this->lang->line("check_customer_email") . " (" . $csv['email'] . "). " . $this->lang->line("customer_already_exist") . " " . $this->lang->line("line_no") . " " . $rw);
                        redirect("module=customers&view=add_by_csv", 'refresh');
                    }
                    $rw++;
                }
            }

            $final = $this->mres($final);
            //$data['final'] = $final;
        }

        if ($this->form_validation->run() == true && $this->customers_model->add_customers($final)) {
            $this->session->set_flashdata('success_message', $this->lang->line("customers_added"));
            redirect('module=customers', 'refresh');
        } else {

            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));

            $data['userfile'] = array('name' => 'userfile',
                'id' => 'userfile',
                'type' => 'text',
                'value' => $this->form_validation->set_value('userfile')
            );

            $meta['page_title'] = $this->lang->line("add_customers_by_csv");
            $data['page_title'] = $this->lang->line("add_customers_by_csv");
            $this->load->view('commons/header', $meta);
            $this->load->view('add_by_csv', $data);
            $this->load->view('commons/footer');

        }

    }

    function delete($id = NULL)
    {
        if (DEMO) {
            $this->session->set_flashdata('message', $this->lang->line("disabled_in_demo"));
            redirect('module=home', 'refresh');
        }

        if ($this->input->get('id')) {
            $id = $this->input->get('id');
        }
        if (!$this->ion_auth->in_group('owner')) {
            $this->session->set_flashdata('message', $this->lang->line("access_denied"));
            $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
            redirect('module=home', 'refresh');
        }

        if ($this->customers_model->deleteCustomer($id)) {
            $this->session->set_flashdata('success_message', $this->lang->line("customer_deleted"));
            redirect("module=customers", 'refresh');
        }

    }

    function mres($q)
    {
        if (is_array($q))
            foreach ($q as $k => $v)
                $q[$k] = $this->mres($v); //recursive
        elseif (is_string($q))
            $q = mysql_real_escape_string($q);
        return $q;
    }

    function suggestions()
    {
        $term = $this->input->get('term', TRUE);

        if (strlen($term) < 2) break;

        $rows = $this->customers_model->getCustomerNames($term);

        $json_array = array();
        foreach ($rows as $row)
            array_push($json_array, $row->name);

        echo json_encode($json_array);
    }

    // issue #29 - Hyder - 9 June 2014 - START - Approval by admin - fonction la em nouvo!
    function approve_customer()
    {
        $id = $_GET['id'];
        $status = $_GET['status'];

        if ($status != 'icon-thumbs-up') {
            $data = array(
                'status' => 'approved'
            );
            $flag = 'approved';
        } else {
            $data = array(
                'status' => 'pending'
            );
            $flag = 'pending';
        }

        echo $flag;
        $this->db->where('id', $id);
        $this->db->update('customers', $data);
        //  echo $this->db->last_query();

    }

    // issue #29 - Hyder - 9 June 2014 - START - Approval by admin
}


text:
package org.apache.sshd.sftp.client;

/**
 * @author Apache MINA SSHD Project
 */
@FunctionalInterface
public interface SftpClientHolder {
    SftpClient getClient();
}

redpajama_set_name: RedPajamaGithub


text:
package org.egordorichev.lasttry.system;

import com.google.common.collect.Queues;
import org.egordorichev.lasttry.entity.CreatureManagerImpl;
import org.egordorichev.lasttry.injection.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Queue;

public class EngineBuilder {
    private static final Logger logger = LoggerFactory.getLogger(EngineBuilder.class);

    private final Queue<Subsystem> subsystems = Queues.newArrayDeque();

    public EngineBuilder addSystem(Subsystem subsystem)
    {
        subsystems.add(subsystem);
        return this;
    }

    public void Start(Context context){
        while (subsystems.size() > 0){
            Subsystem subsystem = subsystems.remove();
            logger.debug("Loading System:" + subsystem.name());
            subsystem.load(context);
        }
    }

}


text:
<?php

date_default_timezone_set('Europe/Paris');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__.'/../autoload.php';
// Delete the temp test user after all tests have fired
register_shutdown_function(function ()
{
});


text:
package com.diffplug.rcpdemo;

import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.diffplug.common.swt.InteractiveTest;

@Category(InteractiveTest.class)
public class AppGuiTest {
	@Test
	public void test() {
		InteractiveTest.testCoat("AppGui", AppGui::new);
	}
}


text:
package org.apache.hadoop.chukwa.rest.services;

import java.util.*;
import java.sql.*;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.chukwa.database.DatabaseConfig;
import org.apache.hadoop.chukwa.database.Macro;
import org.apache.hadoop.chukwa.util.DatabaseWriter;

import org.apache.hadoop.chukwa.rest.objects.ClusterHadoopRpc;
import org.apache.hadoop.chukwa.rest.services.RestHome;

/**
 * Home object for domain model class ClusterHadoopRpc.
 * @see org.apahe.hadoop.chukwa.rest.objects.ClusterHadoopRpc
 * @author Hibernate Tools
 */
public class ClusterHadoopRpcHome extends RestHome {
    private static String table="[cluster_hadoop_rpc]";
    private static final Log log = LogFactory
	.getLog(ClusterHadoopRpcHome.class);

    /*
     * convert from a result set record to an object
     */
    private static ClusterHadoopRpc createClusterHadoopRpc(ResultSet rs) {
	ClusterHadoopRpc obj = null;
	try {
	    obj = new ClusterHadoopRpc(
						    rs.getTimestamp("timestamp"),
						    rs.getInt("host"),
						    rs.getDouble("rpc_processing_time_avg_time"),
						    rs.getDouble("rpc_processing_time_num_ops"),
						    rs.getDouble("rpc_queue_time_avg_time"),
						    rs.getDouble("rpc_queue_time_num_ops"),
						    rs.getDouble("get_build_version_avg_time"),
						    rs.getDouble("get_build_version_num_ops"),
						    rs.getDouble("get_job_counters_avg_time"),
						    rs.getDouble("get_job_counters_num_ops"),
						    rs.getDouble("get_job_profile_avg_time"),
						    rs.getDouble("get_job_profile_num_ops"),
						    rs.getDouble("get_job_status_avg_time"),
						    rs.getDouble("get_job_status_num_ops"),
						    rs.getDouble("get_new_job_id_avg_time"),
						    rs.getDouble("get_new_job_id_num_ops"),
						    rs.getDouble("get_protocol_version_avg_time"),
						    rs.getDouble("get_protocol_version_num_ops"),
						    rs.getDouble("get_system_dir_avg_time"),
						    rs.getDouble("get_system_dir_num_ops"),
						    rs.getDouble("get_task_completion_events_avg_time"),
						    rs.getDouble("get_task_completion_events_num_ops"),
						    rs.getDouble("get_task_diagnostics_avg_time"),
						    rs.getDouble("get_task_diagnostics_num_ops"),
						    rs.getDouble("heartbeat_avg_time"),
						    rs.getDouble("heartbeat_num_ops"),
						    rs.getDouble("killJob_avg_time"),
						    rs.getDouble("killJob_num_ops"),
						    rs.getDouble("submit_job_avg_time"),
						    rs.getDouble("submit_job_num_ops")
						    );
	} catch (Exception e) {
	}
	return obj;
    }

    /*
     * find by timestamp
     */
    public static ClusterHadoopRpc find(String timestamp) {
	String cluster = getCluster();
	DatabaseWriter dbw = new DatabaseWriter(cluster);

	if (timestamp != null) {
	    // get simple value
            try {
		String query = getSingleQuery(ClusterHadoopRpcHome.table,"timestamp",timestamp);
	    	ResultSet rs = dbw.query(query);
	    	if (rs.next()) {
		    ClusterHadoopRpc obj = createClusterHadoopRpc(rs);
		    return obj;
		}
	    } catch (Exception e) {
		log.error("exception:"+e.toString());
	    }
	} else {
	    // check start time and end time
	}
	return null;
    }

    /*
     * find by key
     */
    public static ClusterHadoopRpc find(String timestamp, String host) {
	String cluster = getCluster();
	DatabaseWriter dbw = new DatabaseWriter(cluster);

	if (timestamp != null) {
	    // get simple value
            try {
		Map<String, String> criteriaMap = new HashMap<String,String>();
		criteriaMap.put("timestamp",convertLongToDateString(Long.parseLong(timestamp)));
		criteriaMap.put("host",host);

		String query = getCriteriaQuery(ClusterHadoopRpcHome.table,criteriaMap);
	    	ResultSet rs = dbw.query(query);
	    	if (rs.next()) {
		    ClusterHadoopRpc obj = createClusterHadoopRpc(rs);
		    return obj;
		}
	    } catch (Exception e) {
		log.error("exception:"+e.toString());
	    }
	} else {
	    // check start time and end time
	}
	return null;
    }

    /*
     * find within the start time and end time
     */
    public static Collection<ClusterHadoopRpc> findBetween(String starttime, String endtime) {
	String cluster = getCluster();
	DatabaseWriter dbw = new DatabaseWriter(cluster);

	Collection<ClusterHadoopRpc> collection = new Vector<ClusterHadoopRpc>();

	try {
	    String query = getTimeBetweenQuery(ClusterHadoopRpcHome.table,starttime,endtime);
	    ResultSet rs = dbw.query(query);
	    while (rs.next()) {
		ClusterHadoopRpc obj = createClusterHadoopRpc(rs);
		collection.add(obj);
	    }
	} catch (Exception e) {
	    log.error("exception:"+e.toString());
	}
	return collection;
    }
}


text:
package com.github.chen0040.leetcode.day07.easy;

/**
 * Created by xschen on 2/8/2017.
 *
 * summary:
 * Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
 * For example, the 32-bit integer '11' has binary representation 00000000000000000000000000001011, so the function should return 3.
 *
 * link: https://leetcode.com/problems/number-of-1-bits/description/
 */
public class NumberOf1Bits {
   public static void main(String[] args) {
      Solution s = new Solution();
      int output = s.hammingWeight(11);
      if(output == 3) {
         System.out.println("verified");
      } else {
         System.out.println(output);
      }
      output = s.hammingWeight( (int) 2147483648L);
      if(output == 1) {
         System.out.println("verified");
      } else {
         System.out.println(output);
      }
      output = s.hammingWeight((int)  4294967295L);
      if(output == 32) {
         System.out.println("verified");
      } else {
         System.out.println(output);
      }
   }
   public static class Solution {
      // you need to treat n as an unsigned value
      public int hammingWeight(int n) {

         int count = 0;
         for(int i=0; i < 32; ++i) {
            count += (n&1) > 0 ? 1 : 0;
            n >>= 1;
         }
         return count;
      }
   }
}


text:
FactoryBot.define do
  factory :test_run do
    association :grouping
    association :user, factory: :admin
    revision_identifier { Faker::Number.hexadecimal(digits: 40) }
  end
end


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Compatibility;

namespace NUnit.Framework.Compatibility
{
    using System.Reflection;

    partial class ReflectionExtensionsTests
    {
        [Test]
        public void CanCallTypeInfoOnAllPlatforms()
        {
            var result = typeof(Object).GetTypeInfo();
            Assert.That(result, Is.Not.Null);
        }
    }
}

namespace NUnit.Framework.Compatibility
{
    using BindingFlags = System.Reflection.BindingFlags;

    /// <summary>
    /// A series of unit tests to ensure that the type extensions in the .NET Standard
    /// framework behave the same as their counterparts in the full framework
    /// </summary>
    [TestFixture]
    public partial class ReflectionExtensionsTests
    {
        [Test]
        public void CanGetGenericArguments()
        {
            var result = typeof(GenericTestClass<string, DateTime>).GetGenericArguments();
            Assert.That(result.Length, Is.EqualTo(2));
            Assert.That(result[0], Is.EqualTo(typeof(string)));
            Assert.That(result[1], Is.EqualTo(typeof(DateTime)));
        }

        [Test]
        public void CanGetConstructors()
        {
            var result = typeof(DerivedTestClass).GetConstructors();
            Assert.That(result.Length, Is.EqualTo(3));
            foreach (var ctor in result)
            {
                Assert.That(ctor.IsStatic, Is.False);
                Assert.That(ctor.IsPublic, Is.True);
            }
        }

        [TestCase(typeof(string))]
        [TestCase(typeof(double))]
        [TestCase(typeof(int))]
        public void CanGetConstructorWithParams(Type paramType)
        {
            var result = typeof(DerivedTestClass).GetConstructor(new[] { paramType });
            Assert.That(result, Is.Not.Null);
        }

        [Test]
        public void CanGetGenericConstructor()
        {
            var result = typeof(GenericTestClass<double, double>)
                .GetConstructor(new[] { typeof(double), typeof(int) });
            Assert.That(result, Is.Not.Null);
        }

        [Test]
        public void IsAssignableFromTest()
        {
            bool pass = typeof(BaseTestClass).IsAssignableFrom(typeof(DerivedTestClass));
            bool fail = typeof(DerivedTestClass).IsAssignableFrom(typeof(BaseTestClass));
            Assert.That(pass, Is.True);
            Assert.That(fail, Is.False);
        }

        [Test]
        public void IsInstanceOfTypeTest()
        {
            var baseClass = new BaseTestClass();
            var derivedClass = new DerivedTestClass();

            Assert.That(typeof(BaseTestClass).IsInstanceOfType(baseClass), Is.True);
            Assert.That(typeof(BaseTestClass).IsInstanceOfType(derivedClass), Is.True);
            Assert.That(typeof(DerivedTestClass).IsInstanceOfType(derivedClass), Is.True);
            Assert.That(typeof(DerivedTestClass).IsInstanceOfType(baseClass), Is.False);
            Assert.That(typeof(DerivedTestClass).IsInstanceOfType(null), Is.False);
        }

        [TestCase(typeof(BaseTestClass), typeof(IDisposable))]
        [TestCase(typeof(DerivedTestClass), typeof(IDisposable))]
        [TestCase(typeof(List<int>), typeof(IList<int>))]
        [TestCase(typeof(List<int>), typeof(IEnumerable<int>))]
        public void CanGetInterfaces(Type type, Type @interface)
        {
            var result = type.GetInterfaces();
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Does.Contain(@interface));
        }

        [TestCase(typeof(BaseTestClass), "Name")]
        [TestCase(typeof(BaseTestClass), "StaticString")]
        [TestCase(typeof(BaseTestClass), "Protected")]
        [TestCase(typeof(BaseTestClass), "Dispose")]
        [TestCase(typeof(BaseTestClass), "Private")]
        [TestCase(typeof(DerivedTestClass), "Name")]
        [TestCase(typeof(DerivedTestClass), "Protected")]
        [TestCase(typeof(DerivedTestClass), "Dispose")]
        public void CanGetMember(Type type, string name)
        {
            var result = type.GetMember(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Length, Is.EqualTo(1));
        }

        [Test]
        public void GetStaticMemberOnBaseClass()
        {
            var result = typeof(DerivedTestClass).GetMember("StaticString", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Length, Is.GreaterThan(0));
        }

        [Test]
        public void CanGetPublicField()
        {
            var result = typeof(DerivedTestClass).GetField("_public");
            Assert.That(result, Is.Not.Null);
        }

        [Test]
        public void DoesNotGetPrivateField()
        {
            var result = typeof(DerivedTestClass).GetField("_private");
            Assert.That(result, Is.Null);
        }

        [TestCase(typeof(BaseTestClass), "Name")]
        [TestCase(typeof(DerivedTestClass), "Name")]
        [TestCase(typeof(BaseTestClass), "StaticString")]
        public void CanGetProperty(Type type, string name)
        {
            var result = type.GetProperty(name);
            Assert.That(result, Is.Not.Null);
        }

        [Test]
        public void DoesNotGetStaticPropertyOnBase()
        {
            var result = typeof(DerivedTestClass).GetProperty("StaticString");
            Assert.That(result, Is.Null);
        }

        [TestCase(typeof(BaseTestClass), "Name", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "Name", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "Private", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "StaticString", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, false)]
        [TestCase(typeof(DerivedTestClass), "StaticString", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, false)]
        [TestCase(typeof(BaseTestClass), "Name", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, false)]
        [TestCase(typeof(DerivedTestClass), "Name", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, false)]
        [TestCase(typeof(BaseTestClass), "Private", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, false)]
        [TestCase(typeof(DerivedTestClass), "Private", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, false)]
        [TestCase(typeof(BaseTestClass), "StaticString", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, true)]
        [TestCase(typeof(DerivedTestClass), "StaticString", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, false)]
        [TestCase(typeof(BaseTestClass), "Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "Name", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "Private", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(DerivedTestClass), "Private", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(BaseTestClass), "StaticString", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "StaticString", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(BaseTestClass), "Name", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(DerivedTestClass), "Name", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(BaseTestClass), "Private", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "StaticString", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(DerivedTestClass), "StaticString", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(BaseTestClass), "PubPriv", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "PubPriv", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "PubPriv", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, false)]
        [TestCase(typeof(DerivedTestClass), "PubPriv", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, false)]

        [TestCase(typeof(DerivedTestClass), "Protected", BindingFlags.NonPublic | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "Internal", BindingFlags.NonPublic | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "Protected", BindingFlags.NonPublic | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "Internal", BindingFlags.NonPublic | BindingFlags.Instance, true)]
        public void CanGetPropertyWithBindingFlags(Type type, string name, BindingFlags flags, bool shouldFind)
        {
            var result = type.GetProperty(name, flags);
            Assert.AreEqual(shouldFind, result != null);
        }

        [TestCase(typeof(BaseTestClass), "Dispose", true)]
        [TestCase(typeof(DerivedTestClass), "Dispose", true)]
        [TestCase(typeof(BaseTestClass), "Goodbye", false)]
        [TestCase(typeof(DerivedTestClass), "Goodbye", false)]
        public void CanGetMethodByName(Type type, string name, bool shouldFind)
        {
            var result = type.GetMethod(name);
            Assert.AreEqual(shouldFind, result != null);
        }

        [TestCase(typeof(BaseTestClass), "Hello", new Type[] { }, true)]
        [TestCase(typeof(DerivedTestClass), "Hello", new Type[] { }, true)]
        [TestCase(typeof(BaseTestClass), "Hello", new Type[] { typeof(string) }, true)]
        [TestCase(typeof(DerivedTestClass), "Hello", new Type[] { typeof(string) }, true)]
        [TestCase(typeof(BaseTestClass), "Goodbye", new Type[] { typeof(double) }, false)]
        [TestCase(typeof(DerivedTestClass), "Goodbye", new Type[] { typeof(int) }, false)]
        public void CanGetMethodByNameAndArgs(Type type, string name, Type[] args, bool shouldFind)
        {
            var result = type.GetMethod(name, args);
            Assert.AreEqual(shouldFind, result != null);
        }

        [TestCase(typeof(BaseTestClass), "Dispose", BindingFlags.Public | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "Dispose", BindingFlags.Public | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "Dispose", BindingFlags.Public | BindingFlags.Instance, true)]
        [TestCase(typeof(DerivedTestClass), "Dispose", BindingFlags.Public | BindingFlags.Instance, true)]
        [TestCase(typeof(BaseTestClass), "StaticMethod", BindingFlags.Public | BindingFlags.Static, true)]
        [TestCase(typeof(DerivedTestClass), "StaticMethod", BindingFlags.Public | BindingFlags.Static, false)]
        [TestCase(typeof(BaseTestClass), "Goodbye", BindingFlags.NonPublic | BindingFlags.Instance, true)]
        public void CanGetMethodByNameAndBindingFlags(Type type, string name, BindingFlags flags, bool shouldFind)
        {
            var result = type.GetMethod(name, flags);
            Assert.AreEqual(shouldFind, result != null);
        }

        [Test]
        public void CanGetDerivedMethodsOnly()
        {
            var result = typeof(DerivedTestClass).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
            var methodNames = result.Select(m => m.Name);
            CollectionAssert.AreEquivalent(methodNames, new string[] { "Hello", "Hello", "DerivedInstanceMethod" });
        }

        [TestCase(BindingFlags.Instance | BindingFlags.Public,
            new[] { "DerivedInstanceMethod", "InstanceMethod" },
            new[] { "DerivedProtectedInstanceMethod", "DerivedPrivateInstanceMethod", "ProtectedInstanceMethod", "PrivateInstanceMethod" })]
        [TestCase(BindingFlags.Instance | BindingFlags.NonPublic,
            new[] { "DerivedProtectedInstanceMethod", "DerivedPrivateInstanceMethod", "ProtectedInstanceMethod" },
            new[] { "DerivedInstanceMethod", "InstanceMethod", "PrivateInstanceMethod" })]
        [TestCase(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly,
            new[] { "DerivedInstanceMethod" },
            new[] { "DerivedProtectedInstanceMethod", "DerivedPrivateInstanceMethod", "InstanceMethod", "ProtectedInstanceMethod", "PrivateInstanceMethod" })]
        [TestCase(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly,
            new[] { "DerivedProtectedInstanceMethod", "DerivedPrivateInstanceMethod" },
            new[] { "InstanceMethod", "DerivedInstanceMethod", "ProtectedInstanceMethod", "PrivateInstanceMethod" })]
        public void InstanceCanGetMethodsFromCurrentAndFromBaseClass(BindingFlags flags, string[] containElements, string[] wrongElements)
        {
            var result = typeof(DerivedTestClass).GetMethods(flags);
            var methodNames = result.Select(m => m.Name);

            CollectionAssert.IsSubsetOf(containElements, methodNames);
            foreach (var wrongElement in wrongElements)
            {
                Assert.That(methodNames, Does.Not.Contain(wrongElement));
            }
        }

        [TestCase(
            BindingFlags.Static | BindingFlags.Public,
            new[] { "DerivedStaticMethod" },
            new[] { "DerivedProtectedStaticMethod", "DerivedPrivateStaticMethod" })]
        [TestCase(
            BindingFlags.Static | BindingFlags.NonPublic,
            new[] { "DerivedProtectedStaticMethod", "DerivedPrivateStaticMethod" },
            new[] { "DerivedStaticMethod" })]
        [TestCase(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy,
            new[] { "DerivedStaticMethod", "StaticMethod", },
            new[] { "DerivedProtectedStaticMethod", "ProtectedStaticMethod" })]
        [TestCase(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy,
            new[] { "DerivedProtectedStaticMethod", "DerivedPrivateStaticMethod", "ProtectedStaticMethod" },
            new[] { "DerivedStaticMethod", "StaticMethod" })]
        public void StaticCanGetMethodsFromCurrentAndFromBaseClass(BindingFlags flags, string[] containElements, string[] wrongElements)
        {
            var result = typeof(DerivedTestClass).GetMethods(flags);
            var methodNames = result.Select(m => m.Name);

            CollectionAssert.IsSubsetOf(containElements, methodNames);
            foreach (var wrongElement in wrongElements)
            {
                Assert.That(methodNames, Does.Not.Contain(wrongElement));
            }
        }

        [Test]
        public void CanGetStaticMethodsOnBase()
        {
            var result = typeof(DerivedTestClass).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            foreach (var info in result)
            {
                if (info.Name == "StaticMethod")
                    Assert.Pass();
            }
            Assert.Fail("Did not find StaticMethod on the base class");
        }

        [TestCase(BindingFlags.Static)]
        [TestCase(BindingFlags.FlattenHierarchy)]
        [TestCase(BindingFlags.Default)]
        public void DoesNotFindStaticMethodsOnBase(BindingFlags flags)
        {
            var result = typeof(DerivedTestClass).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | flags);
            foreach (var info in result)
            {
                if (info.Name == "StaticMethod")
                    Assert.Fail("Should not have found StaticMethod on the base class");
            }
        }

        [TestCase("Name", false, true)]
        [TestCase("Name", true, true)]
        [TestCase("Private", false, false)]
        [TestCase("Private", true, true)]
        public void CanGetGetMethod(string name, bool nonPublic, bool shouldFind)
        {
            var pinfo = typeof(BaseTestClass).GetProperty(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            Assert.That(pinfo, Is.Not.Null);
            var minfo = pinfo.GetGetMethod(nonPublic);
            Assert.That(minfo != null, Is.EqualTo(shouldFind));
        }

        [Test]
        public void CanGetAttributesUsingAnInterface()
        {
            var method = typeof(ReflectionExtensionsTests).GetMethod("CanGetAttributesUsingAnInterface");
            Assert.That(method, Is.Not.Null);
            var attr = method.GetAttributes<ITestAction>(false);
            Assert.That(attr, Is.Not.Null);
        }

        [Test]
        public void CanHandleNoGetterPropertyMember()
        {
            var result = typeof(NoGetterPropertyDerivedClass).GetMember("NoGetter", BindingFlags.Default);
            Assert.That(result, Is.Not.Null);
        }
    }

    public class BaseTestClass : IDisposable
    {
        public static string StaticString { get; set; }

        protected string Protected { get; set; }

        internal string Internal { get; set; }

        public string Name { get; set; }

        private string Private { get; set; }

        public string PubPriv { get; private set; }

        public BaseTestClass() : this("Joe") { }

        public BaseTestClass(string name) { Name = name; }

        public virtual void Hello() { }

        public virtual void Hello(string msg) { }

        public void InstanceMethod() { }

        protected void ProtectedInstanceMethod() { }

        private void PrivateInstanceMethod() { }

        public static void StaticMethod() { }

        protected static void ProtectedStaticMethod() { }

        private static void PrivateStaticMethod() { }

        private void Goodbye(double d) { }

        public void Dispose() { }
    }

    public class DerivedTestClass : BaseTestClass
    {
#pragma warning disable 0169
        private string _private;
#pragma warning restore
        public string _public;

        static DerivedTestClass() { StaticString = "static"; }

        public DerivedTestClass() : this("Rob") { }

        public DerivedTestClass(string name) : base(name) { }

        public DerivedTestClass(double d) : this(d.ToString()) { }

        private DerivedTestClass(StringBuilder name) : this(name.ToString()) { }

        public void DerivedInstanceMethod() { }

        protected void DerivedProtectedInstanceMethod() { }

        private void DerivedPrivateInstanceMethod() { }

        public static void DerivedStaticMethod() { }

        protected static void DerivedProtectedStaticMethod() { }

        private static void DerivedPrivateStaticMethod() { }

        public override void Hello() { }

        public override void Hello(string msg) { }
    }

    public class GenericTestClass<T1, T2>
    {
        public T1 PropertyOne { get; set; }
        public T2 PropertyTwo { get; set; }

        public GenericTestClass(T1 one, T2 two)
        {
            PropertyOne = one;
            PropertyTwo = two;
        }
    }

    public class NoGetterPropertyBaseClass
    {
        public string NoGetter { set { } }
    }

    public class NoGetterPropertyDerivedClass : NoGetterPropertyBaseClass
    {
    }
}


text: sap.ui.define(['sap/m/semantic/SemanticButton'],function(S){"use strict";var D=S.extend("sap.m.semantic.DiscussInJamAction",{});return D;},true);


text:
/**
 * @file tinybson.c
 *
 * A simple subset SAX-style BSON parser and generator.
 */

#include <px4_platform_common/posix.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <systemlib/err.h>

#include "tinybson.h"

#if 0
# define debug(fmt, args...)		do { PX4_INFO("BSON: " fmt, ##args); } while(0)
#else
# define debug(fmt, args...)		do { } while(0)
#endif

#define CODER_CHECK(_c)		do { if (_c->dead) { debug("coder dead"); return -1; }} while(0)
#define CODER_KILL(_c, _reason)	do { debug("killed: %s", _reason); _c->dead = true; return -1; } while(0)

#define BSON_READ  read
#define BSON_WRITE write
#define BSON_FSYNC fsync

static int
read_x(bson_decoder_t decoder, void *p, size_t s)
{
	CODER_CHECK(decoder);

	if (decoder->fd > -1) {
		return (BSON_READ(decoder->fd, p, s) == s) ? 0 : -1;
	}

	if (decoder->buf != nullptr) {
		/* staged operations to avoid integer overflow for corrupt data */
		if (s >= decoder->bufsize) {
			CODER_KILL(decoder, "buffer too small for read");
		}

		if ((decoder->bufsize - s) < decoder->bufpos) {
			CODER_KILL(decoder, "not enough data for read");
		}

		memcpy(p, (decoder->buf + decoder->bufpos), s);
		decoder->bufpos += s;
		return 0;
	}

	debug("no source");
	return -1;
}

static int
read_int8(bson_decoder_t decoder, int8_t *b)
{
	return read_x(decoder, b, sizeof(*b));
}

static int
read_int32(bson_decoder_t decoder, int32_t *i)
{
	return read_x(decoder, i, sizeof(*i));
}

static int
read_int64(bson_decoder_t decoder, int64_t *i)
{
	return read_x(decoder, i, sizeof(*i));
}

static int
read_double(bson_decoder_t decoder, double *d)
{
	return read_x(decoder, d, sizeof(*d));
}

int
bson_decoder_init_file(bson_decoder_t decoder, int fd, bson_decoder_callback callback, void *priv)
{
	int32_t	junk;

	decoder->fd = fd;
	decoder->buf = nullptr;
	decoder->dead = false;
	decoder->callback = callback;
	decoder->priv = priv;
	decoder->nesting = 1;
	decoder->pending = 0;
	decoder->node.type = BSON_UNDEFINED;

	/* read and discard document size */
	if (read_int32(decoder, &junk)) {
		CODER_KILL(decoder, "failed discarding length");
	}

	/* ready for decoding */
	return 0;
}

int
bson_decoder_init_buf(bson_decoder_t decoder, void *buf, unsigned bufsize, bson_decoder_callback callback,
		      void *priv)
{
	int32_t	len;

	/* argument sanity */
	if ((buf == nullptr) || (callback == nullptr)) {
		return -1;
	}

	decoder->fd = -1;
	decoder->buf = (uint8_t *)buf;
	decoder->dead = false;

	if (bufsize == 0) {
		decoder->bufsize = *(uint32_t *)buf;
		debug("auto-detected %u byte object", decoder->bufsize);

	} else {
		decoder->bufsize = bufsize;
	}

	decoder->bufpos = 0;
	decoder->callback = callback;
	decoder->priv = priv;
	decoder->nesting = 1;
	decoder->pending = 0;
	decoder->node.type = BSON_UNDEFINED;

	/* read and discard document size */
	if (read_int32(decoder, &len)) {
		CODER_KILL(decoder, "failed reading length");
	}

	if ((len > 0) && (len > (int)decoder->bufsize)) {
		CODER_KILL(decoder, "document length larger than buffer");
	}

	/* ready for decoding */
	return 0;
}

int
bson_decoder_next(bson_decoder_t decoder)
{
	int8_t	tbyte;
	int32_t tint;
	unsigned nlen;

	CODER_CHECK(decoder);

	/* if the previous node was EOO, pop a nesting level */
	if (decoder->node.type == BSON_EOO) {
		if (decoder->nesting > 0) {
			decoder->nesting--;
		}

		/* if the nesting level is now zero, the top-level document is done */
		if (decoder->nesting == 0) {
			/* like kill but not an error */
			debug("nesting is zero, document is done");
			decoder->fd = -1;

			/* return end-of-file to the caller */
			return 0;
		}
	}

	/* if there are unread bytes pending in the stream, discard them */
	while (decoder->pending > 0) {
		if (read_int8(decoder, &tbyte)) {
			CODER_KILL(decoder, "read error discarding pending bytes");
		}

		decoder->pending--;
	}

	/* get the type byte */
	if (read_int8(decoder, &tbyte)) {
		CODER_KILL(decoder, "read error on type byte");
	}

	decoder->node.type = (bson_type_t)tbyte;
	decoder->pending = 0;

	debug("got type byte 0x%02x", decoder->node.type);

	/* EOO is special; it has no name/data following */
	if (decoder->node.type == BSON_EOO) {
		decoder->node.name[0] = '\0';

	} else {

		/* get the node name */
		nlen = 0;

		for (;;) {
			if (nlen >= BSON_MAXNAME) {
				CODER_KILL(decoder, "node name overflow");
			}

			if (read_int8(decoder, (int8_t *)&decoder->node.name[nlen])) {
				CODER_KILL(decoder, "read error on node name");
			}

			if (decoder->node.name[nlen] == '\0') {
				break;
			}

			nlen++;
		}

		debug("got name '%s'", decoder->node.name);

		switch (decoder->node.type) {
		case BSON_BOOL:
			if (read_int8(decoder, &tbyte)) {
				CODER_KILL(decoder, "read error on BSON_BOOL");
			}

			decoder->node.b = (tbyte != 0);
			break;

		case BSON_INT32:
			if (read_int32(decoder, &tint)) {
				CODER_KILL(decoder, "read error on BSON_INT");
			}

			decoder->node.i = tint;
			break;

		case BSON_INT64:
			if (read_int64(decoder, &decoder->node.i)) {
				CODER_KILL(decoder, "read error on BSON_INT");
			}

			break;

		case BSON_DOUBLE:
			if (read_double(decoder, &decoder->node.d)) {
				CODER_KILL(decoder, "read error on BSON_DOUBLE");
			}

			break;

		case BSON_STRING:
			if (read_int32(decoder, &decoder->pending)) {
				CODER_KILL(decoder, "read error on BSON_STRING length");
			}

			break;

		case BSON_BINDATA:
			if (read_int32(decoder, &decoder->pending)) {
				CODER_KILL(decoder, "read error on BSON_BINDATA size");
			}

			if (read_int8(decoder, &tbyte)) {
				CODER_KILL(decoder, "read error on BSON_BINDATA subtype");
			}

			decoder->node.subtype = (bson_binary_subtype_t)tbyte;
			break;

		/* XXX currently not supporting other types */
		default:
			CODER_KILL(decoder, "unsupported node type");
		}
	}

	/* call the callback and pass its results back */
	return decoder->callback(decoder, decoder->priv, &decoder->node);
}

int
bson_decoder_copy_data(bson_decoder_t decoder, void *buf)
{
	int result;

	CODER_CHECK(decoder);

	/* copy data */
	result = read_x(decoder, buf, decoder->pending);

	if (result != 0) {
		CODER_KILL(decoder, "read error on copy_data");
	}

	/* pending count is discharged */
	decoder->pending = 0;
	return 0;
}

size_t
bson_decoder_data_pending(bson_decoder_t decoder)
{
	return decoder->pending;
}

static int
write_x(bson_encoder_t encoder, const void *p, size_t s)
{
	CODER_CHECK(encoder);

	/* bson file encoder (non-buffered) */
	if (encoder->fd > -1 && encoder->buf == nullptr) {
		return (BSON_WRITE(encoder->fd, p, s) == (int)s) ? 0 : -1;
	}

	/* do we need to extend the buffer? */
	while ((encoder->bufpos + s) > encoder->bufsize) {

		/* bson buffered file encoder */
		if (encoder->fd > -1) {
			// write to disk
			debug("writing buffer (%d) to disk", encoder->bufpos);
			int ret = BSON_WRITE(encoder->fd, encoder->buf, encoder->bufpos);

			if (ret == (int)encoder->bufpos) {
				// reset buffer to beginning and continue
				encoder->bufpos = 0;

				if ((encoder->bufpos + s) > encoder->bufsize) {
					CODER_KILL(encoder, "fixed-size buffer overflow");
				}

				break;

			} else {
				CODER_KILL(encoder, "file write error");
			}
		}

		if (!encoder->realloc_ok) {
			CODER_KILL(encoder, "fixed-size buffer overflow");
		}

		uint8_t *newbuf = (uint8_t *)realloc(encoder->buf, encoder->bufsize + BSON_BUF_INCREMENT);

		if (newbuf == nullptr) {
			CODER_KILL(encoder, "could not grow buffer");
		}

		encoder->buf = newbuf;
		encoder->bufsize += BSON_BUF_INCREMENT;
		debug("allocated %d bytes", BSON_BUF_INCREMENT);
	}

	memcpy(encoder->buf + encoder->bufpos, p, s);
	encoder->bufpos += s;
	debug("appended %d bytes", s);

	return 0;
}

static int
write_int8(bson_encoder_t encoder, int8_t b)
{
	return write_x(encoder, &b, sizeof(b));
}

static int
write_int32(bson_encoder_t encoder, int32_t i)
{
	return write_x(encoder, &i, sizeof(i));
}

static int
write_int64(bson_encoder_t encoder, int64_t i)
{
	return write_x(encoder, &i, sizeof(i));
}

static int
write_double(bson_encoder_t encoder, double d)
{
	return write_x(encoder, &d, sizeof(d));
}

static int
write_name(bson_encoder_t encoder, const char *name)
{
	size_t len = strlen(name);

	if (len > BSON_MAXNAME) {
		CODER_KILL(encoder, "node name too long");
	}

	return write_x(encoder, name, len + 1);
}

int
bson_encoder_init_file(bson_encoder_t encoder, int fd)
{
	encoder->fd = fd;
	encoder->buf = nullptr;
	encoder->dead = false;

	if (write_int32(encoder, 0)) {
		CODER_KILL(encoder, "write error on document length");
	}

	return 0;
}

int
bson_encoder_init_buf_file(bson_encoder_t encoder, int fd, void *buf, unsigned bufsize)
{
	encoder->fd = fd;
	encoder->buf = (uint8_t *)buf;
	encoder->bufpos = 0;
	encoder->bufsize = bufsize;
	encoder->dead = false;
	encoder->realloc_ok = false;

	if (write_int32(encoder, 0)) {
		CODER_KILL(encoder, "write error on document length");
	}

	return 0;
}

int
bson_encoder_init_buf(bson_encoder_t encoder, void *buf, unsigned bufsize)
{
	encoder->fd = -1;
	encoder->buf = (uint8_t *)buf;
	encoder->bufpos = 0;
	encoder->dead = false;

	if (encoder->buf == nullptr) {
		encoder->bufsize = 0;
		encoder->realloc_ok = true;

	} else {
		encoder->bufsize = bufsize;
		encoder->realloc_ok = false;
	}

	if (write_int32(encoder, 0)) {
		CODER_KILL(encoder, "write error on document length");
	}

	return 0;
}

int
bson_encoder_fini(bson_encoder_t encoder)
{
	CODER_CHECK(encoder);

	if (write_int8(encoder, BSON_EOO)) {
		CODER_KILL(encoder, "write error on document terminator");
	}

	if (encoder->fd > -1 && encoder->buf != nullptr) {
		/* write final buffer to disk */
		int ret = BSON_WRITE(encoder->fd, encoder->buf, encoder->bufpos);

		if (ret != (int)encoder->bufpos) {
			CODER_KILL(encoder, "write error");
		}

	} else if (encoder->buf != nullptr) {
		/* update buffer length */
		int32_t len = bson_encoder_buf_size(encoder);
		memcpy(encoder->buf, &len, sizeof(len));
	}

	/* sync file */
	if (encoder->fd > -1) {
		BSON_FSYNC(encoder->fd);
	}

	return 0;
}

int
bson_encoder_buf_size(bson_encoder_t encoder)
{
	CODER_CHECK(encoder);

	if (encoder->fd > -1) {
		return -1;
	}

	return encoder->bufpos;
}

void *
bson_encoder_buf_data(bson_encoder_t encoder)
{
	/* note, no CODER_CHECK here as the caller has to clean up dead buffers */

	if (encoder->fd > -1) {
		return nullptr;
	}

	return encoder->buf;
}

int bson_encoder_append_bool(bson_encoder_t encoder, const char *name, bool value)
{
	CODER_CHECK(encoder);

	if (write_int8(encoder, BSON_BOOL) ||
	    write_name(encoder, name) ||
	    write_int8(encoder, value ? 1 : 0)) {
		CODER_KILL(encoder, "write error on BSON_BOOL");
	}

	return 0;
}

int
bson_encoder_append_int(bson_encoder_t encoder, const char *name, int64_t value)
{
	bool result;

	CODER_CHECK(encoder);

	/* use the smallest encoding that will hold the value */
	if (value == (int32_t)value) {
		debug("encoding %lld as int32", value);
		result = write_int8(encoder, BSON_INT32) ||
			 write_name(encoder, name) ||
			 write_int32(encoder, value);

	} else {
		debug("encoding %lld as int64", value);
		result = write_int8(encoder, BSON_INT64) ||
			 write_name(encoder, name) ||
			 write_int64(encoder, value);
	}

	if (result) {
		CODER_KILL(encoder, "write error on BSON_INT");
	}

	return 0;
}

int
bson_encoder_append_double(bson_encoder_t encoder, const char *name, double value)
{
	CODER_CHECK(encoder);

	if (write_int8(encoder, BSON_DOUBLE) ||
	    write_name(encoder, name) ||
	    write_double(encoder, value)) {
		CODER_KILL(encoder, "write error on BSON_DOUBLE");
	}

	return 0;
}

int
bson_encoder_append_string(bson_encoder_t encoder, const char *name, const char *string)
{
	size_t len;

	CODER_CHECK(encoder);

	len = strlen(string) + 1;	/* include trailing nul */

	if (write_int8(encoder, BSON_STRING) ||
	    write_name(encoder, name) ||
	    write_int32(encoder, len) ||
	    write_x(encoder, string, len)) {
		CODER_KILL(encoder, "write error on BSON_STRING");
	}

	return 0;
}

int
bson_encoder_append_binary(bson_encoder_t encoder, const char *name, bson_binary_subtype_t subtype, size_t size,
			   const void *data)
{
	CODER_CHECK(encoder);

	if (write_int8(encoder, BSON_BINDATA) ||
	    write_name(encoder, name) ||
	    write_int32(encoder, size) ||
	    write_int8(encoder, subtype) ||
	    write_x(encoder, data, size)) {
		CODER_KILL(encoder, "write error on BSON_BINDATA");
	}

	return 0;
}


text:
{% load humanize %}

# Done/All Tasks

                  {{board.number_of_done_tasks}}/{{board.number_of_tasks}}
                  {% if member %}

                        New

                  {% endif %}

Spent Time

                {{board.get_spent_time|floatformat:-2}} hours

Adj. Spent Time

                {{board.get_adjusted_spent_time|floatformat:-2}} hours

                    Last month was {{board.get_working_end_date|date:"F Y"}}

                      {{board.last_working_month_spent_time|floatformat:-2}} hours
                      ({{board.last_working_month_adjusted_spent_time|floatformat:-2}} adjusted hours)

Dev. Value

                {{board.get_developed_value|floatformat:-2}} ¤

Adj. Dev. Value

                {{board.get_adjusted_developed_value|floatformat:-2}} ¤

# Comments

                {{board.number_of_comments}}

# Members

                {{board.members.all.count}}

Avg. Week Vel.

                {{board.average_weekly_spent_time|floatformat:-2}} hours

Last Week Vel.

                {{board.last_weekly_spent_time|floatformat:-2}} hours

        {% if board.estimated_number_of_hours %}

Completion

                    {{board.percentage_of_completion}} %

        {% endif %}

        {% if next_due_date_cards|length > 0 %}

Next due date cards

Next deadline is {{next_due_date_cards.0.due_datetime}} ({{next_due_date_cards.0.due_datetime|naturaltime}})

                          {% for next_due_date_card in next_due_date_cards %}

                                        {{next_due_date_card.name}}

                                    {{next_due_date_card.list.get_type_display}}

                                        ({{next_due_date_card.due_datetime}}, {{next_due_date_card.due_datetime|naturaltime}})

                          {% endfor %}

        {% endif %}


text:
namespace aerys
{
  namespace qark
  {
    class Qark
    {
    public:
      static const int                  MAGIC                   = 0x3121322b;

      static const int                  FLAG_NONE               = 0;
      static const int                  FLAG_GZIP               = 1;
      static const int                  FLAG_DEFLATE            = 2;

      static const int                  TYPE_CUSTOM             = 0;
      static const int                  TYPE_OBJECT             = 1;
      static const int                  TYPE_ARRAY              = 2;
      static const int                  TYPE_INT                = 3;
      static const int                  TYPE_UINT               = 4;
      static const int                  TYPE_FLOAT              = 5;
      static const int                  TYPE_STRING             = 6;
      static const int                  TYPE_BYTES              = 7;
      static const int                  TYPE_BOOLEAN            = 8;
      static const int                  TYPE_BITMAP_DATA        = 9;

      typedef std::vector<char>         ByteArray;
      typedef boost::any                Object;
      typedef std::string               String;
      typedef std::list<Object>         Array;
      typedef std::map<String, Object>  Map;

      typedef void (*Encoder)(std::ostream&, const Object&);
      typedef void (*Decoder)(std::istream&, Object&);

    public:
      static ByteArray encode(const Object& source)
      {
        boost::asio::streambuf buffer;
        std::ostream stream(&buffer);

        int magic = MAGIC;
        write(stream, magic);
        encodeRecursive(stream, source);

        const char* data = boost::asio::buffer_cast<const char*>(buffer.data());
        std::size_t size = buffer.size();

        return ByteArray(data, data + size);
      }

      static Object decode(const ByteArray& source)
      {
        boost::asio::streambuf buffer;
        std::iostream stream(&buffer);

        stream.write(&*source.begin(), source.size());

        int magic = 0;
        read(stream, magic);

        if (magic != MAGIC)
          return Object();

        Object result;
        decodeRecursive(stream, result);
        return result;
      }

    private:
      static int getType(const Object& source)
      {
        if (source.type() == typeid(int))
          return TYPE_INT;
        if (source.type() == typeid(unsigned int))
          return TYPE_UINT;
        if (source.type() == typeid(float))
          return TYPE_FLOAT;
        if (source.type() == typeid(String))
          return TYPE_STRING;
        if (source.type() == typeid(Array))
          return TYPE_ARRAY;
        if (source.type() == typeid(ByteArray))
          return TYPE_BYTES;
        if (source.type() == typeid(bool))
          return TYPE_BOOLEAN;
        if (source.type() == typeid(Map))
          return TYPE_OBJECT;

        return TYPE_CUSTOM;
      }

      static Encoder getEncoder(char flag)
      {
        static std::map<char, Encoder> encoders;

        if (encoders.empty())
        {
          encoders[TYPE_INT] = &Qark::encodeTrivial<int>;
        }

        return encoders[flag];
      }

      static Decoder getDecoder(char flag)
      {
        static std::map<char, Decoder> decoders;

        if (decoders.empty())
        {
          decoders[TYPE_INT] = &Qark::decodeTrivial<int>;
        }

        return decoders[flag];
      }

      static void encodeRecursive(std::ostream& target, const Object& source)
      {
        char flag = getType(source);
        write(target, flag);

        Encoder f = getEncoder(flag);
        f(target, source);
      }

      static void decodeRecursive(std::istream& source, Object& target)
      {
        char flag = 0;
        read(source, flag);

        Decoder f = getDecoder(flag);
        f(source, target);
      }

      template <typename T>
      static void
      write(std::ostream& stream, const T& value)
      {
        stream.write(reinterpret_cast<const char*>(&value), sizeof (T));
      }

      template <typename T>
      static void
      read(std::istream& stream, T& value)
      {
        stream.read(reinterpret_cast<char*>(&value), sizeof (T));
      }

      template <typename T>
      static void
      encodeTrivial(std::ostream& stream, const Object& value)
      {
        write(stream, boost::any_cast<const T&>(value));
      }

      template <typename T>
      static void
      decodeTrivial(std::istream& stream, Object& value)
      {
        value = T();
        read(stream, boost::any_cast<T&>(value));
      }

      static void
      encodeString(std::ostream& stream, const String& value)
      {
        unsigned short size = value.size();

        write(stream, size);
        stream.write(value.c_str(), size);
      }

      static void
      decodeString(std::istream& stream, String& value)
      {
        // FIXME: Doesn't work with non-ASCI strings.
        unsigned short size = 0;
        read(stream, size);

        char data[size];
        stream.read(data, size);
        value.assign(data, size);
      }
    };
  }
}


text:
namespace ast {
class Expression;
}

namespace parser {
ast::Expression* Binary(int precedence, ast::Expression* lhs);
}  // end namespace parser

#endif


text:
'use strict';

Object.defineProperty(exports, '__esModule', {
    value: true
});
/**
 * @function createEnsureAvailabilityFn - creates function that throws error if instance was destroyed
 * @param {String} key - key that is truthy when object is destroyed
 * @param {String} [customMessage] - custom message for the error
 * @access public
 * @returns {Function} ensureAvailability
 */
exports.createEnsureAvailabilityFn = createEnsureAvailabilityFn;

/**
 * @function defineProperty - shorthand for Object.defineProperty
 *     mostly for creating public getters and setters
 * @access public
 * @param {Object} object - object to set property on
 * @param {String} publicName - name of property
 * @param {Object} conf - configuration object
 *     @property {String|Function} get - getter function or name of private property that should be returned
 *     @property {Function} [set=defaultSetter] - setter function; if not passed, creates read-only property
 *     @property {Function} [before=noop] - function that has to be called before getter or setter
 *         no matter what it returns, following function will be called (unless it throws error...)
 */
exports.defineProperty = defineProperty;

function createEnsureAvailabilityFn(key, customMessage) {
    var message = customMessage || 'instance was destroyed and it is useless now';

    /**
     * @function ensureAvailability - throws error if object (or non-window this context if not provided) says it was destroyed
     * @param {Object} object - object to check
     */
    return function ensureAvailability(object) {
        var o = object;
        if ('undefined' === typeof o) {
            if (this !== window) {
                o = this;
            }
        }

        if (o[key]) {
            throw new Error(message);
        }
    };
}

function defineProperty(object, publicName, conf) {
    var _arguments = arguments;

    var _get = 'function' === typeof conf.get ? conf.get : function () {
        return object[conf.get];
    };
    var _set = 'function' === typeof conf.set ? conf.set : function () {
        return object[conf.set];
    };
    var before = 'function' === typeof conf.before ? conf.before : function () {};

    Object.defineProperty(object, publicName, {
        get: function get() {
            before.apply(object, _arguments);

            return _get.apply(object, _arguments);
        },
        set: function set() {
            before.apply(object, _arguments);

            return _set.apply(object, _arguments);
        }
    });
}


text:
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 */
/*
 * 修改Extjs4默认字体
 */
.x-btn-default-small .x-btn-inner,
.x-btn-default-medium .x-btn-inner,
.x-btn-default-large .x-btn-inner,
.x-btn-default-toolbar-small .x-btn-inner,
.x-btn-default-toolbar-medium .x-btn-inner,
.x-btn-default-toolbar-large .x-btn-inner,
.x-menu-item-text,
.x-html-editor-tb .x-font-select,
.x-panel-header-default,
.x-panel-header-text-default,
.x-panel-header-default-framed,
.x-tip-header,
.x-tip-body,
.x-form-invalid-tip-body,
.x-tip-header-text,
.x-progress-text,
.x-toolbar,
.x-toolbar
.x-form-item-label,
.x-toolbar .x-toolbar-text,
.x-window-header-text-default,
.x-tab-bar,
.x-tab button,
.x-grid-rowbody,
.x-grid-row .x-grid-cell,
.x-grid-group-title,
.x-grid-row-editor .x-form-field,
.x-grid-row-editor .x-form-display-field,
.x-form-invalid-under,
.x-fieldset-header,
.x-column-header,
.x-mask-msg div,
.x-btn-group-header-text-default-framed,
table.x-datepicker-inner a,
.x-monthpicker-item,
.x-dd-drag-ghost  {
    font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", sans-serif;
    font-size: 12px;
}

.netopt-ctc-logo {
    background: url(/images/ctclogo.png) no-repeat center center;
}

.ni-24-user {
    background: url(/images/user.png) no-repeat center center;
}

/*
 * Gear Loading Screen Background
 */
.x-mask.gearloading {
    background-color: white;
    opacity: 1;

}

/*
 * Gear Loading Screen
 */
.x-mask-msg.gearloading,
.x-mask-msg.gearloading div {
    font-size: 24px;
    font-weight: bold;
    border: none;
    background-color: transparent;
    background-position: top center;
}

.gear-loading-icon {
    background: url('/images/loading.gif') no-repeat center center !important;
    height: 160px;
}

.gearloading .x-mask-msg-text {
    background: none;
}

/*
 * 32px icon 定义
 */
.np-wnd-key {
    background: url('/images/np-icons-32.png') -0px -0px no-repeat !important;
    width: 32;
    height: 32;
}

.np-wnd-login {
    background: url('/images/np-icons-32.png') -0px -32px no-repeat !important;
    width: 32;
    height: 32;
}

#body .x-body {
    background: #00FF00 url("/images/vp-bak.png") repeat ;
}


text:
define(['app', 'angular-form-controls', '/app/js/directives/afc-file.js', '/app/js/services/filters/linkify.js', '/app/js/services/filters/thumbnail.js',], function(app) {
    app.directive('elink', function() {
        return {
            restrict: 'EAC',
            templateUrl: '/app/js/directives/elink.html',
            scope: {
                ngModel: '=',
                typeTitle: '@',
                imgPreview: '@?',
                autocomplete: '=?',
                notFile: '@?',
            },
            controller: function($scope, IStorage, $rootScope) {
                $scope.url = '';
                console.log('autocompete:', $scope.autocomplete);

                //TODO: both ngTagsToArray are duplicated in edit.js and editProject.js
                function ngTagsToArray(fake, real, realKey) {
                    real[realKey] = [];
                    for(var i=0; i!=fake.length; ++i)
                        real[realKey].push(fake[i].text);
                }

                $scope.addItem = function(newItem) {
                    if(!$scope.ngModel) //This is becaus eof how retarded lifeweb data is... requiring undefined... so fucking dumb
                        $scope.ngModel = [];
                    $scope.ngModel.push(angular.copy(newItem));
                    $scope.newItem = {};
                };

                //TODO: make a directive for this or something... i do this everywhere...
                $scope.maybeAddItem = function($event, newItem) {
                  if($event.which == 13) {
                    $scope.addItem(newItem);
                    console.log('ngmodel: ', $scope.ngModel);
                    $event.preventDefault();
                   }
                };

                app.controller('keywordsUsingController', function($scope) {
                    $scope.fakeKeywords = [];
                    $scope.item.keywords = $scope.item.keywords || [];
                    for(var i=0; i!=$scope.item.keywords.length; ++i)
                        $scope.fakeKeywords.push($scope.item.keywords[i]);
                    $scope.$watch('fakeKeywords', function() {
                        ngTagsToArray($scope.fakeKeywords, $scope.item, 'keywords');
                    }, true);
                });
            },
        };
    })
});


text:
@class XLDataStore;

@interface XLDataSectionStore : NSObject

+ (instancetype)dataSectionStore;
+ (instancetype)dataSectionStoreWithTitle:(NSString *)title;

@property (weak) XLDataStore * dataStore;

@property (readonly) NSString * title;

- (NSUInteger)numberOfItems;

- (id)dataAtIndex:(NSUInteger)index;
- (void)addDataItem:(id)item;
- (void)addDataItems:(NSArray *)items;
- (void)addDataItems:(NSArray *)items fromIndex:(NSUInteger)index;
- (void)removeDataItemAtIndex:(NSUInteger)indexPath;
- (BOOL)removeDataItem:(id)item;
- (BOOL)removeDataItemMatchingPredicate:(NSPredicate *)predicate;
- (BOOL)removeDataItemsMatchingPredicate:(NSPredicate *)predicate;

@end