function actionDeliveryDetailList() { //过滤语句 $using = new class_using(); $request = $using->safeUsing('request', 'controller:string,action:string'); $this->_model =& FLEA::getSingleton('model_rep'); //出货表 $rep = $this->_model->find(array('ID' => $request['kcreport'], 'ID' => $request['actionDeliveryDetailList'])); if ($rep) { $this->_model =& FLEA::getSingleton('model_grid'); //表字段 $grid = $this->_model->findAll(array('RepID' => $rep['ID'])); //设置查询语句 $dbo =& FLEA::getDBO(); $this->sql = $rep['select FCustomerCode,FCustomerName,FDate,FSODate from v_delivery']; //查询条件-按日期查询 ///此处可修改>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> $cond = new class_conditions(); $formdate = isset($request['formdate']) ? $request['formdate'] : date("Y-m-d"); $todate = isset($request['todate']) ? $request['todate'] : date("Y-m-d"); $FCustomer = isset($request['FCustomer']) ? trim($this->u2gbk($request['FCustomer'])) : null; $cond->between($formdate, $todate, 'FDate', 'D', 2); $cond->equal($FCustomer, 'FCustomerCode', 'S', ' and '); ///此处可修改<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //排序 $order = new class_order($request); //获取当前页 $page['cid'] = isset($request['pageNum']) && intval($request['pageNum']) > 0 ? intval($request['pageNum']) : 1; $page['size'] = isset($request['numPerPage']) && intval($request['numPerPage']) > 0 ? intval($request['numPerPage']) : 20; echo $this->sql; //获取SQL查询的全部记录 $alldata = $dbo->getAll($this->sql . $cond->getWhere() . $order->getOrder()); //获取SQL查询的记录总数 $page['count'] = count($alldata); //$allFProfit =$this->_count($alldata,'FProfit'); //$allFSaleAmount =$this->_count($alldata,'FSaleAmount'); //记录偏移量 $page['offset'] = ($page['cid'] - 1) * $page['size'] > $page['count'] ? $page['count'] : ($page['cid'] - 1) * $page['size']; $data = array_slice($alldata, $page['offset'], $page['size'], true); //处理查询结果 if (isset($data)) { ///此处可修改>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> $this->_smarty->assign('formdate', $formdate); $this->_smarty->assign('todate', $todate); $this->_smarty->assign('FCustomer', $FCustomer); ///此处可修改<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $this->_smarty->assign('orderField', $order->getField()); $this->_smarty->assign('orderDirection', $order->getDirection()); $this->_smarty->assign('page', $page); $this->_smarty->assign('data', $data); $this->_smarty->assign('grid', $grid); $this->_smarty->assign('alldata', $alldata); $this->_smarty->assign('allFProfit', $allFProfit); $this->_smarty->assign('allFSaleAmount', $allFSaleAmount); $this->_smarty->display('kc.DeliveryDetailList.htm'); } } else { $this->_smarty->display('norepinfo.htm'); } }
function actionDeliveryDetail() { //过滤语句 $using = new class_using(); $request = $using->safeUsing('get', 'controller:string,action:string'); //设置查询语句 $dbo =& FLEA::getDBO(); $this->sql = 'select FCustomerCode,FCustomerName,FDate,FAmount,FAllAmount from v_delivery'; //查询条件-按日期查询 $cond = new class_conditions(); $formdate = isset($request['formdate']) ? $request['formdate'] : date("Y-m-d"); $todate = isset($request['todate']) ? $request['todate'] : date("Y-m-d"); $FCustomer = isset($request['FCustomer']) ? trim(rawurldecode($request['FCustomer'])) : null; $cond->equal($FCustomer, 'FCustomerCode', 'S', ' and '); $cond->between($formdate, $todate, 'fdate', 'D', 2); //排序 $order = new class_order($request); //获取SQL查询的全部记录 $alldata = $dbo->getAll($this->sql . $cond->getWhere() . $order->getOrder()); $xls = new class_excel(); $xls->addArray($this->gethead($alldata)); $xls->addArray($this->getdata($alldata)); $xls->addArray($this->getfoot($alldata)); $xls->generateXML("DeliveryDetail"); }
/** * 生成代码 * * @param string $tableName * @param string $tableClass * * @return string */ function _getCode($tableName, $tableClass) { /** * 首先判断指定的数据表是否存在 */ $dbo =& FLEA::getDBO(); $tables = $dbo->metaTables(); if (!in_array($tableName, $tables)) { echo "Database table '{$tableName}' not exists.\n"; return -1; } $meta = $dbo->metaColumns($tableName); $primaryKey = ''; foreach ($meta as $field) { if ($field['primaryKey']) { $primaryKey = $field['name']; break; } } $viewdata = array('tableName' => $tableName, 'tableClass' => $tableClass, 'primaryKey' => $primaryKey); return $this->_parseTemplate('table', $viewdata); }
<?php require 'FLEA.php'; $dbDSN = array('driver' => 'mysqlt', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'database' => 'test'); FLEA::setAppInf('dbDSN', $dbDSN); FLEA::setAppInf('internalCacheDir', 'D:/temp'); $dbo =& FLEA::getDBO(); $dbo->startTrans(); /** * 建立全部需要的权限 */ $tablePermissions =& FLEA::getSingleton('FLEA_Acl_Table_Permissions'); /* @var $tablePermissions FLEA_Acl_Table_Permissions */ $permissions = array(array('name' => '/Project/Create'), array('name' => '/Project/View'), array('name' => '/Project/Edit'), array('name' => '/Project/Delete'), array('name' => '/Bug/Create'), array('name' => '/Bug/View'), array('name' => '/Bug/Edit'), array('name' => '/Bug/AddComment'), array('name' => '/Bug/SetFixed'), array('name' => '/Bug/SetClosed'), array('name' => '/Bug/Delete')); $tablePermissions->createRowset($permissions); $permissions = $tablePermissions->findAll(); FLEA::loadHelper('array'); $permissions = array_to_hashmap($permissions, 'name'); /** * 建立角色,并将权限绑定到角色上 */ $tableRoles =& FLEA::getSingleton('FLEA_Acl_Table_Roles'); /* @var $tableRoles FLEA_Acl_Table_Roles */ $role = array('name' => 'ProjectManager', 'permissions' => array($permissions['/Project/Create'], $permissions['/Project/View'], $permissions['/Project/Edit'], $permissions['/Project/Delete'], $permissions['/Bug/Delete'])); $tableRoles->create($role); $role = array('name' => 'Developer', 'permissions' => array($permissions['/Project/View'], $permissions['/Bug/View'], $permissions['/Bug/AddComment'], $permissions['/Bug/SetFixed'], $permissions['/Bug/Delete'])); $tableRoles->create($role); $role = array('name' => 'Tester', 'permissions' => array($permissions['/Project/Create'], $permissions['/Bug/Create'], $permissions['/Bug/Edit'], $permissions['/Bug/View'], $permissions['/Bug/AddComment'], $permissions['/Bug/SetClosed'])); $tableRoles->create($role); /** * 读取所有角色信息,并以角色名为索引
/** * 构造 FLEA_Db_TableDataGateway 实例 * * $params 参数允许有下列选项: * - schema: 指定数据表的 schema * - tableName: 指定数据表的名称; * - primaryKey: 指定主键字段名 * - autoValidating: 指示是否使用自动验证; * - verifierProvider: 指定要使用的数据验证服务对象。 * 如果未指定。则使用应用程序设置 helper.verifier 指定的验证服务提供对象; * - skipConnect: 指示初始化表数据入口对象时是否不连接到数据库; * - dbDSN: 指定连接数据库要使用的 DSN,如果未指定则使用默认的 DSN 设置; * - dbo: 指定要使用的数据库访问对象; * - skipCreateLinks: 指示初始化表数据入口时,是否不建立关联关系 * * @param array $params * * @return FLEA_Db_TableDataGateway */ function FLEA_Db_TableDataGateway($params = null) { if (!empty($params['schema'])) { $this->schema = $params['schema']; } if (!empty($params['tableName'])) { $this->tableName = $params['tableName']; } if (!empty($params['primaryKey'])) { $this->primaryKey = $params['primaryKey']; } // 初始化验证服务对象 if (isset($params['autoValidating'])) { $this->autoValidating = $params['autoValidating']; } if ($this->autoValidating) { if (!empty($params['verifierProvider'])) { $provider = $params['verifierProvider']; } else { $provider = FLEA::getAppInf('helper.verifier'); } if (!empty($provider)) { $this->verifier =& FLEA::getSingleton($provider); } } // 当 skipInit 为 true 时,不初始化表数据入口对象 if (isset($params['skipConnect']) && $params['skipConnect'] != false) { return; } // 初始化数据访问对象 if (!isset($params['dbo'])) { if (isset($params['dbDSN'])) { $dbo =& FLEA::getDBO($params['dbDSN']); } else { $dbo =& FLEA::getDBO(); } } else { $dbo =& $params['dbo']; } $this->setDBO($dbo); // 当 skipCreateLinks 不为 true 时,建立关联 if (!isset($params['skipCreateLinks']) || $params['skipCreateLinks'] == false) { $this->relink(); } }
public function actionallmondy() { if ($_POST['sub']) { //发送指令 FLEA::loadClass('Util_socketclient'); if ($_POST['dev']) { try { $db = FLEA::getDBO(); $db->startTrans(); foreach ($_POST['dev'] as $equipment) { $socket = new Util_socketclient(); $devinfo = $this->_M->find($equipment); if (!$devinfo) { continue; } $this->log->ip = $devinfo['ipaddr']; $socket_command = array('passstat' => "SP9{$_POST[passstat]}Z", 'mutestat' => "SM9{$_POST[mutestat]}Z", 'gain' => "SG9" . $socket->setupgain($_POST['gain']) . "Z"); $socket->socketconn($devinfo['ipaddr'], $devinfo['ipport']); foreach ($socket_command as $field => $command) { switch ($socket->sendmessage($command)) { case $socket->returntrue: $updatearr = array($field => $_POST[$field]); $this->M_chninfo->updateByConditions("dev_no={$equipment}", $updatearr); $this->log->writelog($devinfo['devname'], $command, $socket->returntrue); break; case $socket->returnfalse: $this->log->writelog($devinfo['devname'], $command, $socket->returnfalse); break; } sleep(1); } fclose($socket->socket); } $db->completeTrans(); $this->_G->customshow('发送指令成功', "edit", "Index", 3, 1); } catch (Exception $e) { $db->completeTrans(FALSE); $this->_G->customshow('发送指令失败', "edit", "Index", 3, 0); } } else { $message = " <font color=red><b>您没有选择设备!</b></font> "; } } else { $dev = $this->_M->findAll(); $this->_V->assign('dev', $dev); $this->_V->assign('gainArray', $this->socketClient->gainArray); $this->_V->display('edit_allmondy.htm'); } }
function actionFEmpIDName() { $dbo =& FLEA::getDBO(); $data = $dbo->getAll('select distinct FEmpIDName from v_salesdetail where FEmpIDName <>"" and FEmpIDName is not null'); $this->_smarty->assign('data', $data); $this->_smarty->display('FEmpIDName.htm'); }
/** * 返回当前页对应的记录集 * * @param string $fields * @param boolean $queryLinks * * @return array */ function &findAll($fields = '*', $queryLinks = true) { if ($this->count == -1) { $this->count = 20; } $offset = ($this->currentPage - $this->_basePageIndex) * $this->pageSize; if (is_object($this->source)) { $limit = array($this->pageSize, $offset); $rowset = $this->source->findAll($this->_conditions, $this->_sortby, $limit, $fields, $queryLinks); } else { if (is_null($this->dbo)) { $this->dbo =& FLEA::getDBO(false); } $rs = $this->dbo->selectLimit($this->source, $this->pageSize, $offset); $rowset = $this->dbo->getAll($rs); } return $rowset; }
/** * 返回数据库访问对象实例(已经过时,用 FLEA::getDBO() 代替) * * @param array $dsn * * @return SDBO * @deprecated */ function &get_dbo($dsn) { return FLEA::getDBO($dsn); }
/** * 打开 session * * @param string $savePath * @param string $sessionName * * @return boolean */ function sessionOpen($savePath, $sessionName) { $dsnName = FLEA::getAppInf('sessionDbDSN'); $dsn = FLEA::getAppInf($dsnName); $this->dbo =& FLEA::getDBO($dsn); if (!$this->dbo) { return false; } if (!empty($this->dbo->dsn['prefix'])) { $this->tableName = $this->dbo->dsn['prefix'] . $this->tableName; } $this->tableName = $this->dbo->qtable($this->tableName); $this->fieldId = $this->dbo->qfield($this->fieldId); $this->fieldData = $this->dbo->qfield($this->fieldData); $this->fieldActivity = $this->dbo->qfield($this->fieldActivity); $this->sessionGc(FLEA::getAppInf('sessionDbLifeTime')); return true; }
/** * 恢复设备默认设置 * */ public function actionResumeDefault() { $devinfo = $this->M_devinfo->find($_GET['serial']); $socket = FLEA::getSingleton('Util_socketclient'); $socket->socketconn($devinfo['ipaddr'], $devinfo['ipport']); $this->log->ip = $devinfo['ipaddr']; switch ($socket->sendmessage('SINITZ')) { case $socket->returntrue: $this->log->writelog($devinfo['devname'], 'SINITZ', $socket->returntrue); $serial = (int) $_GET['serial']; try { $db = FLEA::getDBO(); $db->startTrans(); sleep(1); for ($i = 1; $i < 9; $i++) { $return_socketinfo = $socket->sendmessage("SI{$i}Z"); if (strlen($return_socketinfo) == 13) { $chninfo = $socket->analysisinfo($return_socketinfo); if ($chninfo === FALSE) { exit($this->_G->customshow('获取设备信息出现乱码,请重试', $_GET['socket_C'], 'index', 3, 0)); } //如果有乱码将直接退出 #检测APID是否有相同 $this->M_chninfo->updateByConditions("dev_no='{$serial}' and chn='{$chninfo['chn']}'", $chninfo); $chninfo['prgname'] = " "; $chninfo['chnshort'] = " "; $this->M_chninfo->updateByConditions("dev_no='{$serial}' and chn='{$chninfo['chn']}'", $chninfo); sleep(1); } } fclose($socket->socket); $db->completeTrans(); $this->_G->customshow("该设备已恢复成默认值", 'socket', 'index', 3, 1); } catch (Exception $e) { $db->completeTrans(FALSE); $this->_G->customshow("恢复设备默认值失败,请重试", 'socket', 'index', 3, 0); } break; case $socket->returnfalse: $this->log->writelog($devinfo['devname'], 'SINITZ', $socket->returnfalse); $this->_G->customshow("恢复出错,请重新恢复", 'socket', 'index', 0); break; } }
function actionReceivable() { //过滤语句 $using = new class_using(); $request = $using->safeUsing('post', 'controller:string,action:string'); //设置查询语句 $dbo =& FLEA::getDBO(); $this->sql = 'select * from v_pay'; //查询条件-按日期查询 $cond = new class_conditions(); $formdate = isset($request['formdate']) ? $request['formdate'] : date("Y-m-d"); $todate = isset($request['todate']) ? $request['todate'] : date("Y-m-d"); //$cond->between($formdate,$todate,'fdate','D',2); //$cond->equal($FCustomercode,'FCustomercode','S',' and '); //排序 $order = new class_order($request); //获取当前页 $page['cid'] = isset($request['pageNum']) && intval($request['pageNum']) > 0 ? intval($request['pageNum']) : 1; $page['size'] = isset($request['numPerPage']) && intval($request['numPerPage']) > 0 ? intval($request['numPerPage']) : 20; //获取SQL查询的全部记录 $alldata = $dbo->getAll($this->sql . $cond->getWhere() . $order->getOrder()); //获取SQL查询的记录总数 $page['count'] = count($alldata); //记录偏移量 $page['offset'] = ($page['cid'] - 1) * $page['size'] > $page['count'] ? $page['count'] : ($page['cid'] - 1) * $page['size']; $data = array_slice($alldata, $page['offset'], $page['size'], true); //处理查询结果 if (isset($data)) { $this->_smarty->assign('formdate', $formdate); $this->_smarty->assign('todate', $todate); $this->_smarty->assign('orderField', $order->getField()); $this->_smarty->assign('orderDirection', $order->getDirection()); $this->_smarty->assign('page', $page); $this->_smarty->assign('data', $data); $this->_smarty->assign('alldata', $alldata); $this->_smarty->display('repsale.Receivable.htm'); } }
function actionuserImport() { $rbac =& FLEA::getSingleton('FLEA_Rbac'); $SE = $rbac->getUser(); if (!$SE) { $this->writeAjax('300', '你无权执行此操作!', '', '', ''); } $using = new class_using(); $request = $using->safeUsing('post', 'UserID:string'); $dbo =& FLEA::getDBO(); $data = $dbo->getAll('select t_user.FName AS Username,password=1,IsSuperUser=0,t_user.FName as DisplayName from t_user where t_user.FName not in(select srep_user.Username as FName from srep_user) and t_user.FUserID > 16000 and t_user.FName<>' . "''"); $this->_model =& FLEA::getSingleton('model_user'); $this->_model->saveRowset($data); if (isset($data)) { $this->_smarty->assign('users', $data); $this->_smarty->display('userimport.htm'); } }
function actionDeliveryDetail() { //过滤语句 $using = new class_using(); $request = $using->safeUsing('get', 'controller:string,action:string'); //设置查询语句 $dbo =& FLEA::getDBO(); $this->sql = 'select FCustomerType,sum(FSaleAmountIncludeTax) as FSaleAmountIncludeTax ,sum(FSaleAmount) as FSaleAmount,sum(FAmount) as FAmount,sum(FProfit) as FProfit,case when sum(FSaleAmount) = 0 then 0 else sum(FProfit)/sum(FSaleAmount) end FProfitRate from v_salesdetail'; //查询条件-按日期查询 $cond = new class_conditions(); $formdate = isset($request['formdate']) ? $request['formdate'] : date("Y-m-d"); $todate = isset($request['todate']) ? $request['todate'] : date("Y-m-d"); $FCustomerType = isset($request['FCustomerType']) ? trim(rawurldecode($request['FCustomerType'])) : null; $cond->between($formdate, $todate, 'fdate', 'D', 2); $cond->equal($FCustomerType, 'FCustomerType', 'S', ' and '); //排序 $order = new class_order($request); //获取SQL查询的全部记录 $alldata = $dbo->getAll($this->sql . $cond->getWhere() . ' group by FCustomerType ' . $order->getOrder()); $xls = new class_excel(); $xls->addArray($this->gethead($alldata)); $xls->addArray($this->getdata($alldata)); $xls->addArray($this->getfoot($alldata)); $xls->generateXML("DeliveryDetail"); }
function actionrepsaleCombine() { //过滤语句 $using = new class_using(); $request = $using->safeUsing('post', 'controller:string,action:string'); //设置查询语句 $dbo =& FLEA::getDBO(); //查询条件-按日期查询 $cond = new class_conditions(); $formdate = isset($request['formdate']) ? $request['formdate'] : date("Y-m-d"); $todate = isset($request['todate']) ? $request['todate'] : date("Y-m-d"); $FA = isset($request['FA']) && !empty($request['FA']) ? trim($this->u2gbk($request['FA'])) : ''; $FB = isset($request['FB']) && !empty($request['FB']) ? trim($this->u2gbk($request['FB'])) : ''; $FB = $FA == $FB ? '' : $FB; $_FA = $FA == '' ? '' : $FA . ','; $_FB = $FB == '' ? '' : $FB . ','; $cond->between($formdate, $todate, 'fdate', 'D', 2); $this->sql = 'select ' . $_FA . $_FB . 'sum(FSaleAmountIncludeTax) as FSaleAmountIncludeTax ,sum(FSaleAmount) as FSaleAmount,sum(FAmount) as FAmount,sum(FProfit) as FProfit,case when sum(FSaleAmount) = 0 then 0 else sum(FProfit)/sum(FSaleAmount) end FProfitRate from v_salesdetail'; //排序 $order = new class_order($request); //获取当前页 $page['cid'] = isset($request['pageNum']) && intval($request['pageNum']) > 0 ? intval($request['pageNum']) : 1; $page['size'] = isset($request['numPerPage']) && intval($request['numPerPage']) > 0 ? intval($request['numPerPage']) : 20; if (trim($_FA . $_FB, ',') == '') { $alldata = $dbo->getAll($this->sql . $cond->getWhere() . $order->getOrder()); } else { $alldata = $dbo->getAll($this->sql . $cond->getWhere() . ' group by ' . trim($_FA . $_FB, ',') . $order->getOrder()); } //获取SQL查询的记录总数 $page['count'] = count($alldata); $allFProfit = $this->_count($alldata, 'FProfit'); $allFSaleAmount = $this->_count($alldata, 'FSaleAmount'); //记录偏移量 $page['offset'] = ($page['cid'] - 1) * $page['size'] > $page['count'] ? $page['count'] : ($page['cid'] - 1) * $page['size']; $data = array_slice($alldata, $page['offset'], $page['size'], true); //处理查询结果 if (isset($data)) { $this->_smarty->assign('formdate', $formdate); $this->_smarty->assign('todate', $todate); $this->_smarty->assign('FA', $FA); $this->_smarty->assign('FB', $FB); $this->_smarty->assign('orderField', $order->getField()); $this->_smarty->assign('orderDirection', $order->getDirection()); $this->_smarty->assign('page', $page); $this->_smarty->assign('data', $data); $this->_smarty->assign('alldata', $alldata); $this->_smarty->assign('allFProfit', $allFProfit); $this->_smarty->assign('allFSaleAmount', $allFSaleAmount); $this->_smarty->display('repsale.Combine.htm'); } }