Skip to content

Instantly share code, notes, and snippets.

@gnh1201
Created April 13, 2019 06:06
Show Gist options
  • Save gnh1201/f12162682016cc0df6d711c57c6a6308 to your computer and use it in GitHub Desktop.
Save gnh1201/f12162682016cc0df6d711c57c6a6308 to your computer and use it in GitHub Desktop.
orderlist.php (Example of reasonableframework)
<?php
loadHelper("ndkponum.utils");
loadHelper("paginate");
$manager = get_requested_value("manager");
$page = paginate_get_current_page(get_requested_value("page"));
$limit = 7;
// title이 변수로 전달된다.
$data = array(
"title" => "Order List",
);
// get staffs
$staffs = array();
$bind = array(
"type" => "staff",
);
$sql = get_bind_to_sql_select("ndk_po_users", $bind);
$rows = exec_db_fetch_all($sql, $bind);
foreach($rows as $row) {
$staffs[] = array("id" => $row['userId'], "name" => $row['userName']);
}
$data['staffs'] = $staffs;
// get orders
$orders = array();
$bind = array();
if(!empty($manager)) {
$bind['manager'] = $manager;
}
$sql = get_bind_to_sql_select("ndk_po_order", $bind, array(
"fieldnames" => array(
"id",
"orderNum",
"manager",
"direct_orderNum",
"agencyId",
"agencyNm",
"incoterms",
"incoterms_nm",
"pay_meth",
"pay_meth_nm",
"bDate"
),
"setlimit" => $limit,
"setpage" => $page,
"setorders" => array(
"id desc"
),
));
$rows = exec_db_fetch_all($sql, $bind);
foreach($rows as $k=>$row) {
$rows[$k]['submitted_nm'] = ndk_po_submitted_number($row['bDate'], $row['orderNum']);
}
$orders = $rows;
$data['orders'] = $orders;
/*
// 위와 동일한 표현
for($k = 0; $k < count($rows); $k++) {
$rows[$k]['submitted_nm'] = ndk_po_submitted_number($rows[$k]['bDate'], $rows[$k]['orderNum']);;
}
*/
// get orders pagenate
$bind = array();
if(!empty($manager)) {
$bind['manager'] = $manager;
}
$sql = get_bind_to_sql_select("ndk_po_order", $bind, array(
"getcnt" => true,
));
$row = exec_db_fetch($sql, $bind);
$cnt = get_value_in_array("cnt", $row);
$total_pages = paginate_get_total_pages($limit, $cnt);
$paginate_html = paginate_make_html($limit, $page, $cnt, $total_pages, get_route_link("order/orderlist", array("page" => "")), "");
$data['paginate_html'] = $paginate_html;
$data['manager'] = $manager;
renderView("templates/mincss/header", $data);
renderView("order/view_orderlist", $data);
renderView("templates/mincss/footer", $data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment