<?php /** * Client Manager * * Login Page * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_FORM', true); define('LOAD_MYSQL', true); define('IN_LOGIN', true); require 'cm_includes/entry.php'; $frm = new SpoonForm('login'); $pf = parseForm($frm, 'login'); $pf[0] == 3 && $pf[1] && header('Location: ' . CM_URL); $frm->parse($tpl); $tpl->display(tpl_path('login.tpl.php'));
//datagrid, generating results table $grid = new SpoonDataGridSourceArray($query); $datagrid = new SpoonDatagrid($grid); $datagrid->setColumnsHidden('id', 'attachment'); $datagrid->setCompileDirectory(COMPILE_PATH); $url = $_SERVER['QUERY_STRING'] ? cleanQuery($_SERVER['QUERY_STRING']) . 'offset=[offset]&order=[order]&sort=[sort]' : '?offset=[offset]&order=[order]&sort=[sort]'; $datagrid->setURL($url); $datagrid->setSortingColumns(array('file', 'name', 'ic', 'id'), 'id'); $datagrid->setPagingLimit(PAGING_LIMIT); $datagrid->setHeaderLabels(array('file' => '档案 File', 'case' => '案情 Case', 'photo' => '照片 Photo', 'name' => '姓名 Name', 'ic' => '身份证 IC', 'action' => '操作')); $tpl->assign('results', $datagrid->getContent()); } else { $tpl->assign('tooltip', 'No Relevant Results.'); $frm->parse($tpl); } } else { $frm->parse($tpl); } $tpl->display(tpl_path('admin_search.tpl.php')); function cleanQuery($query) { parse_str($query, $str); unset($str['offset']); unset($str['order']); unset($str['sort']); $query = "?"; foreach ($str as $key => $value) { $query .= $key . '=' . $value . '&'; } return $query; }
*/ define('LOAD_TEMPLATE', true); define('LOAD_FORM', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; isset($_GET['id']) ? $id = (int) $_GET['id'] : header("Location: " . CM_ROOT . '/cm_admin/'); if (isset($_GET['delete']) && $_GET['delete'] == 1) { $tpl->assign('tooltip', tableParser('profiles', 'delete', array('id' => $id)) ? 'You have successfuly delete the profile.<br />Check out more profiles <a href="' . CM_URL . '/cm_admin/list.php">here</a>.' : 'Delete the profile resulted failed.'); } else { $frm = new SpoonForm('profile'); $get_user = tableParser('profiles', 'getProf', array('id' => $id)); if (empty($get_user)) { $tpl->assign('tooltip', 'Profile not available'); } else { //set form value $pf = parseForm($frm, 'profile', $get_user); $update = $pf[0] == 3 ? tableParser('profiles', 'update', array_merge($pf[1], array('id' => $id))) : false; //set profile image & attachment path isset($get_user['photo']) && strlen($get_user['photo']) > 0 && $tpl->assign('photo_path', CM_URL . '/cm_api/images.php?thumbnail=1&id=' . $id); isset($get_user['attachment']) && strlen($get_user['attachment']) > 0 && $tpl->assign('attach_path', CM_URL . '/cm_api/attachments.php?id=' . $id); $tpl->assign('id', $id); $tpl->assign('lastupdate', date(DATE_RFC822, $get_user['lastupdate'])); if ($pf[0] == 3) { $tpl->assign('tooltip', $update ? 'You have successfuly edit the profile.<br />' : 'Edit the profile resulted failed.'); } $frm->parse($tpl); } } $tpl->display(tpl_path('admin_edit.tpl.php'));
if (isset($value['attachment']) && strlen($value['attachment']) > 0) { $records[$key]['action'] .= '<br /><a href="' . CM_URL . '/cm_api/attachments.php?id=' . $value['id'] . '" target="_blank">Attach</a>'; } $records[$key]['company'] = getCompanyValue($value['company']); } //datagrid, generating results table $grid = new SpoonDataGridSourceArray($records); $datagrid = new SpoonDatagrid($grid); $datagrid->setCompileDirectory(COMPILE_PATH); $datagrid->setURL('?offset=[offset]&order=[order]&sort=[sort]'); $datagrid->setPagingLimit(PAGING_LIMIT); $datagrid->setColumnHidden('attachment'); $datagrid->setSortingColumns(array('file', 'name', 'ic', 'id'), 'id'); $datagrid->setHeaderLabels(array('file' => '档案<br />File', 'case' => '案情<br />Case', 'photo' => '照片Photo', 'name' => '姓名 <br />Name', 'ic' => '身份证 IC', 'company' => '公司 1<br />Company', 'action' => 'Action<br />操作')); $tpl->assign('results', $datagrid->getContent()); } else { $tpl->assign('tooltip', 'No Relevant Results.'); } $tpl->display(tpl_path('admin_list.tpl.php')); /** * Return first company details * * @return string * @param string $value */ function getCompanyValue($value) { $values = explode(', ', $value); $count = -1; return $values[$count += 1]; }
<?php /** * Client Manager * * Create Profile Form * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_FORM', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; $frm = new SpoonForm('profile'); $pf = parseForm($frm, 'profile'); $pf[0] == 3 && ($pf[1] = $mysql->insert('profiles', $pf[1])); if ($pf[0] == 3 && $pf[1]) { $tpl->assign('tooltip', 'You have successfuly create a new profile. More Action ?<br /> <a href="' . CM_URL . '/cm_admin/edit.php?id=' . $pf[1] . '">Edit</a> | <a href="' . CM_URL . '/cm_admin/profile.php?id=' . $pf[1] . '">Print</a> | <a href="' . CM_URL . '/cm_admin/edit.php?id=' . $pf[1] . '&delete=1">Delete</a> or Create a new Profile <a href="' . CM_URL . '/cm_admin/create.php">here</a>.'); } elseif ($pf[0] == 3 && !$pf[1]) { $tpl->assign('tooltip', 'Creating new profile resulted failed.'); $frm->parse($tpl); } else { $frm->parse($tpl); } $tpl->display(tpl_path('admin_create.tpl.php'));
$count = -1; for ($i = 1; $i < 6; $i++) { $profile_html .= genLab("公司名字{$i} <br />company name ", $value[$count += 1]); $profile_html .= genLab("注册号码{$i} <br />registration number ", $value[$count += 1]); $profile_html .= genLab("公司号码{$i} <br />Company number ", $value[$count += 1]); $profile_html .= genLab("公司电邮{$i} <br />Company email ", $value[$count += 1]); $profile_html .= genLab("公司股东{$i} <br />Shareholder ", $value[$count += 1]); $profile_html .= genLab("注册地址{$i} <br />Registered Address ", $value[$count += 1]); $profile_html .= genLab("营业地址{$i} <br />Business Address ", $value[$count += 1]); } } elseif ($key == 'lastupdate') { $profile_html .= genLab($replaceLabel[$key], date(DATE_RFC822, $value)); } elseif (isset($value)) { $profile_html .= genLab($replaceLabel[$key], $value); } } $tpl->assign('profile', $profile_html); } $tpl->display(tpl_path('profile.tpl.php')); function genLab($label, $value) { if ($value) { $profile_html = '<p>'; $profile_html .= '<label>' . $label . '</label>'; $profile_html .= '<span>' . $value . '</span>'; $profile_html .= '</p>'; return $profile_html; } else { return NULL; } }
<?php /** * Client Manager * * Main Page of CM * @package Client Manager 0.2 alpha * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_MYSQL', true); define('IN_ADMIN', true); require '../cm_includes/entry.php'; $tpl->assign('total', count(tableParser('profiles', 'getTotal'))); $tpl->assign('expired', round((SpoonSession::get('expiredTime') - time()) / 60, 1)); $tpl->display(tpl_path('admin_index.tpl.php'));