public function ajax_list($limit = 0)
 {
     $post = $this->input->post();
     $export = false;
     if (isset($post["isExport"])) {
         $post = json_decode($post["lastPost"], true);
         $export = $post["export"] = true;
     }
     $columns = array(array('db' => 'name', 'dt' => 0), array('db' => 'role', 'dt' => 1), array('db' => 'email', 'dt' => 2), array('db' => 'creation_date', 'dt' => 3, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'id', 'dt' => 4, 'formatter' => function ($d, $row) {
         $op = array();
         if (hasAccess("adminusers", "edit")) {
             $op[] = '<a href="' . site_url('admin/adminusers/edit/' . $d) . '" class="fa fa-edit"></a> ';
         }
         /*if (hasAccess("adminusers","delete"))
         		$op[] = '<a href="javascript:void(0);" onclick="delete_user('.$d.')" class="fa fa-trash-o"></a>';*/
         return implode(" / ", $op);
     }));
     if (!$export) {
         echo json_encode(SSP::simple($post, ADMIN, "id", $columns));
         exit;
     } else {
         $exportColumns = array("name" => "Name", "role" => "Role", "email" => "Email");
         $data = SSP::simple($post, ADMIN, "id", $columns);
         $this->load->library("excel");
         $this->excel->setActiveSheetIndex(0);
         $this->excel->stream('adminusers.xls', $data, $exportColumns);
     }
 }
 public function ajax_list($limit = 0)
 {
     $post = $this->input->post();
     $export = false;
     if (isset($post["isExport"])) {
         $post = json_decode($post["lastPost"], true);
         $export = $post["export"] = true;
     }
     $i = 0;
     $columns = array(array('db' => 'cm_uname', 'dt' => $i++), array('db' => 'cm_uemail', 'dt' => $i++), array('db' => 'cm_umobile', 'dt' => $i++), array('db' => 'cm_ucity', 'dt' => $i++), array('db' => 'cm_ucomment', 'dt' => $i++), array('db' => 'cm_date', 'dt' => $i++, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'cm_id', 'dt' => $i++, 'formatter' => function ($d, $row) {
         $op = array();
         if (hasAccess("contactrequest", "view")) {
             $op[] = '<a href="javascript:void(0);" onclick="view_contact(' . $d . ')" class="fa fa-list-alt"></a>';
         }
         if (hasAccess("contactrequest", "delete")) {
             $op[] = '<a href="javascript:void(0);" onclick="delete_contact(' . $d . ')" class="fa fa-trash-o"></a>';
         }
         return implode(" / ", $op);
     }));
     if (!$export) {
         echo json_encode(SSP::simple($post, CONTACT, "cm_id", $columns));
         exit;
     } else {
         $exportColumns = array("cm_uname" => "Name", "cm_uemail" => "Email", "cm_umobile" => "Mobile number", "cm_ucity" => "City", "cm_ucomment" => "Message", "cm_date" => "Date");
         $data = SSP::simple($post, CONTACT, "cm_id", $columns);
         $this->load->library("excel");
         $this->excel->setActiveSheetIndex(0);
         $this->excel->stream('contact_request.xls', $data, $exportColumns);
     }
 }
示例#3
1
 public function getdata()
 {
     $table = '`group`';
     $primaryKey = 'id';
     $columns = array(array('db' => 'id', 'dt' => 'DT_RowId', 'formatter' => function ($d, $row) {
         return 'row_' . $d;
     }, 'field' => 'id'), array('db' => 'id', 'dt' => 0, 'field' => 'id'), array('db' => 'name', 'dt' => 1, 'field' => 'name'), array('db' => 'null', 'dt' => 2));
     require 'ssp.ado.class.php';
     echo json_encode(SSP::simple($this->cfg->dbcnx, $_GET, $table, $primaryKey, $columns, $joinQuery));
 }
示例#4
1
 function ajax()
 {
     $table = 'v_asignaturas';
     $primaryKey = 'codigo';
     $columns = array(array('db' => 'nombre_area_administrativa', 'dt' => 0), array('db' => 'codigo', 'dt' => 1), array('db' => 'nombre', 'dt' => 2), array('db' => 'codigo', 'dt' => 3, 'formatter' => function ($d, $row) {
         return '<input type="checkbox" name="asignatura_ciclo" value="' . $d . '" onclick="$.ajax({method: \'POST\', url: \'/asignaturas_ciclo/asociar_asignatura_ciclo\', data: { asignatura: \'' . $d . '\'}})">';
     }));
     $sql_details = array('user' => 'root', 'pass' => 'root', 'db' => 'simapro', 'host' => 'localhost');
     require 'ssp.class.php';
     echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns));
 }
示例#5
1
 public function get_remote()
 {
     $table = 'access_level';
     // Table's primary key
     $primaryKey = 'id';
     // Array of database columns which should be read and sent back to DataTables.
     // The `db` parameter represents the column name in the database, while the `dt`
     // parameter represents the DataTables column identifier. In this case simple
     // indexes
     $columns = array(array('db' => 'level_name', 'dt' => 0), array('db' => 'description', 'dt' => 1), array('db' => 'indicator', 'dt' => 2));
     // SQL server connection information
     $CI =& get_instance();
     $sql_details = array('user' => $CI->db->username, 'pass' => $CI->db->password, 'db' => $CI->db->database, 'host' => $CI->db->hostname);
     echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns));
 }
示例#6
1
        if (!$result_sql) {
            echo 'Invalid query: ' . mysql_error();
        } else {
            echo "success";
        }
    } else {
        echo 'Invalid query: ' . mysql_error();
    }
}
if ($type == 'get_button_list') {
    $table = 'share_buttons';
    $primaryKey = 'bid';
    $columns = array(array('db' => 'b_title', 'dt' => 'b_title'), array('db' => 'b_target_id', 'dt' => 'b_target_id'), array('db' => 'b_content', 'dt' => 'b_content'), array('db' => 'page_id', 'dt' => 'page_id'), array('db' => 'bid', 'dt' => 'bid'));
    $extraWhere = " shop='" . mysql_real_escape_string($shop) . "' ";
    require 'ssp.class.php';
    $arr = SSP::complex($_POST, $sql_details, $table, $primaryKey, $columns, null, $extraWhere);
    $json = $arr;
    print_r(json_encode($json));
}
if ($type == 'search_p') {
    $search_text = trim($_REQUEST['ss']);
    $search_collection_id = trim($_REQUEST['sc']);
    $search_type = trim($_REQUEST['st']);
    $page = trim($_REQUEST['page']);
    $limit_str = 10;
    if ($search_type == "all_coll") {
        $search_peram = "?limit=" . $limit_str . "&page=" . $page;
        $search_products_data = $sc->call('GET', '/admin/products.json?collection_id=' . $search_collection_id . $search_peram);
        $total_prod_count = $sc->call('GET', '/admin/products.json?collection_id=' . $search_collection_id);
        $total_prod_count = intval($total_prod_count);
    } else {
// DB table to use
$table = 'modx_activations';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(array('db' => 'id', 'dt' => 'DT_RowId', 'formatter' => function ($d, $row) {
    // Technically a DOM id cannot start with an integer, so we prefix
    // a string. This can also be useful if you have multiple tables
    // to ensure that the id is unique with a different prefix
    return 'row_' . $d;
}), array('db' => 'act_date', 'dt' => 0, 'formatter' => function ($d, $row) {
    return !empty($d) ? date('d.m.Y', $d) : "";
}), array('db' => 'pc_id', 'dt' => 1, 'formatter' => function ($d, $row) {
    global $modx;
    return $modx->runSnippet('pdoField', array('id' => $d, 'field' => 'pagetitle'));
}), array('db' => 'abonent', 'dt' => 2), array('db' => 'bonus_set', 'dt' => 3, 'formatter' => function ($d, $row) {
    return !empty($d) ? $d . " руб." : "";
}));
// SQL server connection information
$sql_details = array('user' => 'mgmbee', 'pass' => 'mB915009', 'db' => 'mgm', 'host' => 'node100241-blogger.jelastic.regruhosting.ru');
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */
require MODX_CORE_PATH . 'components/datatables/server_side/scripts/ssp.class.php';
$beeWhere = array($_POST['beeWhere']);
echo json_encode(SSP::complex($_POST, $sql_details, $table, $primaryKey, $columns, null, $beeWhere));
示例#8
1
        $columns = array(array('db' => 'id', 'dt' => 0), array('db' => 'original_id', 'dt' => 1), array('db' => 'addres', 'dt' => 2), array('db' => 'start_date', 'dt' => 3), array('db' => 'end_date', 'dt' => 4), array('db' => 'task_type_name', 'dt' => 5), array('db' => 'shabloni_name', 'dt' => 6), array('db' => 'first_last_name', 'dt' => 7), array('db' => 'person_name', 'dt' => 8), array('db' => 'prio_name', 'dt' => 9), array('db' => 'note', 'dt' => 10));
        // SQL server connection information
        $sql_details = array('user' => 'root', 'pass' => 'Gl-1114', 'db' => 'asteriskcdrdb', 'host' => 'localhost');
        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         * If you just want to use the basic configuration for DataTables with PHP
         * server-side, there is no need to edit below this line.
         */
        mysql_close();
        require '../../../../includes/ssp.class.php';
        if ($_REQUEST[check] != '') {
            $dadebit = "";
        } else {
            $dadebit = "";
        }
        $where_param = "";
        $data = SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $where_param);
        break;
    case 'delete_file':
        mysql_query("DELETE FROM file WHERE id = {$delete_id}");
        $increm = mysql_query("\tSELECT  `name`,\r\n        \t\t\t`rand_name`,\r\n        \t\t\t`id`\r\n        \t\t\tFROM \t`file`\r\n        \t\t\tWHERE   `task_id` = {$edit_id}\r\n        \t\t\t");
        $data1 = '';
        while ($increm_row = mysql_fetch_assoc($increm)) {
            $data1 .= '<tr style="border-bottom: 1px solid #85b1de;">
				          <td style="width:110px; display:block;word-wrap:break-word;">' . $increm_row[name] . '</td>
        			<td ><button type="button" value="media/uploads/file/' . $increm_row[rand_name] . '" style="cursor:pointer; border:none; margin-top:25%; display:block; height:16px; width:16px; background:none;background-image:url(\'media/images/get.png\');" id="download" ></button><input type="text" style="display:none;" id="download_name" value="' . $increm_row[rand_name] . '"> </td>
        					<td ><button type="button" value="' . $increm_row[id] . '" style="cursor:pointer; border:none; margin-top:25%; display:block; height:16px; width:16px; background:none; background-image:url(\'media/images/x.png\');" id="delete"></button></td>
 					  </tr>';
        }
        $data = array('page' => $data1);
        break;
    case 'up_now':
示例#9
0
 function get_table_group($table, $primaryKey, $columns, $where, $group)
 {
     $config = new config();
     $sql_details = $config->sql_details();
     require 'ssp.class.php';
     echo json_encode(SSP::simplewheregroup($_POST, $sql_details, $table, $primaryKey, $columns, $where, $group));
 }
示例#10
0
 function get_table_join($table, $table2, $primaryKey, $columns, $on, $where, $group, $dataArray)
 {
     $config = new config();
     $sql_details = $config->sql_details();
     require 'ssp.class.php';
     echo json_encode(SSP::complexjoin($_POST, $sql_details, $table, $table2, $primaryKey, $columns, $on, $where, $group, $dataArray));
 }
示例#11
0
 function galleries_table()
 {
     //ajax call function
     if (!$_REQUEST) {
         return false;
     }
     $baseSql = "\n\t\t\tSELECT \n\t\t\t\tCASE g.type \n\t\t\t\t\tWHEN 1 THEN 'Gallery 1'\n\t\t\t\t\tWHEN 2 THEN 'Gallery 2'\n\t\t\t\t\tWHEN 3 THEN 'Gallery 3'\n\t\t\t\t\tWHEN 4 THEN 'Gallery 4'\n\t\t\t\t\tELSE 'Gallery'\n\t\t\t\tEND AS 'Type',\n\t\t\t\tg.gallery_id,\n\t\t\t\tg.gallery_title as 'Title',\n\t\t\t\tg.url as 'URL',\n\t\t\t\tg.category as 'Category',\n\t\t\t\tg.author_id,\n\t\t\t\tg.created as 'Date Created',\n\t\t\t\tu.username as 'Author',\n\t\t\t\t'' as 'Image'\n\t\t\tFROM\n\t\t\t\tgallery g\n\t\t\tLEFT JOIN\n\t\t\t\tusername u\n\t\t\tON\n\t\t\t\tg.user_id = u.id\n\t\t";
     //List all of your columns here
     $columns = array('Title', 'URL', 'Type', 'Category', 'Author', 'Image', 'Date Created');
     $functions = array();
     /*
      * adding functions is not required. This is just a way to run functions on the data if you wish.
      * This will take the target which is the Image row from the query, and change it to the "replace" string.
      * You can use part of the query to build the replace using {} and passing them in the params.
      */
     $functions[] = array('function' => 'editRow', 'target' => 'Image', 'replace' => '<img src="www.mysite.com/{gallery_id}" alt="{Title}">', 'params' => array('gallery_id', 'Title'));
     /*
      * Add this to change the date format. Simply put in the date format
      * of your column in the format_from value, and put the
      * desired date format in the format_to value
      * 20150101 becomes Thu: 01-01-15
      */
     $functions[] = array('function' => 'date_format', 'format_to' => 'D: m-d-y', 'format_from' => 'Ymd', 'columns' => array('Date Created'));
     /*
      * list any columns you want to be "searchable".
      * you can also list non visable data here to be searchable, such as the gallery_id.
      */
     $searchable = array('Title', 'URL', 'Author', 'Category');
     echo json_encode(SSP::buildTable($this->Model, $_REQUEST, $baseSql, $columns, $searchable, $functions));
 }
示例#12
0
 public function menucat_list()
 {
     $sql = 'select menu_category_id,menu_category_name from menu_category';
     $sql_data = $this->usermenumodel->columns($sql);
     $ssp_file = 'IncludeViews/ssp.php';
     require $ssp_file;
     echo json_encode(SSP::simple($_POST, $sql_data['sql_details'], $sql, $sql_data['columns']));
 }
示例#13
0
 public function zone_list()
 {
     $sql = 'select * from country_zone';
     $sql_data = $this->usermenumodel->columns($sql);
     $ssp_file = 'IncludeViews/ssp.php';
     require $ssp_file;
     echo json_encode(SSP::simple($_POST, $sql_data['sql_details'], $sql, $sql_data['columns']));
 }
示例#14
0
 public function usermaster_list()
 {
     $sql = $this->usermastermodel->index();
     $sql_data = $this->usermenumodel->columns($sql);
     $ssp_file = 'IncludeViews/ssp.php';
     require $ssp_file;
     echo json_encode(SSP::simple($_POST, $sql_data['sql_details'], $sql, $sql_data['columns']));
 }
示例#15
0
 public function ajax_list($limit = 0)
 {
     $post = $this->input->post();
     $columns = array(array('db' => 'name', 'dt' => 0), array('db' => 'email', 'dt' => 1), array('db' => 'creation_date', 'dt' => 2, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'id', 'dt' => 3, 'formatter' => function ($d, $row) {
         $op = array();
         $op[] = '<a href="' . site_url('/users/edit/' . $d) . '" class="fa fa-edit"></a> ';
         $op[] = '<a href="javascript:void(0);" onclick="delete_user(' . $d . ')" class="fa fa-trash-o"></a>';
         return implode(" / ", $op);
     }));
     echo json_encode(SSP::simple($post, USER, "id", $columns));
     exit;
 }
示例#16
0
 public function getOrder()
 {
     $table = 'tx_order';
     $primaryKey = 'id';
     $columns = array(array('db' => '`o`.`id`', 'dt' => 'id', 'formatter' => function ($d, $row) {
         return 'row_' . $d;
     }, 'field' => 'id'), array('db' => '`o`.`show_id`', 'dt' => 'show_id', 'field' => 'show_id'), array('db' => '`o`.`order_time`', 'dt' => 'order_time', 'field' => 'order_time'), array('db' => '`o`.`order_mobile`', 'dt' => 'mobile1', 'field' => 'order_mobile'), array('db' => '`o`.`cared_name`', 'dt' => 'cared_name', 'field' => 'cared_name'), array('db' => '`o`.`cared_gender`', 'dt' => 'cared_gender', 'field' => 'cared_gender'), array('db' => '`h`.`hospital_name`', 'dt' => 'hospital_name', 'field' => 'hospital_name'), array('db' => '`u`.`mobile`', 'dt' => 'mobile2', 'field' => 'mobile'), array('db' => '`o`.`status`', 'dt' => 'status', 'field' => 'status'), array('db' => '`o`.`cid`', 'dt' => 'cid', 'field' => 'cid'));
     $sql_details = array('user' => 'root', 'pass' => 'root', 'db' => 'taixin', 'host' => 'localhost');
     require 'ssp.customized.class.php';
     $joinQuery = "FROM `tx_order` AS `o` JOIN `tx_user` AS `u` ON (`u`.`id` = `o`.`uid`) JOIN  `tx_hospital` AS `h` ON (`h`.`id` = `o`.`hospital_id`)";
     //$extraWhere = "`u`.`salary` >= 90000";
     $extraWhere = '';
     echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere));
 }
 public function ajax_list($limit = 0)
 {
     $post = $this->input->post();
     $export = false;
     if (isset($post["isExport"])) {
         $post = json_decode($post["lastPost"], true);
         $export = $post["export"] = true;
     }
     $columns = array(array('db' => 'ad.ad_title', 'dt' => 0), array('db' => 'ad.ad_image', 'dt' => 1), array('db' => 'ad.ad_link', 'dt' => 2), array('db' => 'ad.ad_ispaid', 'dt' => 3), array('db' => 'ad.ad_show_on_page', 'dt' => 4), array('db' => 'ad.ad_created_date', 'dt' => 5, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'ad.ad_active', 'dt' => 6, 'formatter' => function ($d, $row) {
         $status = '';
         if ($d == 1) {
             $status = 'Active';
         }
         if ($d == 0) {
             $status = 'Inactive';
         }
         return $status;
     }), array('db' => 'ad.ad_id', 'dt' => 7, 'formatter' => function ($d, $row) {
         $op = array();
         if (hasAccess("advertise", "view")) {
             $op[] = '<a href="javascript:void(0);" onclick="view_ad(' . $d . ')" class="fa fa-list-alt"></a>';
         }
         if (hasAccess("advertise", "edit")) {
             $op[] = '<a href="' . site_url('/admin/advertise/edit/' . $d) . '" class="fa fa-edit"></a>';
         }
         if (hasAccess("advertise", "delete")) {
             $op[] = '<a href="javascript:void(0);" onclick="delete_ad(' . $d . ')" class="fa fa-trash-o">';
         }
         return implode(" / ", $op);
     }));
     #$join[] = array(USER_U,"u.u_id = ad.ad_uid");
     if (!$export) {
         echo json_encode(SSP::simple($post, ADVERTISE_AD, "ad.ad_id", $columns));
         exit;
     } else {
         $exportColumns = array("ad_title" => "Title", "ad_link" => "Link", "ad_ispaid" => "Is Paid", "ad_show_on_page" => "On Page", "ad_active" => "Status", "ad_created_date" => "Created At");
         $data = SSP::simple($post, ADVERTISE_AD, "ad.ad_id", $columns);
         $this->load->library("excel");
         $this->excel->setActiveSheetIndex(0);
         $this->excel->stream('advertise.xls', $data, $exportColumns);
     }
 }
 public function ajax_list($limit = 0)
 {
     $post = $this->input->post();
     $export = false;
     if (isset($post["isExport"])) {
         $post = json_decode($post["lastPost"], true);
         $export = $post["export"] = true;
     }
     $columns = array(array('db' => 'ad.clad_title', 'dt' => 0), array('db' => 'u.u_fname', 'dt' => 1), array('db' => 'r.report_text', 'dt' => 2), array('db' => 'r.created_on', 'dt' => 3, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'r.report_id,r.report_clad_id,ad.clad_active', 'dt' => 4, 'formatter' => function ($d, $row) {
         $report_id = $row['report_id'];
         $clad_id = $row['report_clad_id'];
         $clad_active = $row['clad_active'];
         $op = array();
         if (hasAccess("report", "view")) {
             $op[] = '<a href="javascript:void(0);" onclick="view_ad(' . $clad_id . ')"  title="View" class="fa fa-file-text-o"></a> ';
         }
         if (hasAccess("report", "delete")) {
             $op[] = '<a href="javascript:void(0);" onclick="delete_report(' . $report_id . ')" title="Delete" class="fa fa-trash-o"></a>';
         }
         if (hasAccess("classifiedad", "toggleStatus")) {
             if ($clad_active) {
                 $op[] = '<a href="javascript:void(0);" onclick="toggle_status(' . $clad_id . ')" title="Ad is active" class="fa fa-pause"></a>';
             } else {
                 $op[] = '<a href="javascript:void(0);" onclick="toggle_status(' . $clad_id . ')" title="Ad is inactive" class="fa fa-play"></a>';
             }
         }
         return implode("  &nbsp;&nbsp;  ", $op);
     }));
     $join[] = array(CLASSIFIEDAD_AD, "ad.clad_id = r.report_clad_id");
     $join[] = array(USER_U, "u.u_id = ad.clad_uid");
     if (!$export) {
         echo json_encode(SSP::simple($post, REPORTAD_R, "r.report_id", $columns, $join));
         exit;
     } else {
         $exportColumns = array("clad_title" => "Classified Title", "u_fname" => "User", "report_text" => "Comment", "created_on" => "Reported At", "clad_active" => "Classified Status");
         $data = SSP::simple($post, REPORTAD_R, "r.report_id", $columns, $join);
         $this->load->library("excel");
         $this->excel->setActiveSheetIndex(0);
         $this->excel->stream('report.xls', $data, $exportColumns);
     }
 }
 public function getContact($type = "")
 {
     if (isset($type) && $type != "") {
         $extraWhere = 'type =' . $type;
     } else {
         $extraWhere = '';
     }
     $table = 'inv_contact';
     $primaryKey = 'id';
     $columns = array(array('db' => 'name', 'dt' => 0, 'field' => 'name', 'searchable' => 'name', 'formatter' => function ($d, $row) {
         return '<a href="contact/item/' . $row['id'] . '" style="color:blue;">' . $d . '</a>';
     }), array('db' => 'type', 'dt' => 1, 'field' => 'type', 'formatter' => function ($d, $row) {
         $a = $d == 1 ? 'Client' : 'Supplier';
         return $a;
     }), array('db' => 'phone', 'dt' => 2, 'field' => 'phone', 'searchable' => 'phone'), array('db' => 'email', 'dt' => 3, 'field' => 'email', 'searchable' => 'email'), array('db' => 'country', 'dt' => 4, 'field' => 'country', 'searchable' => 'country'), array('db' => 'id', 'dt' => 5, 'field' => 'action', 'formatter' => function ($d, $row) {
         return '<a href="contact/edit/' . $d . '" class="btn btn-xs show-tooltip" title="" data-original-title="Edit"><span class="fa fa-edit"></span></a>';
     }));
     $joinQuery = 'SELECT * FROM inv_contact $where $order $limit';
     echo json_encode(SSP::simple1($_REQUEST, $this->_sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere));
 }
示例#20
0
 public function get_json()
 {
     $table = 'view_products';
     // Table's primary key
     $primaryKey = 'id';
     // Array of database columns which should be read and sent back to DataTables.
     // The `db` parameter represents the column name in the database, while the `dt`
     // parameter represents the DataTables column identifier. In this case simple
     // indexes
     $columns = array(array('db' => 'id', 'dt' => 0), array('db' => 'name', 'dt' => 1, 'formatter' => function ($d, $row) {
         return ucfirst($d);
     }), array('db' => 'sku', 'dt' => 2, 'formatter' => function ($d, $row) {
         return ucfirst($d);
     }), array('db' => 'price', 'dt' => 3, 'formatter' => function ($d, $row) {
         return 'Rs. ' . number_format($d, 2);
     }), array('db' => 'category_name', 'dt' => 4, 'formatter' => function ($d, $row) {
         return ucfirst($d);
     }), array('db' => 'weight', 'dt' => 5), array('db' => 'is_instock', 'dt' => 6, 'formatter' => function ($d, $row) {
         $class = $d == 0 || $d == '' ? 'btn-danger' : 'btn-success';
         $value = $d == 0 || $d == '' ? 0 : 1;
         $result = "<button class='change-stock btn btn-xs btn-status btn-outline " . $class . "''>" . $this->config->item("stock_" . $value) . "</button>";
         return $result;
     }), array('db' => 'is_active', 'dt' => 7, 'formatter' => function ($d, $row) {
         $class = $d == 0 || $d == '' ? 'btn-danger' : 'btn-success';
         $value = $d == 0 || $d == '' ? 0 : 1;
         $result = "<button class='change-status btn btn-xs btn-status " . $class . "''>" . $this->config->item("status_" . $value) . "</button>";
         return $result;
     }), array('db' => 'id', 'dt' => 8, 'formatter' => function ($d, $row) {
         $links = '<a href="' . base_url() . "products/edit/" . base64_encode($d) . '" class="btn btn-info btn-circle" type="button" title="Edit"><i class="fa fa-pencil"></i></a>
                                     <a href="' . base_url() . 'products/delete/' . base64_encode($d) . '" class="delete btn btn-danger btn-circle" type="button" title="Delete"><i class="fa fa-trash"></i></a>';
         return $links;
     }));
     // SQL server connection information
     $sql_details = array('user' => 'root', 'pass' => '', 'db' => 'trade_plus', 'host' => 'localhost');
     /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
      * If you just want to use the basic configuration for DataTables with PHP
      * server-side, there is no need to edit below this line.
      */
     echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns));
 }
示例#21
0
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(array('db' => 'title', 'dt' => 0), array('db' => 'date', 'dt' => 1, 'formatter' => function ($d, $row) {
    return date('Y-m-d', strtotime($d));
}));
// SQL server connection information
//TODO: make me elegant
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$server = $url["host"];
file_put_contents('php://stderr', print_r("SERVER2222", TRUE));
file_put_contents('php://stderr', print_r($server, TRUE));
$username = $url["user"];
$password = $url["pass"];
$db = substr($url["path"], 1);
$sql_details = array('user' => $username, 'pass' => $password, 'db' => $db, 'host' => $server);
// user id
$id = $_SESSION['id'];
// where conditioning for sql query
// datatables will load data restrict by user id
$whereAll = "id={$id}";
$whereResult = null;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */
require 'ssp.class.php';
echo json_encode(SSP::complex($_GET, $sql_details, $table, $primaryKey, $columns, null, "userID={$id}"));
示例#22
0
 * Please note that this script is intentionally extremely simply to show how
 * server-side processing can be implemented, and probably shouldn't be used as
 * the basis for a large complex system. It is suitable for simple use cases as
 * for learning.
 *
 * See http://datatables.net/usage/server-side for full details on the server-
 * side processing requirements of DataTables.
 *
 * @license MIT - http://datatables.net/license_mit
 */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables
 */
// DB table to use
$table = 'massive';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(array('db' => 'id', 'dt' => 0), array('db' => 'firstname', 'dt' => 1), array('db' => 'surname', 'dt' => 2), array('db' => 'zip', 'dt' => 3), array('db' => 'country', 'dt' => 4));
// SQL server connection information
$sql_details = array('user' => '', 'pass' => '', 'db' => '', 'host' => '');
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */
require '../../../../examples/server_side/scripts/ssp.class.php';
echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns));
示例#23
0
 * for learning.
 *
 * See http://datatables.net/usage/server-side for full details on the server-
 * side processing requirements of DataTables.
 *
 * @license MIT - http://datatables.net/license_mit
 */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables
 */
// DB table to use
$table = 'datatables_demo';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(array('db' => 'first_name', 'dt' => 0), array('db' => 'last_name', 'dt' => 1), array('db' => 'position', 'dt' => 2), array('db' => 'office', 'dt' => 3), array('db' => 'start_date', 'dt' => 4, 'formatter' => function ($d, $row) {
    return date('jS M y', strtotime($d));
}), array('db' => 'salary', 'dt' => 5, 'formatter' => function ($d, $row) {
    return '$' . number_format($d);
}));
$sql_details = array('user' => '', 'pass' => '', 'db' => '', 'host' => '');
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */
require 'ssp.class.php';
echo $_GET['callback'] . '(' . json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)) . ');';
<?php

require 'config.php';
// DB table to use
$table = 'statistic';
// Table's primary key
$primaryKey = 'id';
$columns = array(array('db' => 'id', 'dt' => 0, 'field' => 'id', 'as' => 'id'), array('db' => 'tahun', 'dt' => 1, 'field' => 'tahun', 'as' => 'tahun'), array('db' => 'minggu', 'dt' => 2, 'field' => 'minggu', 'as' => 'minggu'), array('db' => 'negeri', 'dt' => 3, 'field' => 'negeri', 'as' => 'negeri'), array('db' => 'daerah', 'dt' => 4, 'field' => 'daerah', 'as' => 'daerah'), array('db' => 'lokasi', 'dt' => 5, 'field' => 'lokasi', 'as' => 'lokasi'), array('db' => 'kes_terkumpul', 'dt' => 6, 'field' => 'kes_terkumpul', 'as' => 'kes_terkumpul'), array('db' => 'tempoh_wabak', 'dt' => 7, 'field' => 'tempoh_wabak', 'as' => 'tempoh_wabak'));
require 'ssp.class.php';
$joinQuery = "";
$extraCondition = "latitude IS NOT NULL";
$groupBy = '';
echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraCondition, $groupBy));
示例#25
0
            global $base_url;
            
            $cn = '<div class="btn-group">';
            $val = SSP::get_units_details($d);
            if(!$val[0]['is_deleted'])
            {
                if($_GET['edit']==1){
                    $cn .= '<a class="btn btn-xs btn-default" title="" data-toggle="tooltip" href="'.$base_url.'Units/edit/'.$d.'" data-original-title="Edit">
<i class="fa fa-pencil"></i></a>';
                }
                if($_GET['delete']==1){
                    $cn .= '<a class="btn btn-xs btn-danger" title="" data-toggle="tooltip" href="'.$base_url.'Units/delete/'.$d.'" data-original-title="Delete">
<i class="fa fa-times"></i></a>';
                }
            }
            else
            {
                /*$cn .= '<a onclick="confirm(\'Are you sure want to Retrieve?\');" class="btn btn-xs btn-warning" title="" data-toggle="tooltip" href="'.$base_url.'Units/delete/'.$d.'" data-original-title="Retrieve">
<i class="fa fa-undo"></i></a>';*/
				 $cn .= ' ';
            }
            $cn .= '</div>';
                          
            return $cn;
    })
    
);

echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns , $where1, $where2 ,$join)
);
 /**
  * Perform the SQL queries needed for an server-side processing requested,
  * utilising the helper functions of this class, limit(), order() and
  * filter() among others. The returned array is ready to be encoded as JSON
  * in response to an SSP request, or can be modified if needed before
  * sending back to the client.
  *
  *  @param  array $request Data sent to server by DataTables
  *  @param  array $sql_details SQL connection details - see sql_connect()
  *  @param  string $table SQL table to query
  *  @param  string $primaryKey Primary key of the table
  *  @param  array $columns Column information array
  *  @return array          Server-side processing response array
  */
 static function simple($request, $table, $primaryKey, $columns, $join = array(), $custom_where = array())
 {
     $bindings = array();
     $model = SSP::get_model();
     $fields = SSP::pluck_db($columns);
     $model->db->select("SQL_CALC_FOUND_ROWS " . $primaryKey, FALSE);
     $model->db->select($fields, FALSE);
     $model->db->from($table);
     foreach ($join as $j) {
         $model->db->join($j[0], $j[1]);
     }
     $where = SSP::filter($request, $columns, $bindings);
     if ($where != "") {
         $model->db->where($where);
     }
     if ($custom_where != "") {
         $model->db->where($custom_where);
     }
     foreach (SSP::order($request, $columns) as $order) {
         $order = explode("||", $order);
         $model->db->order_by($order[0], $order[1]);
     }
     $rows = isset($request['start']) ? $request['start'] : "";
     $limit = isset($request['length']) ? $request['length'] : 0;
     $model->db->limit($limit, $rows);
     $query = $model->db->get();
     $cquery = $model->db->query('SELECT FOUND_ROWS() AS `Count`');
     $recordsFiltered = $cquery->row()->Count;
     $data = $query->result_array();
     //print_r($data);exit;
     $query->free_result();
     $model->db->select($primaryKey);
     $model->db->from($table);
     $query = $model->db->get();
     //print_r($query);exit;
     $recordsTotal = $query->num_rows();
     $query->free_result();
     return array("draw" => intval($request['draw']), "recordsTotal" => intval($recordsTotal), "recordsFiltered" => intval($recordsFiltered), "data" => SSP::data_output($columns, $data));
 }
示例#27
0
 * the basis for a large complex system. It is suitable for simple use cases as
 * for learning.
 *
 * See http://datatables.net/usage/server-side for full details on the server-
 * side processing requirements of DataTables.
 *
 * @license MIT - http://datatables.net/license_mit
 */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables
 */
// DB table to use
$table = 'posts';
// Table's primary key
$primaryKey = 'post_id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(array('db' => "`n`.`title`", 'dt' => 0, 'field' => 'title', 'as' => 'title'), array('db' => '`n`.`content`', 'dt' => 1, 'field' => 'content'), array('db' => '`u`.`username`', 'dt' => 2, 'field' => 'username'), array('db' => "GROUP_CONCAT(`t`.`tag` SEPARATOR ', ')", 'dt' => 3, 'field' => 'tag', 'as' => 'tag'), array('db' => '`p`.`comment_count`', 'dt' => 4, 'field' => 'comment_count'), array('db' => "CONCAT_WS(',',`n`.`modified`,`n`.`created`)", 'dt' => 5, 'field' => 'date', 'as' => 'date'), array('db' => "`n`.`status`", 'dt' => 6, 'field' => 'status'), array('db' => "`u`.`uri`", 'dt' => 7, 'field' => 'uri'));
$sql_details = array('user' => 'root', 'pass' => 'Singosari123', 'db' => 'emif_framework', 'host' => 'localhost');
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */
// require( 'ssp.class.php' );
require 'ssp.customized.class.php';
$joinQuery = 'FROM `posts` AS `p` JOIN `post_types` AS `pt` ON (`p`.`post_type_id` = `pt`.`post_type_id`) JOIN `nodes` AS `n` ON (`p`.`post_id` = `n`.`node_id`) JOIN `users` AS `u` ON (`u`.`user_id` = `n`.`user_id`) LEFT JOIN `tags` AS `t` ON (`p`.`post_id` = `t`.`post_id`)';
$extraWhere = "`n`.`module` = 'post' AND `pt`.`post_type` = '" . $_GET['post'] . "' GROUP BY `p`.`post_id`";
echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere));
示例#28
-1
 public function ajax_list($limit = 0)
 {
     $post = $this->input->post();
     $columns = array(array('db' => 'company', 'dt' => 0), array('db' => 'cell_id', 'dt' => 1), array('db' => 'town', 'dt' => 2), array('db' => 'address', 'dt' => 3), array('db' => 'latitude', 'dt' => 4), array('db' => 'longitude', 'dt' => 5), array('db' => 'created_date', 'dt' => 6, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'modified_date', 'dt' => 7, 'formatter' => function ($d, $row) {
         return date('jS M y', strtotime($d));
     }), array('db' => 'id', 'dt' => 8, 'formatter' => function ($d, $row) {
         $op = array();
         $op[] = '<a href="javascript:addedit_cellinfo(' . $d . ');" class="fa fa-edit"></a> ';
         $op[] = '<a href="javascript:void(0);" onclick="delete_cellarea(' . $d . ')" class="fa fa-trash-o"></a>';
         return implode(" / ", $op);
     }));
     echo json_encode(SSP::simple($post, CELLAREA, "id", $columns));
     exit;
 }
示例#29
-1
 public function list_song()
 {
     $this->layout = null;
     $this->autoRender = false;
     $dataSource = ConnectionManager::getDataSource('default');
     $table = 'musics';
     $primaryKey = 'id';
     $columns = array(array('db' => 'id', 'field' => 'id', 'dt' => 0, 'formatter' => function ($d, $row) {
         return "<input class='checkboxed' type='checkbox' name='userid[]' value='{$d}'/>";
     }), array('db' => 'image', 'field' => 'image', 'dt' => 1, 'formatter' => function ($d, $row) {
         if (empty($d)) {
             // $view = new View();
             // return $view->Html->image('avataruser/avatarDefault.png',array('width'=>'70px','height'=>'70px'));
             return $d;
         } else {
             return "<img src='{$d}' width='70px' height='70px' />";
         }
     }), array('db' => 'id', 'field' => 'id', 'dt' => 2, 'formatter' => function ($d, $row) {
         $str = "<div class='btn-group btn-group-xs'><a href='" . Router::url(array('controller' => 'musics', 'action' => 'edit_song', 'admin' => true, 'id' => $d)) . "' class='btn btn-success'>";
         $str .= "<i class='fa fa-edit'></i></a></div>&nbsp;";
         $str .= "<div class='btn-group btn-group-xs'>";
         $str .= "<button class='btn btn-danger removemusic' title='Xóa bài hát' musicid='" . $d . "' type='button' id='remove-" . $d . "'><i class='fa fa-trash'></i>Xoá</button></div>";
         return $str;
     }), array('db' => 'name', 'field' => 'name', 'dt' => 3, 'formatter' => function ($d, $row) {
         return $d;
     }), array('db' => 'type', 'field' => 'type', 'dt' => 4, 'formatter' => function ($d, $row) {
         return $d;
     }), array('db' => 'idTacgia', 'field' => 'idTacgia', 'dt' => 5, 'formatter' => function ($d, $row) {
         return $d;
     }), array('db' => 'namSangtac', 'field' => 'namSangtac', 'dt' => 6, 'formatter' => function ($d, $row) {
         return $d;
     }), array('db' => 'moTa', 'field' => 'moTa', 'dt' => 7, 'formatter' => function ($d, $row) {
         return $d;
     }), array('db' => 'created', 'field' => 'created', 'dt' => 8, 'formatter' => function ($d, $row) {
         return $d;
     }));
     $sql_details = array('user' => $dataSource->config['login'], 'pass' => $dataSource->config['password'], 'db' => $dataSource->config['database'], 'host' => $dataSource->config['host']);
     App::import('Vendor', 'amnhac/ssp');
     $joinQuery = "FROM musics";
     echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery));
 }
示例#30
-1
 function ajax()
 {
     $table = 'ciclos';
     $primaryKey = 'id';
     $columns = array(array('db' => 'id', 'dt' => 0), array('db' => 'nombre', 'dt' => 1), array('db' => 'fecha_inicio', 'dt' => 2), array('db' => 'fecha_fin', 'dt' => 3), array('db' => 'paridad', 'dt' => 4), array('db' => 'activo', 'dt' => 5, 'formatter' => function ($d, $row) {
         return $d == 1 ? "Si" : "No";
     }), array('db' => 'id', 'dt' => 6, 'formatter' => function ($d, $row) {
         return "<a href=\"/ciclos/modificar_formulario/{$row['id']}\">Modificar</a>";
     }), array('db' => 'id', 'dt' => 7, 'formatter' => function ($d, $row) {
         return "<a href=\"/ciclos/eliminar/{$row['id']}\">Eliminar</a>";
     }));
     $sql_details = array('user' => 'root', 'pass' => 'root', 'db' => 'simapro', 'host' => 'localhost');
     require 'ssp.class.php';
     echo json_encode(SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns));
 }