1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732 |
- <?php
- /**
- * @author darkredz
- */
- class AdminController extends DooController {
- public $staff;
- public $nature = array (
- '1' => '设计',
- '2' => '造价管理',
- '3' => '业主',
- '4' => '交通局',
- '5' => '公路局',
- '6' => '审计',
- '7' => '财政',
- '8' => '审核',
- '9' => '施工',
- '10' => '咨询',
- '11' => '招标代理',
- '12' => '监理',
- '13' => '学校',
- '14' => '个人',
- '15' => '合作伙伴'
- );
- public $tooltip = array (
- '1' => array (
- 'L',
- '点击筛选标签'
- ),
- '2' => array (
- 'M',
- '点击筛选标签'
- ),
- '3' => array (
- 'N',
- '点击筛选标签'
- ),
- '4' => array (
- 'O',
- '点击筛选标签'
- ),
- '5' => array (
- 'P',
- '点击筛选标签'
- ),
- '6' => array (
- 'Q',
- '点击筛选标签'
- ),
- '7' => array (
- 'R',
- '点击筛选标签'
- )
- );
- public $webPath = "http://cld.smartcost.com.cn/upload/emailAnnex/";
- function __construct() {
- if (isset ( $_COOKIE ["adStaff"] )) {
- if (! empty ( $_COOKIE ["adStaff"] )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $this->staff = $staff->getUserByIdList ( $_COOKIE ["adStaff"] );
-
- if ($this->staff [0] ['isadmin'] == 1 && $this->staff [0] ['username'] == 'admin') {
- return "/adminoffice";
- }
- }
- }
-
- Doo::loadCore ( 'uri/DooUriRouter' );
- $router = new DooUriRouter ();
- $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
-
- if ($routeRs ['1'] != "adlogin") {
- header ( 'Content-Type:text/html;charset=utf-8' );
- @header ( "Location: /adlogin" );
- }
- }
- function adlogin() {
-
-
-
- $passwork = $this->get_args('passwork') ? $this->get_args('passwork') : "";
- $uid = $this->get_args('user') ? $this->get_args('user') : "";
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (! empty ( $passwork )) {
- $userinfo = $staff->getOne ( array (
- 'where' => "username='admin'",
- 'asArray' => true
- ) );
-
- if (! empty ( $userinfo )) {
- if ($userinfo ['username'] == $uid && $userinfo ['passwork'] == md5 ( $passwork )) {
- setcookie ( "adStaff", $XDeode->encode ($userinfo ['sid']), time () + 36000, "/" );
- return "/adminoffice";
- }
- }
- }
-
- $data ['staff'] = "";
- $data ['login'] = "";
- if (! empty ( $passwork ))
- $data ['login'] = "inputErrow";
-
- $this->render ( "/admin/adminLogin", $data );
- }
- function adout() {
- setcookie ( "adStaff", "", time () - 3600, "/" );
- return "/adlogin";
- }
- function adminPW() {
- $msg = $this->params ['msg'] ? $this->params ['msg'] : "";
-
- $data ['msg'] = "msg";
- $data ['memu'] = "adminpw";
- $data ['staff'] = $this->staff;
- $data ['msg'] = urldecode ( $this->params ['msg'] );
- $this->render ( "/admin/admin-admininfo", $data );
- }
- function upAdP() {
- $opw = $this->get_args ( 'opw' ) ? $this->get_args ( 'opw' ) : "";
- $npw1 = $this->get_args ( 'npw1' ) ? $this->get_args ( 'npw1' ) : "";
- $npw2 = $this->get_args ( 'npw2' ) ? $this->get_args ( 'npw2' ) : "";
-
- if (! empty ( $opw )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $userinfo = $staff->getOne ( array (
- 'where' => "username='admin'",
- 'asArray' => true
- ) );
-
- if (! empty ( $userinfo )) {
- if ($userinfo ['sid'] == $_COOKIE ["adStaff"] && $userinfo ['passwork'] == md5 ( $opw )) {
- if (($npw1 == $npw2) && ($npw1 != "")) {
- $staff->passwork = md5 ( $npw1 );
- $staff->update ( array (
- 'where' => "sid='" . $_COOKIE ["adStaff"] . "'"
- ) );
- return "/adminpw/" . urlencode ( '密码修改成功' );
- } else
- return "/adminpw/" . urlencode ( '新密码不一致' );
- } else
- return "/adminpw/" . urlencode ( '旧密码不正确' );
- } else
- return "/adminpw/" . urlencode ( '未找到用户' );
- } else
- return "/adminpw/" . urlencode ( '请输入旧密码' );
- }
- function adminoffice() {
- $data ['memu'] = "adminoffice";
-
- $data ['staff'] = $this->staff;
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'district' );
-
- $district = new district ();
- $staff = new staff ();
- $L_category = new L_category ();
-
- $data ['category'] = $L_category->getCategory ();
-
- $data ['district'] = $district->get_lv ( 1 );
-
- foreach ( $data ['category'] as $key => $value ) {
- $data ['category'] [$key] ['count'] = $staff->count ( array (
- 'where' => 'cid=' . $value ['cid']
- ) );
- }
-
- $data ['msg'] = urldecode ( $this->params ['msg'] );
- $this->render ( "/admin/admin_group", $data );
- }
- function addCategory() {
- $msg = "添加成功";
-
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
- $district = $this->get_args ( 'district' ) ? $this->get_args ( 'district' ) : "";
-
- if (! empty ( $title ) && ! empty ( $district )) {
- Doo::loadModel ( 'L_category' );
-
- $L_category = new L_category ();
-
- $L_category->title = $title;
-
- $L_category->districtid = $district;
-
- $L_category->insert ();
- } else {
- $msg = "请输入正确的信息";
- }
-
- return "/adminoffice/" . $msg;
- }
- function adminuser() {
- $data ['memu'] = "adminuser";
- $data ['staff'] = $this->staff;
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
-
- $staff = new staff ();
- $L_category = new L_category ();
-
- $data ['category'] = $L_category->getCategory ();
- $data ['stafflist'] = $staff->getStaff ();
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/admin_user", $data );
- }
- function adduser() {
- $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
- $password = $this->get_args ( 'password' ) ? $this->get_args ( 'password' ) : "";
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
- $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 1;
-
- if (! empty ( $username ) && ! empty ( $password ) && ! empty ( $cid ) && ! empty ( $hiredate ) && ! empty ( $nature )) {
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'tag' );
- Doo::loadModel ( 'holidaystaff' );
-
- $staff = new staff ();
- $L_category = new L_category ();
-
- // 加入默认总部分类
- $cagegory = $L_category->getCategoryById ( $cid );
-
- // 根据这个分类加入管理权限
- if ($cagegory [0] ['defult'] == 1) {
- $staff->isadmin = 1;
- }
-
- $staff->username = $username;
- $staff->passwork = md5 ( $password );
- $staff->cid = $cagegory [0] ['cid'];
- $staff->category = $cagegory [0] ['title'];
- $staff->hiredate = $hiredate;
- $staff->nature = $nature;
- $id = $staff->insert ();
-
- $holidaystaff = new HStaff ();
- $holidaystaff->uid = $id;
- $holidaystaff->insert();
- $staffmsg = $staff->getUserById($id);
- $this->updateAnnualLeave($staffmsg[0]);
- for ($i=1;$i<=7;$i++){
- $tag = new tag ();
- $tag->name = "个人标签";
- $tag->sid = $id;
- $tag->colorid = $i;
- $tag->insert ();
- }
- }
- return "/adminuser";
- }
- function adminEdiUser() {
- $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
- $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
-
- if (! empty ( $sid )) {
-
- $data ['msg'] = urldecode ( $msg );
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
-
- $data ['newPw'] = '';
- $data ['staffInfo'] = $staff->getUserById ( $sid );
- $data ['category'] = $L_category->getCategory ();
- $data ['staff'] = $this->staff;
- $data ['memu'] = "adminuser";
- $this->render ( "/admin/admin_EdiUser", $data );
- } else
- return "/adminuser";
- }
- function adminResetUserPw() {
- $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
- $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
- if (! empty ( $sid )) {
-
- $data ['msg'] = urldecode ( $msg );
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
-
- $newPw = $this->getRandChar ( 6 );
- $staff->sid = $sid;
- $staff->passwork = md5 ( $newPw );
- $staff->update ();
-
- $data ['newPw'] = $newPw;
- $data ['staffInfo'] = $staff->getUserById ( $sid );
- $data ['category'] = $L_category->getCategory ();
- $data ['staff'] = $this->staff;
- $data ['memu'] = "adminuser";
- $this->render ( "/admin/admin_EdiUser", $data );
- } else
- return "/adminuser";
- }
- function adminDoEdiUser() {
- $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
- $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
- $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
- $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
- $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
- $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
- $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
- $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
-
- if (! empty ( $sid )) {
- $msg = "";
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
-
- $staff = new staff ();
- $L_category = new L_category ();
-
- $categoryInfo = $L_category->getCategoryById ( $cid );
-
- $staff->sid = $sid;
-
- if ($cid != 0) {
- $staff->cid = $categoryInfo [0] ['cid'];
- $staff->category = $categoryInfo [0] ['title'];
- }
-
- if ($categoryInfo [0] ['defult'] == 1) {
- $staff->isadmin = 1;
- } else {
- $staff->isadmin = 0;
- }
-
- if (! empty ( $username ))
- $staff->username = $username;
- if (! empty ( $gender ))
- $staff->gender = $gender;
-
- if (! empty ( $qq ) && is_numeric ( $qq ))
- $staff->qq = $qq;
-
- if (! empty ( $phone ))
- $staff->phone = $phone;
-
- if (! empty ( $telephone ))
- $staff->telephone = $telephone;
-
- if (! empty ( $email ) && filter_var ( $email, FILTER_VALIDATE_EMAIL ))
- $staff->email = $email;
- else
- $msg = "邮箱不正确";
-
- if (! empty ( $hiredate ))
- $staff->hiredate = $hiredate;
-
- $staff->nature = $nature;
-
- $staff->update ();
-
- $staffmsg = $staff->getUserById ( $sid );
- $this->updateAnnualLeave ( $staffmsg [0] );
-
- return "/edi/user/" . $sid . "/" . $msg;
- } else {
- return "/adminuser";
- }
- }
- function adminDoAddCategory() {
- $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
-
- if (! empty ( $sid )) {
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
-
- $stfInfo = $staff->getOne ( array (
- 'where' => 'sid =' . $sid,
- 'asArray' => true
- ) );
- if ($stfInfo ['cid'] == $cid)
- return "/adminuser";
-
- $othcid = explode ( ',', $stfInfo ['othercid'] );
- if (in_array ( $cid, $othcid ))
- return "/adminuser";
-
- array_push ( $othcid, $cid );
- $strCid = implode ( ',', array_filter ( $othcid ) );
- $catename = $L_category->getCategoryById ( $cid );
- $othcategory = explode ( ',', $stfInfo ['othercategory'] );
- array_push ( $othcategory, $catename [0] ['title'] );
- $strcategory = implode ( ',', array_filter ( $othcategory ) );
- $staff->sid = $sid;
- $staff->othercid = $strCid;
- $staff->othercategory = $strcategory;
- $staff->update ();
- }
- return "/adminuser";
- }
- function adminDeleteUser() {
- $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
- if (! empty ( $sid )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $staff->sid = $sid;
- $staff->delete ();
- Doo::loadModel ('holidaystaff');
- $hstaff = new HStaff();
- $hstaff->uid = $sid;
- $hstaff->delete();
- }
- return "/adminuser";
- }
- function adminproduct() {
- $data ['memu'] = "adminproduct";
- $data ['staff'] = $this->staff;
-
- Doo::loadModel ( 'product' );
- Doo::loadModel ( 'longle' );
-
- $product = new product ();
- $longle = new longle ();
-
- $data ['product'] = $product->getProudct ();
- foreach ( $data ['product'] as $key => $value ) {
- $data ['product'] [$key] ['count'] = $longle->count ( array (
- 'where' => 'product="' . $value ['title'] . '"'
- ) );
- }
-
- $this->render ( "/admin/admin_product", $data );
- }
- function addproduct() {
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
-
- if (! empty ( $title )) {
- Doo::loadModel ( 'product' );
- $product = new product ();
- $product->title = $title;
- $product->insert ();
- }
- return "/adminproduct";
- }
- function adminDeleteProduct() {
- $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
- if (! empty ( $pid )) {
- Doo::loadModel ( 'product' );
- $product = new product ();
- $product->pid = $pid;
- $product->delete ();
- }
- return "/adminproduct";
- }
- function adminEdiProduct() {
- $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
- $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
-
- if (! empty ( $pid )) {
- $data ['msg'] = urldecode ( $msg );
- Doo::loadModel ( 'product' );
- $product = new product ();
-
- $data ['productInfo'] = $product->getProductById ( $pid );
-
- $data ['memu'] = "adminproduct";
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/admin_EdiProduct", $data );
- } else
- return "/adminproduct";
- }
- function adminDoEdiProduct() {
- $pid = is_numeric ( $this->get_args ( 'pid' ) ) ? $this->get_args ( 'pid' ) : "";
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
- $typeid = $this->get_args ( 'typeid' ) ? $this->get_args ( 'typeid' ) : "";
- if (! empty ( $pid ) && ! empty ( $title ) && ! empty ( $typeid )) {
- $msg = "";
- Doo::loadModel ( 'product' );
- $product = new product ();
- $product->pid = $pid;
- $product->title = $title;
- $product->typeid = $typeid;
- $product->update ();
- return "/adminproduct";
- } else {
- return "/adminproduct";
- }
- }
- function adminverify() {
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( "verify" );
- $verify = new verify ();
- $staff = new staff ();
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $verify->find ( array (
- 'asArray' => true
- ) );
- $roleList = $role->find ( array (
- 'asArray' => true
- ) );
-
- foreach ( $roleList as $key => $value ) {
- $staffList = json_decode ( $value ['staff'] );
-
- foreach ( $staffList as $k => $v ) {
- $staffList [$k] = substr ( strstr ( $v, '_' ), 1 );
- }
-
- $roleList [$key] ['staff'] = implode ( ',', $staffList );
- }
-
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $list [$key] ['staff'] = "";
- foreach ( $name as $k => $v ) {
- if ($v [1] == 'ROLE') {
- $roleInfo = $role->getOne ( array (
- 'where' => 'rid = "' . $v [0] . '"',
- 'asArray' => true
- ) );
- $v [1] = $roleInfo ['name'];
- }
- $list [$key] ['staff'] .= " " . $v [1];
- }
- }
-
- $data ['roleList'] = $roleList;
- $data ['verify'] = $list;
- $data ['memu'] = "verify";
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/admin_reportGroup", $data );
- }
- function addVerify() {
- $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
-
- $uidlist = explode ( ",", $uidlist );
-
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $list = array ();
- foreach ( $uidlist as $key => $value ) {
- $info = explode ( ":", $value );
- if ($info [1] == 'ROLE') {
- $roleInfo = $role->getOne ( array (
- 'where' => 'rid = "' . $info [0] . '"',
- 'asArray' => true
- ) );
- array_push ( $info, $roleInfo ['staff'] );
- }
- array_push ( $list, $info );
- }
-
- if (! empty ( $description ) && ! empty ( $list )) {
- Doo::loadModel ( "verify" );
- $verify = new verify ();
-
- $verify->description = $description;
- $verify->staff = json_encode ( $list );
- $verify->insert ();
- }
-
- return "/adminverify";
- }
- function adminRole() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "verify" );
- $verify = new verify ();
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $verify->find ( array (
- 'asArray' => true
- ) );
- $roleList = $role->find ( array (
- 'asArray' => true
- ) );
-
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $list [$key] ['staff'] = "";
- foreach ( $name as $k => $v ) {
- $list [$key] ['staff'] .= " " . $v [1];
- }
- }
-
- foreach ( $roleList as $key => $value ) {
- $staff = json_decode ( $value ['staff'] );
-
- foreach ( $staff as $k => $v ) {
- // print_r($info);
- // $staff[$k]=substr(strstr($v, '_'), 1);
- $info = explode ( '_', $v );
- $staff [$k] = $info;
- }
- $roleList [$key] ['list'] = $staff;
- }
-
- $data ['roleList'] = $roleList;
- $data ['verify'] = $list;
- $data ['memu'] = "verify";
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminReportGroupRole", $data );
- }
- function addRole() {
- $name = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- $list = array ();
- foreach ( $staff as $key => $value ) {
- $na = explode ( ":", $value );
- array_push ( $list, $na [0] . '_' . $na [1] );
- }
-
- if (! empty ( $name ) && ! empty ( $list )) {
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $role->name = $name;
- $role->staff = json_encode ( $list );
- $role->insert ();
- }
- return "/adminRole";
- }
- function delRole() {
- $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
-
- if (! empty ( $rid )) {
- Doo::loadModel ( "role" );
- $role = new role ();
- $role->delete ( array (
- 'where' => 'rid="' . $rid . '"'
- ) );
- }
- return "/adminRole";
- }
- function updateRole() {
- $oldStaff = $this->get_args ( 'oldStaff' ) ? $this->get_args ( 'oldStaff' ) : "";
- $newStaff = $this->get_args ( 'newStaff' ) ? $this->get_args ( 'newStaff' ) : "";
- $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
-
- if (! empty ( $oldStaff ) && ! empty ( $newStaff ) && ! empty ( $rid )) {
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $roleInfo = $role->getOne ( array (
- 'where' => 'rid = "' . $rid . '"',
- 'asArray' => true
- ) );
-
- $staffList = json_decode ( $roleInfo ['staff'], true );
-
- foreach ( $staffList as $key => $value ) {
- if ($value == $oldStaff) {
- $staffList [$key] = $newStaff;
- break;
- }
- }
-
- $role->staff = json_encode ( $staffList );
- $role->update ( array (
- 'where' => 'rid = "' . $rid . '"'
- ) );
- }
- return "/adminRole";
- }
- function adminExecute() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $execute->find ( array (
- 'asArray' => true
- ) );
-
- $execute = array (
- '借款执行人' => '',
- '借款费用执行人' => '',
- '报销单执行人' => '',
- '对公汇款执行人' => ''
- );
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $staffString = "";
- if (! empty ( $name )) {
- foreach ( $name as $k => $v ) {
-
- $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
- }
- }
- foreach ( $execute as $k => $v ) {
- if ($k == $value ['mold']) {
- $execute [$k] = $name = $staffString;
- }
- }
- }
- // print_r($execute);die;
- $data ['execute'] = $execute;
- $data ['memu'] = "verify";
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminCarriedout", $data );
- }
- function addExecute() {
- $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- if (! empty ( $mold ) && ! empty ( $staff )) {
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'mold ="' . $mold . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo )) {
-
- $list = array ();
- foreach ( $staff as $key => $value ) {
- $info = explode ( ":", $value );
- array_push ( $list, $info );
- }
-
- $execute->mold = $mold;
- $execute->staff = json_encode ( $list );
-
- $execute->insert ();
- } else {
- $list = json_decode ( $executeInfo ['staff'], true );
-
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- foreach ( $list as $key => $value ) {
- if ($value [1] == $info [1]) {
- unset ( $staff [$k] );
- break;
- }
- }
- }
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- array_push ( $list, $info );
- }
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'eid = ' . $executeInfo ['eid']
- ) );
- }
- }
- return "/adminExecute";
- }
- function delExecute() {
- $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
- $eid = isset ( $this->params ['eid'] ) && is_numeric ( $this->params ['eid'] ) ? $this->params ['eid'] : 0;
-
- if (! empty ( $uid ) && ! empty ( $eid )) {
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'eid ="' . $eid . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo ))
- return "/adminExecute";
-
- $ini = array ();
- $list = json_decode ( $executeInfo ['staff'], true );
- foreach ( $list as $k => $v ) {
- if ($v [0] == $uid) {
- $ini = $list [$k];
- unset ( $list [$k] );
- break;
- }
- }
-
- file_put_contents ( "protected/config/execute/execute.ini", "," . $ini [0], FILE_APPEND );
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'eid = ' . $executeInfo ['eid']
- ) );
- }
-
- return "/adminExecute";
- }
- function adminInvoice() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceManage" );
- $invoiceManage = new invoiceManage ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $invoiceManage->find ( array (
- 'asArray' => true
- ) );
-
- $execute = array (
- '收款管理' => '',
- '发票审批' => '',
- '发票打印' => '',
- '发票邮寄' => '',
- '发票退票' => '',
- '公司汇总查阅' => ''
- );
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $staffString = "";
- if (! empty ( $name )) {
- foreach ( $name as $k => $v ) {
-
- $staffString .= "<span class='tagGroup'> " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceManage/' . $v [0] . '/' . $value ['iid'] . '\'" title="删除" class="icon-">k</a></span>';
- }
- }
- foreach ( $execute as $k => $v ) {
- if ($k == $value ['mold']) {
- $execute [$k] = $name = $staffString;
- }
- }
- }
-
- $data ['invoice'] = $execute;
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminInvoice", $data );
- }
- function addInvoiceManage() {
- $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- if (! empty ( $mold ) && ! empty ( $staff )) {
- Doo::loadModel ( "invoiceManage" );
- $execute = new invoiceManage ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'mold ="' . $mold . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo )) {
-
- $list = array ();
- foreach ( $staff as $key => $value ) {
- $info = explode ( ":", $value );
- array_push ( $list, $info );
- }
-
- $execute->mold = $mold;
- $execute->staff = json_encode ( $list );
-
- $execute->insert ();
- } else {
- $list = json_decode ( $executeInfo ['staff'], true );
-
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- foreach ( $list as $key => $value ) {
- if ($value [1] == $info [1]) {
- unset ( $staff [$k] );
- break;
- }
- }
- }
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- array_push ( $list, $info );
- }
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'iid = ' . $executeInfo ['iid']
- ) );
- }
- }
- return "/adminInvoice";
- }
-
- /**
- * 发票相关权限配置,把相关组的审批人删除。不会影响已经生成发票数据,修改后只会影响修改后生成的发票数据
- * @return string 返回配置页
- */
- function delInvoiceManage() {
- $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
- $iid = isset ( $this->params ['iid'] ) && is_numeric ( $this->params ['iid'] ) ? $this->params ['iid'] : 0;
-
- if (! empty ( $uid ) && ! empty ( $iid )) {
- Doo::loadModel ( "invoiceManage" );
- $execute = new invoiceManage ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'iid ="' . $iid . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo ))
- return "/adminInvoice";
-
- $ini = array ();
- $list = json_decode ( $executeInfo ['staff'], true );
- foreach ( $list as $k => $v ) {
- if ($v [0] == $uid) {
- $ini = $list [$k];
- unset ( $list [$k] );
- break;
- }
- }
-
- $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
- if (! empty ( $fileInvoice )) {
- $fileInvoice = json_decode ( $fileInvoice, true );
- if (isset ( $fileInvoice [$executeInfo ['mold']] ))
- $fileInvoice [$executeInfo ['mold']] .= "," . $ini [0];
- else
- $fileInvoice [$executeInfo ['mold']] = '';
- $moldArray = explode ( ',', $fileInvoice [$executeInfo ['mold']] );
- $moldArray = array_unique ( $moldArray );
- $fileInvoice [$executeInfo ['mold']] = implode ( ',', $moldArray );
- $fileInvoice = json_encode ( $fileInvoice );
- file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
- } else {
- $fileInvoice = array (
- $executeInfo ['mold'] => $ini [0]
- );
- $fileInvoice = json_encode ( $fileInvoice );
- file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
- }
-
- file_put_contents ( "protected/config/execute/invoice.ini", "," . $ini [0], FILE_APPEND );
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'iid = ' . $executeInfo ['iid']
- ) );
- }
- return "/adminInvoice";
- }
-
-
-
- function ajaxRoleStaff() {
- $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $staffList = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'where' => 'username != "' . $name . '" and username !="admin"',
- 'asArray' => true
- ) );
-
- $html = '';
- foreach ( $staffList as $key => $value ) {
- $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
- }
-
- echo json_encode ( array (
- "success" => true,
- 'html' => $html
- ) );
- die ();
- }
- function loadCVS() {
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $list = $longle->find ( array (
- 'select' => 'key_num',
- 'asArray' => TRUE
- ) );
-
- $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
-
- while ( $data = fgetcsv ( $file ) ) {
- $goods_list [$data [0]] = $data [1];
- }
- fclose ( $file );
-
- $sqlArray = array ();
- $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
- foreach ( $list as $key => $value ) {
-
- if (array_key_exists ( $value ['key_num'], $goods_list )) {
- // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
- // $longle->SerialNumber=$goods_list[$value['key_num']];
- // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
- $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
-
- array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
- unset ( $goods_list [$value ['key_num']] );
- }
- }
- $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
- echo $sql . '<br/>--------------------------------<br/>';
- foreach ( $goods_list as $key => $value ) {
- echo $key . ',' . $value . '<br/>';
- }
- }
- private function getRandChar($length) {
- $str = null;
- $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
- $max = strlen ( $strPol ) - 1;
-
- for($i = 0; $i < $length; $i ++) {
- $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
- }
-
- return $str;
- }
- private function getReceiptCount() {
- $status = 2;
- $year = date ( 'Y' );
-
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- Doo::loadModel ( 'verify' );
- $verify = new verify ();
-
- // user verify ID
- $vidList = array ();
- $verifyDetail = $verify->find ( array (
- 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
- 'asArray' => true
- ) );
- foreach ( $verifyDetail as $key => $value ) {
- array_push ( $vidList, $value ['vid'] );
- }
- $vid = implode ( ",", $vidList );
- if (empty ( $verifyDetail ))
- $vid = 0;
-
- $dateCondition = " and Year(date) =" . $year;
- $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
-
- $receiptList = $receipt->find ( array (
- 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
- 'desc' => 'rid',
- 'asArray' => true
- ) );
-
- return count ( $receiptList );
- }
-
- /**
- * 格式化excel文件为数组
- * @param unknown_type $file_url
- * @param unknown_type $mcid
- */
- function _format_excel_to_array($file_url = "") {
- if (! file_exists ( $file_url ))
- return array ();
-
- Doo::loadClass ( 'PHPExcel' );
-
- $PHPExcel = new PHPExcel ();
-
- $PHPReader = new PHPExcel_Reader_Excel2007 ();
-
- if (! $PHPReader->canRead ( $file_url )) {
- $PHPReader = new PHPExcel_Reader_Excel5 ();
- if (! $PHPReader->canRead ( $file_url )) {
-
- echo 'no Excel';
- return;
- }
- }
-
- $PHPExcel = $PHPReader->load ( $file_url );
- /**
- * 读取excel文件中的第一个工作表
- */
- $currentSheet = $PHPExcel->getSheet ( 0 );
- /**
- * 取得最大的列号
- */
- $allColumn = $currentSheet->getHighestColumn ();
- /**
- * 取得一共有多少行
- */
- $allRow = $currentSheet->getHighestRow ();
-
- $excel_array = array ();
-
- for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
-
- $excel_column = array ();
-
- // 后期改进
- if ($allColumn == 'AM')
- $allColumn = 'Z';
-
- /**
- * 从第A列开始输出
- */
- for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
-
- $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
-
- /**
- * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
- */
- $val = "'" . addslashes ( $val ) . "'";
- if ($currentColumn == 'A')
- $excel_column ['key_num'] = $val;
- elseif ($currentColumn == 'C')
- $excel_column ['product'] = $val;
- elseif ($currentColumn == 'D') {
-
- $val = str_replace ( "'", "", $val );
-
- $excel_column ['make_day'] = $this->excelTime ( $val );
- } elseif ($currentColumn == 'E') {
- $val = str_replace ( "'", "", $val );
-
- $excel_column ['alloted_time'] = $this->excelTime ( $val );
- } elseif ($currentColumn == 'F') {
- $val = str_replace ( "'", "", $val );
-
- $excel_column ['version'] = $val;
- } elseif ($currentColumn == 'B') {
- $val = str_replace ( "'", "", $val );
- $excel_column ['SerialNumber'] = $val;
- }
- }
- array_push ( $excel_array, $excel_column );
- }
-
- return $excel_array;
- }
- function excelTime($date, $time = false) {
- if (function_exists ( 'GregorianToJD' )) {
- if (is_numeric ( $date )) {
- $jd = GregorianToJD ( 1, 1, 1970 );
- $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
- $date = explode ( '/', $gregorian );
- $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
- return $date_str;
- }
- } else {
- $date = $date > 25568 ? $date + 1 : 25569;
- /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
- $ofs = (70 * 365 + 17 + 2) * 86400;
- $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
- }
- return $date;
- }
- function _GetFileEXT($filename) {
- $pics = explode ( '.', $filename );
-
- $num = count ( $pics );
-
- return $pics [$num - 1];
- }
-
- /**
- * 获取get或者POST值
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else {
- return addslashes ( $_GET [$name] );
- }
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else {
- return addslashes ( $_POST [$name] );
- }
- } else {
- return false;
- }
- }
- function get_previous($on_page = 1) {
- return $on_page != 0 ? $on_page - 1 : $on_page;
- }
-
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
- $page_c = "";
- $page ['previous'] = $this->get_previous ( $on_page );
- $page ['on_page'] = $on_page;
- $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
- $total = intval ( $total_count / $page_size );
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
- $page ['total_data'] = $total_count;
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
- $i = 1;
- $page_max = 1;
- if ($on_page > 10) {
- $page_max = intval ( $on_page / 10 ) + 1;
- $i = intval ( $on_page / 10 ) * 10 - 1;
- }
- $page ['page'] = $page_c;
- $page ['lower'] = (-- $on_page) * $page_size;
- return $page;
- }
-
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
- $page_c = "";
-
- $page ['previous'] = $this->get_previous ( $on_page );
-
- $page ['on_page'] = $on_page;
-
- $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
-
- $total = intval ( $total_count / $page_size );
-
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
-
- $page ['total_data'] = $total_count;
-
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
-
- $i = 1;
-
- $page_max = 1;
-
- if ($on_page > 10) {
- $page_max = intval ( $on_page / 10 ) + 1;
- $i = intval ( $on_page / 10 ) * 10 - 1;
- }
-
- for(; $i <= $page ['total_page']; $i ++) {
-
- if ($i == $on_page) {
- if ($other == "page")
- $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
- else
- $page_c .= ' <span class="current">' . $i . '</span> ';
- } else if ($other == "page")
- $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
- else
- $page_c .= ' <a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a> ';
- if ($i == (10 * $page_max))
- break;
- }
-
- $page ['page'] = $page_c;
-
- $page ['lower'] = (-- $on_page) * $page_size;
-
- return $page;
- }
-
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
- if ($tagSQL)
- $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
- else
- $sql = "select count(*) as count from CLD_company where " . $condition;
-
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
- return $result ['count'];
- }
-
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
- // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
- // echo $staffid;die;
- //
- if (! empty ( $staffid )) {
- // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
- $sql = "select count(*) as count from CLD_client as b left join CLD_tag_client as c on (b.cid=c.client) where 1 " . $condition;
- } else {
- if (strlen ( $condition ) == 1 || empty ( $condition ))
- $sql = "select count(*) as count from CLD_client as a " . $condition;
- else
- $sql = "select count(*) as count from CLD_client as a left join CLD_tag_client as c on (a.cid=c.client) where 1 " . $condition;
- }
-
- if (! empty ( $search ))
- $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
-
- if (! empty ( $tooltip )) {
- $condition = str_replace ( "a.", "c.", $condition );
- if ($tagSQL)
- $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_tag_client as c on (a.cid=c.client) left join CLD_client as b on (c.client=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
- else
- $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_client as b on (a.cid=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
- }
- // echo $sql;
- $query = Doo::db ()->query ( $sql );
-
- $result = $query->fetch ();
-
- return $result ['count'];
- }
- public function holidayGroup(){
- Doo::loadModel('staff');
- Doo::loadModel("holidayacman");
- Doo::loadModel('L_category');
- $L_category = new L_category();
- $acman=new HACMan();
- $staff=new staff();
- $data['staffList']=$staff->find(array('select'=>'username,sid,wxid', 'where' => 'cid!=1','asArray'=>true));
- $acmanlist=$acman->find(array('where' => 'type=0', 'desc' => 'id','asArray'=>true));
- if(!empty($acmanlist)){
- foreach($acmanlist as $k => $v){
- $acmanlist[$k]['name'] = implode('->', explode(' ', $v['name']));
- $category = explode(',',$v['category']);
- $categoryname = array();
- if(!empty($category)){
- foreach($category as $key => $value){
- $name = $L_category->getOne(array('where' => 'cid="'.$value.'"', 'asArray' => TRUE));
- array_push($categoryname,$name['title']);
- }
- }
- $acmanlist[$k]['categoryname'] = implode(',',$categoryname);
- }
- }
- //获取办事处列表
- $data['category']=$L_category->getCategory();
- $data['acmanlist'] = $acmanlist;
- $data['staff']=$this->staff;
- $data['memu'] = 'holiday';
- $data['noindexjs'] = 'noindexjs';
- $this->render( "/admin/admin_holidayGroup", $data );
- }
- public function addHolidayApprover() {
- if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
- exit ( '请输入组名' );
- }
- if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
- exit ( '请选择成员' );
- }
-
-
-
- $idname = $name = $pinyinname = array ();
- $stafflist = explode(',',$_POST['staff']);
- foreach ( $stafflist as $k => $v ) {
- $msg = explode ( ':', $v );
- array_push ( $idname, $msg [0] );
- array_push ( $name, $msg [1] );
- array_push ( $pinyinname, $msg [2] );
- }
- Doo::loadModel("holidayacman");
- $acman=new HACMan();
- $acman->typename = $_POST['title'];
- $acman->idname = implode(',', $idname);
- $acman->name = implode(' ', $name);
- $acman->pinyinname = implode('|', $pinyinname);
- $acman->type = 0;
- $result = $acman->insert();
- if($result){
- $acman2=new HACMan();
- $acman2->type = $result;
- $acman2->insert();
- Doo::loadModel('holidaystaff');
- foreach($idname as $ik => $iv){
- $hstaff = new HStaff();
- $hstaff->uid = $iv;
- $hstaff->isadmin = 1;
- $hstaff->update();
- }
- }
- return '/holidaygroup';
- }
- public function setHolidaySee(){
- if(!isset($_POST['groupid']) || empty($_POST['groupid']) || !is_numeric($_POST['groupid'])){
- exit('审批组id出错');
- }
- $category = !empty($_POST['category']) ? implode(',', $_POST['category']) : '';
- Doo::loadModel('holidayacman');
- $acman = new HACMan();
- $acman->id = $_POST['groupid'];
- $acman->category = $category;
- $acman->update();
- return '/holidaygroup';
- }
- public function delHolidayGroup(){
- if(!isset($_POST['approvalid']) || empty($_POST['approvalid']) || !is_numeric($_POST['approvalid'])){
- exit('审批组id出错');
- }
- Doo::loadModel('holidayacman');
- $acman = new HACMan();
- $idname = $acman->getOne(array('where' => 'id='.$_POST['approvalid'], 'asArray' => TRUE));
- $idname = explode(',', $idname['idname']);
- $acman->id = $_POST['approvalid'];
- $acman->delete();
- // $acman2 = new HACMan();
- // $acman2->type = $_POST['approvalid'];
- // $acman2->delete();
- //删除管理员资格
- $acman3 = new HACMan();
- foreach($idname as $k => $v){
- $same = 0;
- $approverlist = $acman3->find(array('where' => 'idname like "%'.$v.'%" and type=0', 'asArray' => TRUE));
- if(!empty($approverlist)){
- foreach($approverlist as $ak => $av){
- $aidname = explode(',', $av['idname']);
- foreach($aidname as $ik => $iv){
- if($iv == $v){
- $same = 1;
- break;
- }
- }
- }
- }
- if($same == 0){
- Doo::loadModel('holidaystaff');
- $hstaff = new HStaff();
- $hstaff->uid = $v;
- $hstaff->isadmin = 0;
- $hstaff->update();
- }
- }
- return '/holidaygroup';
- }
- public function holidayCSGroup(){
- Doo::loadModel('staff');
- Doo::loadModel('holidayacman');
- $acman = new HACMan();
- $staff = new staff();
- $approverlist = $acman->find(array('where' => 'type=0', 'desc' => 'id', 'asArray' => TRUE));
- if(!empty($approverlist)){
- foreach($approverlist as $k => $v){
- $csman = $acman->getOne(array('where' => 'type='.$v['id'], 'asArray' => TRUE));
- if(!empty($csman['name'])){
- $idname = explode(',',$csman['idname']);
- $name = explode(' ',$csman['name']);
- $pinyinname = explode('|',$csman['pinyinname']);
- $csmsg = array();
- foreach($idname as $ik => $iv){
- $csmsg[$ik]['csidname'] = $iv;
- $csmsg[$ik]['csname'] = $name[$ik];
- $csmsg[$ik]['cspinyinname'] = $pinyinname[$ik];
- }
- $approverlist[$k]['csmsg'] = $csmsg;
- }
- }
- $data['approverlist'] = $approverlist;
- }
- //获取总部人员列表
- $zongbu = $staff->getStaffByCid(12);
- $data['zongbu'] = $zongbu;
- //获取办事处列表
- Doo::loadModel('L_category');
- $L_category = new L_category();
- $data['category']=$L_category->getCategory();
- $data['memu'] = 'holiday';
- $data['noindexjs'] = 'noindexjs';
- $this->render( "/admin/admin_holidayGroup_cc", $data );
- }
- public function getStaffCategory(){
- if(isset($_POST['cid']) && is_numeric($_POST['cid'])){
- Doo::loadModel('staff');
- $staff = new staff();
- $stafflist = $staff->getStaffByCid($_POST['cid']);
- exit(json_encode(array('code' => 200, 'stafflist' => $stafflist)));
- }
- exit(json_encode(array('code' => 400)));
- }
- public function addHolidayCS(){
- if(!isset($_POST['approvalid']) || empty($_POST['approvalid']) || !is_numeric($_POST['approvalid'])){
- exit('审批组出错');
- }
- if(!isset($_POST['cidstaff']) || empty($_POST['cidstaff'])){
- exit('抄送人出错');
- }
- $cidstaff = explode(':',$_POST['cidstaff']);
- Doo::loadModel('holidayacman');
- $acman = new HACMan();
- $csmsg = $acman->getOne(array('where' => 'type='.$_POST['approvalid'], 'asArray' => TRUE));
- $csidmsg = !empty($csmsg['idname']) ? $csmsg['idname'].','.$cidstaff[0] : $cidstaff[0];
- $csnamemsg = !empty($csmsg['name']) ? $csmsg['name'].' '.$cidstaff[1] : $cidstaff[1];
- $cspinyinnamemsg = !empty($csmsg['pinyinname']) ? $csmsg['pinyinname'].'|'.$cidstaff[2] : $cidstaff[2];
- $acman->id = $csmsg['id'];
- $acman->idname = $csidmsg;
- $acman->name = $csnamemsg;
- $acman->pinyinname = $cspinyinnamemsg;
- $acman->update();
- Doo::loadModel('holidaystaff');
- $hstaff = new HStaff();
- $hstaffmsg = $hstaff->getOne(array('where' => 'uid=?','param' => array($cidstaff[0]), 'asArray' => TRUE));
- if(!empty($hstaffmsg) && $hstaffmsg['iscc'] == 0){
- $hstaff->uid = $cidstaff[0];
- $hstaff->iscc = 1;
- $hstaff->update();
- }
- return '/hcsgroup';
- }
- public function delHolidayCS(){
- if(!isset($_POST['approvalid']) || empty($_POST['approvalid']) || !is_numeric($_POST['approvalid'])){
- exit('审批id出错');
- }
- if(!isset($_POST['cidstaff']) || empty($_POST['cidstaff'])){
- exit('抄送信息出错');
- }
- $cidstaff = explode(':',$_POST['cidstaff']);
- Doo::loadModel('holidayacman');
- $acman = new HACMan();
- $csmsg = $acman->getOne(array('where' => 'type='.$_POST['approvalid'], 'asArray' => TRUE));
- if(!empty($csmsg['idname'])){
- $idnamearr = explode(',', $csmsg['idname']);
- foreach($idnamearr as $ik => $iv){
- if($iv == $cidstaff[0]){
- unset($idnamearr[$ik]);
- break;
- }
- }
- $csidmsg = implode(',',$idnamearr);
- }
- if(!empty($csmsg['name'])){
- $namearr = explode(' ', $csmsg['name']);
- foreach($namearr as $nk => $nv){
- if($nv == $cidstaff[1]){
- unset($namearr[$nk]);
- break;
- }
- }
- $csnamemsg = implode(' ',$namearr);
- }
- if(!empty($csmsg['pinyinname'])){
- $pinyinnamearr = explode('|', $csmsg['pinyinname']);
- foreach($pinyinnamearr as $pk => $pv){
- if($pv == $cidstaff[2]){
- unset($pinyinnamearr[$pk]);
- break;
- }
- }
- $cspinyinnamemsg = implode('|',$pinyinnamearr);
- }
- $acman->id = $csmsg['id'];
- if(isset($csidmsg)){
- $acman->idname = $csidmsg;
- }
- if(isset($csnamemsg)){
- $acman->name = $csnamemsg;
- }
- if(isset($cspinyinnamemsg)){
- $acman->pinyinname = $cspinyinnamemsg;
- }
- $acman->update();
- //删除抄送员资格
- $acman3 = new HACMan();
- $same = 0;
- $approverlist = $acman3->find(array('where' => 'idname like "%'.$cidstaff[0].'%" and type!=0', 'asArray' => TRUE));
- if(!empty($approverlist)){
- foreach($approverlist as $ak => $av){
- $aidname = explode(',', $av['idname']);
- foreach($aidname as $ik => $iv){
- if($iv == $cidstaff[0]){
- $same = 1;
- break;
- }
- }
- }
- }
- if($same == 0){
- Doo::loadModel('holidaystaff');
- $hstaff = new HStaff();
- $hstaff->uid = $cidstaff[0];
- $hstaff->iscc = 0;
- $hstaff->update();
- }
- return '/hcsgroup';
- }
- public function HolidayAdmin(){
- Doo::loadModel('staff');
- $staff=new staff();
- $staffList=$staff->find(array('select'=>'username,sid', 'where' => 'cid!=1','asArray'=>true));
- Doo::loadModel('holidayadmin');
- $admin = new HAdmin();
- $adminList = $admin->find(array('asArray' => TRUE));
- if(!empty($adminList)){
- foreach($adminList as $k => $v){
- foreach($staffList as $sk => $sv){
- if($sv['sid'] == $v['uid']){
- array_splice($staffList, $sk,1);
- break;
- }
- }
- }
- }
- $data['staffList'] = $staffList;
- $data['adminList'] = $adminList;
- $data['memu'] = 'holiday';
- $data['noindexjs'] = 'noindexjs';
- $this->render( "/admin/admin_holidayuser", $data );
- }
- public function addHolidayAdmin(){
- if(!isset($_POST['staff']) || empty($_POST['staff'])){
- exit('请选择管理人');
- }
- Doo::loadModel('holidayadmin');
- foreach($_POST['staff'] as $k => $v){
- $staffmsg = explode(':',$v);
- $admin = new HAdmin();
- $admin->uid = $staffmsg[0];
- $admin->username = $staffmsg[1];
- $admin->insert();
- }
- return '/holidayadmin';
- }
- public function delHolidayAdmin(){
- if(!isset($_POST['cidstaff']) || empty($_POST['cidstaff'])){
- exit('请选择管理人删除');
- }
- Doo::loadModel('holidayadmin');
- $admin = new HAdmin();
- $admin->id = $_POST['cidstaff'];
- $admin->delete();
- return '/holidayadmin';
- }
- //检查年假是否过期并更新年假
- private function updateAnnualLeave($staff){
- Doo::loadModel('holidaystaff');
- $hstaff = new HStaff();
- $hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$staff['sid'],'asArray' => TRUE));
- $hiredate = $staff['hiredate'];
- $hadyear = intval((time()-strtotime($hiredate))/(86400*365));
- if($hadyear != $hstaffmsg['hadyear']){
- $hstaff->uid = $staff['sid'];
- $hstaff->hadyear = $hadyear;
- $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
- $hstaff->update();
- }
- }
- }
- ?>
|