Пример #1
0
 function genMenu($config)
 {
     $iconstyle = 'style="width: 60px; height: 60px; vertical-align: middle" ';
     global $request;
     $module = 'admin';
     /**  BEGIN GEN MAIN TAB **/
     $text = "<tr>";
     $i = 0;
     foreach ($config as $controller => $nav) {
         if ($nav->nolink == 'true') {
             $link = "";
         } else {
             $link = "onclick=location.href='/{$module}/{$controller}'";
         }
         // echo $controller," ",(int)Sam_Acl::getInstance()->isAllowed($controller,'view'),"<br/>";
         if ($link == '' or Sam_Acl::getInstance()->isAllowed($controller, 'view') == true) {
             $text .= "<td {$link} ><img {$iconstyle} src='{$nav->icon}' /> <br/> ";
             $text .= "<span>{$nav->label}</span>";
             $text .= "</td>";
         }
         ++$i;
         if ($i != 0 and $i % 5 == 0) {
             $text .= "</tr><tr>";
         }
     }
     $text .= "</tr>";
     return $text;
 }
Пример #2
0
    function genMenu($config, $module = '')
    {
        $text = '';
        //print_r($config->$module);
        $iconstyle = 'style="width: 40px; height: 40px; vertical-align: middle" ';
        global $request;
        //$module = 'admin';
        /**  BEGIN GEN MAIN TAB **/
        $i = 0;
        foreach ($config->{$module}->sub as $controller => $nav) {
            //	echo $controller;
            //print_r($nav);
            $moduleurl = "/{$module}/{$controller}";
            if ($nav->url != '') {
                $moduleurl = $nav->url;
            }
            if ($nav->nolink == 'true') {
                $link = "";
            } else {
                $link = "onclick=location.href='{$moduleurl}'";
            }
            // echo $controller," ",(int)Sam_Acl::getInstance()->isAllowed($controller,'view'),"<br/>";
            $resource = strtolower("{$module}:{$controller}");
            // echo $resource;
            if ($link == '' or Sam_Acl::getInstance()->isAllowed($resource, 'view') == true) {
                //$text .= "<li $link style='cursor: pointer;' ><img $iconstyle src='{$nav->icon}' /> <br/> ";
                //$text .= "<h4>{$nav->label}</h4>";
                //$text .= "</li>";
                ob_start();
                ?>
                                <div class="col-sm-4" style='cursor: pointer;' <?php 
                echo $link;
                ?>
 >
                                  <div class="panel panel-default">
                             
                                    <div class="panel-body">
                                      <img $iconstyle src='<?php 
                echo $nav->icon;
                ?>
' /> <?php 
                echo $nav->label;
                ?>
                                    </div>
                                  </div>
                                </div>
                        <?php 
                $text .= ob_get_contents();
                ob_end_clean();
            }
            ++$i;
        }
        return $text;
    }
Пример #3
0
 public function addSaveButton()
 {
     //$req = Zen
     $req = Zend_Controller_Front::getInstance()->getRequest();
     $controller = $req->getControllerName();
     $module = $req->getModuleName();
     $resource = strtolower("{$module}:{$controller}");
     $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, 'edit');
     if ($isAllowed) {
         $save = $this->addElement('submit', 'save', array('label' => 'Save', 'class' => "button-submit"));
         return $save;
     }
 }
Пример #4
0
 function isHaveAllowSubMenu($config, $class, $module)
 {
     $isHaveAllowSubMenu = false;
     foreach ($config as $controller => $nav) {
         $resource = strtolower("{$module}:{$controller}");
         $isAllow = Sam_Acl::getInstance()->isAllowed($resource, 'view');
         $resource = strtolower("{$module}:{$controller}");
         if ($isAllow == true) {
             $isHaveAllowSubMenu = true;
             return true;
         }
     }
     return $isHaveAllowSubMenu;
 }
Пример #5
0
 function genMenu($config, $module = '')
 {
     //echo $module;
     //print_r($config->$module);
     $iconstyle = 'style="width: 40px; height: 40px; vertical-align: middle" ';
     //global $request;
     //$module = 'admin';
     /**  BEGIN GEN MAIN TAB **/
     $i = 0;
     foreach ($config->{$module}->sub as $controller => $nav) {
         //	echo $controller;
         //print_r($nav);
         if (count($nav->sub) == 0) {
             if ($nav->nolink == 'true') {
                 $link = "";
             } else {
                 $link = "onclick=location.href='/{$module}/{$controller}'";
             }
             // echo $controller," ",(int)Sam_Acl::getInstance()->isAllowed($controller,'view'),"<br/>";
             $resource = strtolower("{$module}:{$controller}");
             // echo $resource;
             if ($link == '' or Sam_Acl::getInstance()->isAllowed($resource, 'view') == true) {
                 $text .= "<li {$link} style='cursor: pointer;' ><img {$iconstyle} src='{$nav->icon}' /> <br/> ";
                 $text .= "<h4>{$nav->label}</h4>";
                 $text .= "</li>";
             }
         } else {
             //print_r($nav);
             $text .= "<table class='statistics'  width='100%' border='0' cellspacing='0' cellpadding='0' class='welcome-menu'><tr></td>";
             $text .= "<tr><th><img src='{$nav->icon}' /> {$this->view->translate($nav->label)} </th></tr>";
             $text .= "<tr><td>";
             $text .= "<ul class='welcome-menu' >";
             $text .= $this->genSubMenu($nav, $module);
             $text .= "</ul>";
             $text .= "</td></tr>";
             $text .= "</table>";
         }
         ++$i;
     }
     return $text;
 }
Пример #6
0
 function genMenu($config, $module, $controllerName)
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     //echo $module;
     //print_r($config->$module);
     $this->view->headLink()->appendStylesheet('/css/menu/style1.css');
     $iconstyle = 'style="width: 16px; height: 16px; vertical-align: middle" ';
     //global $request;
     //$module = 'admin';
     /**  BEGIN GEN MAIN TAB **/
     $i = 0;
     $text = '';
     foreach ($config->{$module}->sub->{$controllerName}->sub as $controller => $nav) {
         //	echo $controller;
         //print_r($nav);
         if ($nav->nolink == 'true') {
             $link = "";
         } else {
             $link = "/{$module}/{$controller}";
         }
         $currentController = $request->getControllerName();
         if ($currentController == $controller) {
             $liId = "current";
         } else {
             $liId = $controller;
         }
         // echo $controller," ",(int)Sam_Acl::getInstance()->isAllowed($controller,'view'),"<br/>";
         $resource = strtolower("{$module}:{$controller}");
         // echo $resource;
         if ($link == '' or Sam_Acl::getInstance()->isAllowed($resource, 'view') == true) {
             $text .= "<li id='{$liId}'    ><a  href='{$link}'>  ";
             $text .= "{$nav->label}";
             $text .= "</a></li>";
         }
         ++$i;
     }
     return $text;
 }
Пример #7
0
    function genMenu($config, $module = '')
    {
        $text = '';
        //print_r($config->$module);
        $iconstyle = 'style="width: 40px; height: 40px; vertical-align: middle" ';
        global $request;
        //$module = 'admin';
        /**  BEGIN GEN MAIN TAB **/
        $i = 0;
        foreach ($config->{$module}->sub as $controller => $nav) {
            //	echo $controller;
            //print_r($nav);
            if ($nav->nolink == 'true') {
                $link = "";
            } else {
                $link = "onclick=location.href='/{$module}/{$controller}'";
            }
            // echo $controller," ",(int)Sam_Acl::getInstance()->isAllowed($controller,'view'),"<br/>";
            $resource = strtolower("{$module}:{$controller}");
            // echo $resource;
            if ($link == '' or Sam_Acl::getInstance()->isAllowed($resource, 'view') == true) {
                //$text .= "<li $link style='cursor: pointer;' ><img $iconstyle src='{$nav->icon}' /> <br/> ";
                //$text .= "<h4>{$nav->label}</h4>";
                //$text .= "</li>";
                $text .= <<<HTML
\t\t\t\t\t<div class="report" {$link} style="cursor: pointer;" >
                        <p class="report-title"><img  src="{$nav->icon}" /> {$nav->label}</p>
                        <p class="report-figures">10</p>
                        <div class="clear"></div>
                        <div class="headway"><div class="advance" style="width:100%;"></div></div>
                    </div>
HTML;
            }
            ++$i;
        }
        return $text;
    }
Пример #8
0
 function authenLog($token = '', $user = null, $isMaster = false, $result = 'SUCCESS', $message = '')
 {
     return false;
     if ($token == '') {
         $token = uniqid();
     }
     $log = new Sam_Model_AuthenticationLog();
     $log->setToken($token)->setLoginDatetime(new DateTime())->setIsMaster($isMaster)->setUserAcountName($user)->setIp($_SERVER['REMOTE_ADDR'])->setAgent($_SERVER['HTTP_USER_AGENT'])->setSessionid(session_id())->setResult($result)->setErrorMessage($message);
     if ($user instanceof Sam_Model_User) {
         $log->setUserId($user->getId())->setGroupId($user->getGroupid())->setUserAcountName($user->getLoginid())->setUserFullname($user->getFullname())->setUserId($user->getId())->setpermissionData(json_encode(Sam_Acl::getInstance()->getPermissions()));
     }
     $log->save();
 }
Пример #9
0
 public function isAllowed($resource, $action)
 {
     //$module = $this->getRequest ()->getModuleName ();
     return Sam_Acl::getInstance()->isAllowed($resource, $action);
 }
Пример #10
0
 function isAllowAccess($module = "", $controller = "", $action = "view")
 {
     //$isAllow = false;
     if (trim($controller) != "") {
         $resource = strtolower("{$module}:{$controller}");
     } else {
         $resource = strtolower("{$module}");
     }
     $isAllow = Sam_Acl::getInstance()->isAllowed($resource, $action);
     return $isAllow;
 }
Пример #11
0
 function genMainMenu($config, $id, $class, $module = '', $control = '')
 {
     $iconstyle = 'style="width: 16px; height: 16px; vertical-align: middle" ';
     //echo "A: class=",$class,' modul=',$module,' controll=',$control='',"<br/>";
     $request = $this->request;
     $controllerName = $this->controllerName;
     $controllerSelected = $this->controllerSelected;
     /**  BEGIN GEN MAIN TAB **/
     $text = "<div><ul id='{$id}' class='{$class}'>";
     foreach ($config as $nodeName => $nav) {
         if (trim($nav->ismodule) == 'true') {
             $module = $nodeName;
             if (trim($nav->module) != '') {
                 $module = $nav->module;
             }
         }
         if (!$this->isAllowAccess($module)) {
             continue;
         }
         if ($module == '') {
             $module = DEFAULT_MODULE;
         }
         if ($class == 'sub') {
             $controller = $nodeName;
         } else {
             $controller = '';
         }
         $ops = '';
         if ($controller == $controllerName) {
             $controllerSelected = $controller;
             $ops = "";
         } else {
             $ops = "";
         }
         if ($nav->nolink == 'true') {
             $link = "#";
         } else {
             $linkclass = "class='parent' ";
             if (trim($nav->ismodule) == 'true') {
                 $link = "/{$module}";
                 $ops = "class=''";
                 $linkclass = " ";
                 if ($module == $request->getModuleName()) {
                     $ops = "class='selected'";
                 }
             } elseif (trim($nav->control) != '') {
                 $link = "/{$module}/{$nav->control}/{$controller}";
             } else {
                 $link = "/{$module}/{$controller}";
             }
         }
         $resource = strtolower("{$module}:{$controller}");
         // $this->addResource ($controller, $module, $nav->description);
         if ($nav->visible == 'false') {
             continue;
         }
         if ($nav->sub) {
             if ($this->isHaveAllowSubMenu($nav->sub, 'sub', $module)) {
                 if ($nav->ismodule == 'true' or Sam_Acl::getInstance()->isAllowed($resource, 'view') == true) {
                     $text .= "<li  {$ops} ><a href='{$link}' {$linkclass} ><span><img {$iconstyle} src='{$nav->icon}' />  ";
                     $text .= "{$nav->label}</span></a>";
                     // $text .= genMainMenu($nav->sub, '', 'sub', $module, $controller);
                     $text .= "</li>";
                 }
             }
         } else {
             if ($nav->ismodule == 'true' or Sam_Acl::getInstance()->isAllowed($resource, 'view') == true) {
                 $text .= "<li  {$ops}><a href='{$link}' {$linkclass} ><span><img {$iconstyle} src='{$nav->icon}' />  ";
                 $text .= "{$nav->label}</span></a>";
                 $text .= "</li>";
             }
         }
     }
     $text .= "</ul></div>";
     return $text;
 }
Пример #12
0
 public function indexAction()
 {
     $this->view->gridParam = $this->_userparam;
     $this->view->gridRenderer = $this->_gridRenderer;
     //print_r($this->_modelProperties);
     $req = $this->getRequest();
     $model = $this->getObject($this->_model);
     $filter = new App_Grid_Filter($model);
     $filter->setUiName($this->_uiConfig);
     if ($this->_gridSQL != '') {
         $filter->setSQL($this->_gridSQL);
     }
     $printMode = false;
     $this->view->printmode = false;
     if ($this->_request->getParam("print", '') != '') {
         $this->setPrintLayout();
         $filter->disableAction();
         $printMode = true;
         $this->view->printmode = true;
     }
     if ($this->_pdfClass != '' and class_exists($this->_pdfClass)) {
         $module = $this->_request->getModuleName();
         $controller = $this->_request->getControllerName();
         $this->addGridAction(array('action' => 'print', 'class' => 'btn-print-pdf', 'iconUrl' => '/images/icon/printer.png', 'tooltip' => 'พิมพ์รายละเอียด', 'onClickFunction' => "function(rowid,row,grid){\n                  \t\trow = \$(this).parent().parent();\n                  \t\tid = row.attr('id');\n                  \t\tvar link= '/{$module}/{$controller}/print/id/'+id;\n                  \t\topenPrintWindows(link,'print-pdf',450,600);\n            }"));
     }
     //summayrow
     //   print_r($this->_gridCellAligns);
     // $filter->addForm($this->_setForm($form));
     $filter->setCellAligns($this->_gridCellAligns);
     // print_r($this->_summayFields);
     $filter->setSummayFields($this->_summayFields);
     //echo "269",$this->_gridSeparater;
     $filter->setSeparater($this->_gridSeparater);
     $filter->setGridWidth($this->_gridWidth);
     if ($this->_gridActionDisabled == true) {
         $filter->disableAction();
     }
     $controller = $req->getControllerName();
     $module = $req->getModuleName();
     $resource = strtolower("{$module}:{$controller}");
     $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, 'delete');
     //echo ($isAllowed == true)? 'Y':'N';
     //echo ($this->_disableDeleteButton == true)? 'DY':'DN';
     if (!$this->_disableDeleteButton and $isAllowed) {
         $this->addGridAction(array('action' => 'delete', 'iconUrl' => '/images/grid/publish_x.png', 'class' => 'IMGDELETE'));
     }
     if ($this->_gridActions) {
         $filter->setGridActions($this->_gridActions);
     }
     $filter->setView($this->view);
     if (count($this->_helperFunctions) > 0) {
         foreach ($this->_helperFunctions as $propKey => $helperName) {
             $filter->addHelperFunction($propKey, $helperName);
         }
     }
     if ($this->_section != '') {
         $filter->addCondition('secid', $this->_section);
     }
     if ($this->_catigory != '') {
         $filter->addCondition('catid', $this->_catigory);
     }
     if ($this->_request->getParam('filter', '') != 'reset') {
         if (count($this->_conditions) > 0) {
             foreach ($this->_conditions as $condition) {
                 $field = trim($condition[0]);
                 $field = $this->_modelProperties[$field];
                 $filter->addCondition($field, trim($condition[1]), trim($condition[2]));
             }
         }
     }
     if ($this->_gridHeaders != null) {
         $filter->setHeaderTitles($this->_gridHeaders);
     }
     $filter->setFields($this->_gridFields);
     $filter->setRowsWidth($this->_gridFieldWidth);
     $filter->setRequest($req);
     //echo $this->_sort;
     //if ($this->_sort != '') {
     //echo $this->_sort,$this->_direction ;
     $filter->setSortBy((int) $this->_sort);
     $filter->setDirection($this->_direction);
     //}
     $filter->setRecordsPerPage($this->_recordsPerPage);
     #view config
     //$controlname =$this->_translate($this->_request->getControllerName ());
     //$modulename = $this->_translate(  $this->_request->getModuleName()  );
     if ($this->_titleOfIndex != '') {
         $this->view->layout()->btitle = $this->_titleOfIndex;
     }
     if ($this->_subTitleOfIndex != '') {
         $this->view->layout()->subtitle = $this->_subTitleOfIndex;
     }
     $this->view->filter = $filter;
     if (!$printMode) {
         if ($this->_htmlTabs != null and ($this->_showTabsOnView == null or $this->_showTabsOnView == 'index')) {
             $this->view->htmlTabs = $this->_htmlTabs;
         }
         $buttons = $this->getButtons('index');
         if ($this->_disableNewButton != true) {
             //button($action,$controller='',$label='', $id = '', $disabled = false, $title = '',$additionalClass='',$userParams=null,array $windowOptions = null)
             $url = $_SERVER['REQUEST_URI'];
             $uri_ep = explode("/", $_SERVER['REQUEST_URI']);
             $last = count($uri_ep) - 1;
             $uri_ep[$last] = 'new';
             $url = join("/", $uri_ep);
             $buttons[] = $this->view->zbutton(array('action' => 'new-group-form', 'id' => 'AddButton', 'label' => 'Add', 'class' => 'new-button', 'params' => array('id' => $this->companyid), 'url' => $url, 'windowOptions' => array('width' => '500', 'height' => '500')));
             //$buttons[]=$this->view->zbutton(array('action'=>'new','id'=>'NewButton',label=>'New','class'=>'new-button',
             //
             //
             //'onClickFunction'=>" onclick={location.href='$url'} "));
         }
         $buttons2[] = $this->view->zbutton(array('action' => 'reload', 'label' => '', 'tooltip' => 'reload', 'params' => $this->_userparam, 'class' => 'refresh-zbutton'));
         $this->view->buttons = $buttons;
     }
     $this->view->layout()->actionbar = $this->view->actionbar3(null, $buttons2);
     $this->view->gridSelectedAction = $this->_gridSelectedAction;
     if ($this->_customsIndexView != '') {
         $this->render($this->_customsIndexView, null, false);
     } elseif ($this->_noIndexView == true) {
         $this->render('index', null, true);
     }
 }
Пример #13
0
 /**
  * @return Sam_Acl
  */
 public function getAcl()
 {
     return Sam_Acl::getInstance();
 }
Пример #14
0
    /**
     * @param string $label
     * @param string $onclick
     * @param string $additionalClass
     * @param string $id
     * @param bool $disabled
     * @param string $title
     * @return string
     */
    public function Zbutton($action, $controller = '', $label = '', $id = '', $disabled = false, $title = '', $additionalClass = '', $userParams = null, array $windowOptions = null)
    {
        $module = '';
        if (is_array($action)) {
            $iconclass = isset($action['icon']) ? $action['icon'] : 'ui-icon-bullet';
            $controller = isset($action['controller']) ? $action['controller'] : null;
            $module = isset($action['module']) ? $action['module'] : null;
            $width = isset($action['width']) ? $action['width'] : null;
            $title = isset($action['tooltip']) ? $action['tooltip'] : null;
            $onClickFunction = isset($action['onClickFunction']) ? $action['onClickFunction'] : null;
            $label = isset($action['label']) ? $action['label'] : null;
            $id = isset($action['id']) ? $action['id'] : null;
            $disabled = isset($action['disabled']) ? $action['disabled'] : null;
            $additionalClass = isset($action['class']) ? $action['class'] : null;
            $userParams = isset($action['params']) ? $action['params'] : null;
            $windowOptions = isset($action['windowOptions']) ? $action['windowOptions'] : null;
            $url = isset($action['url']) ? $action['url'] : null;
            $class = isset($action['class']) ? $action['class'] : "{$action}-button";
            $action = isset($action['action']) ? $action['action'] : null;
            //if($label=='')$label=$title;
            //echo $iconclass;
            //return $iconclass;
        }
        //if(strtolower($label) == 'new')$label = ucfirst($action);
        $req = Zend_Controller_Front::getInstance()->getRequest();
        if (trim($controller) == '') {
            $controller = $req->getControllerName();
        }
        if ($module == '') {
            $module = $req->getModuleName();
        }
        //$class = "$action-button";
        $disabledClass = $disabled ? ' button-disabled ' : '';
        $onclick = '';
        if ($label == '') {
            $label = ucfirst($action);
        }
        //if($action =='reload')$label = 'reload';
        if ($title == '') {
            $title = "Click to " . ucfirst($action) . " {$controller}.";
        }
        if ($id == '') {
            $id = 'btn_' . $action;
        }
        //echo $action;
        $resource = strtolower("{$module}:{$controller}");
        $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, $action);
        $resourceName = "{$resource}#{$action}";
        if ($id == "SaveButton") {
            if (in_array(App_Env::getActionName(), array('new', 'new-dialog'))) {
                $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, "new");
            } else {
                $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, "edit");
            }
        } else {
        }
        //	echo (int)$isAllowed,"<br/>";
        $is_refresh = false;
        if ($action == 'reload') {
            $action = null;
            $is_refresh = true;
        }
        if ($isAllowed and $disabled == false) {
            if ($url != '') {
                $link = $url;
                $onclick = " onclick=\"location.href='{$link}'\" ";
            } else {
                if ($onClickFunction != '') {
                    $onclick = $onClickFunction;
                } else {
                    if ($windowOptions != null) {
                        //if(!isset($userParams["print"])){
                        //	$userParams["print"]='html';
                        //}
                        $userParams["mode"] = 'window';
                        if ($url == '') {
                            $link = $this->view->url($action, $controller, $module, $userParams);
                        } else {
                            $link = $url;
                        }
                        $wwidth = isset($windowOptions['width']) ? $windowOptions['width'] : '';
                        $wheight = isset($windowOptions['height']) ? $windowOptions['height'] : '';
                        if ($windowOptions['type'] == 'print') {
                            $id = 'PrintButton';
                            $onclick = "onclick=\"window.print();\"";
                        } else {
                            $onclick = "onclick=\"openWindows('{$link}','{$id}','{$wwidth}','{$wheight}')\"";
                        }
                    } elseif ($id == 'PrintButton') {
                        $userParams["mode"] = 'window';
                        $userParams["print"] = 'html';
                        if ($url == '') {
                            $link = $this->view->url($action, $controller, $module, $userParams);
                        } else {
                            $link = $url;
                        }
                        $onclick = "onclick=\"window.print();\"";
                    } else {
                        if ($is_refresh) {
                            //$link = $this->view->url('SSSSS',$controller,null,$userParams,true);
                            $x = uniqid();
                            $onclick = "onclick=\"location.href='?x={$x}&filter=reset'\"";
                        } elseif ($action != '') {
                            $link = $this->view->url($action, $controller, null, $userParams, true);
                            $onclick = "onclick=\"location.href='{$link}'\"";
                        } else {
                            $onclick = '';
                        }
                    }
                }
            }
        } else {
            $disabled = true;
        }
        if ($disabled == true) {
            $disabledClass = ' button-disabled ';
            $disabled = 'disabled="disabled"';
        }
        if ($action == 'index' or $action == 'back') {
            //$iconclass = "glyphicon glyphicon-refresh";
        }
        if ($action == 'close' or $action == 'back') {
            //$iconclass = "glyphicon glyphicon-refresh";
        }
        if ($is_refresh) {
            $iconclass = "glyphicon glyphicon-refresh";
        } elseif ($id == "SaveButton" or $id == "DownloadButton" or $id == "SaveTransaction") {
            $iconclass = "glyphicon glyphicon-floppy-disk";
        } elseif ($id == "ResetButton" or $class == 'reset' or $Id == "ReStart" or $id == 'forn-search-button-refresh') {
            $iconclass = "glyphicon glyphicon-refresh";
        } elseif ($id == "CancelButton") {
            $iconclass = "glyphicon glyphicon-remove";
        } elseif ($id == "EditButton" or $id == "edit") {
            $iconclass = "glyphicon glyphicon-pencil";
        } elseif ($id == "CloseButton") {
            $iconclass = "glyphicon glyphicon-remove-circle";
        } elseif ($id == "ExportButton") {
            $iconclass = "glyphicon glyphicon-download";
        } elseif ($id == "PrintButton") {
            $iconclass = "glyphicon glyphicon-print";
            $label = 'Print';
        } elseif ($class == 'apply' or $id == 'forn-search-button-submit') {
            $iconclass = "glyphicon glyphicon-search";
            $title = 'search';
            $label = 'search';
        } elseif ($id == 'CloseToIIndexButton' or $id == 'CloseToIndexButton') {
            $iconclass = "glyphicon glyphicon-chevron-left";
            $link = App_View_Helper_Table::getToIndexLink($this->view, null, null, null, array('action' => $action));
            $onclick = "onclick=\"location.href='{$link}'\"";
        } elseif ($id == "DeleteButton") {
            $iconclass = "glyphicon glyphicon-trash";
        } elseif ($id == "NewButton") {
            $iconclass = "glyphicon glyphicon-plus";
        }
        if (trim($iconclass) == '') {
            $iconclass = "glyphicon glyphicon-plus";
        }
        if ($width == '') {
            $width = '300';
        }
        $style = " style='width: {$width} ;' ";
        /*		
        		$output =<<<button
        		<input type='button' value='{$label}'  id='{$id}' name='$id' $onclick $disabled $width title='{$this->view->escape($title)}' class='btn {$class} {$disabledClass} {$additionalClass}' />
        				    
        button;
        					$output2 =<<<buttonImg
        		<img type="button" value="{$label}" 
        		 			id='{$id}'
        		 			name='$id'
        					$onclick
        					$disabled
        					title='{$this->view->escape($title)}'
        					class=' {$class} {$disabledClass} {$additionalClass}' />
        				    
        buttonImg;
        */
        $output3 = <<<buttonImg
\t\t<a resource='{$resourceName}'  id='{$id}' name='{$id}' {$onclick} {$disabled} {$style} title='{$this->view->escape($title)}' class='btn btn-default btn-xs ' >
\t\t<i class="{$iconclass}"></i> {$label}
\t\t</a>
\t\t\t\t    
buttonImg;
        return $output3;
    }
Пример #15
0
 protected function _addSaveButton($disableAcc = false)
 {
     if ($disableAcc == false) {
         $req = Zend_Controller_Front::getInstance()->getRequest();
         $controller = $req->getControllerName();
         $module = $req->getModuleName();
         $resource = strtolower("{$module}:{$controller}");
         if ($this->_ignoreAuthorize == false) {
             // echo "sssss";
             // exit();
             $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, 'edit');
         } else {
             $isAllowed = true;
         }
         if ($isAllowed) {
             $save = $this->addElement('submit', 'save', array('decorators' => $this->buttonDecorators, 'label' => 'Save', 'class' => "button-submit"));
         } else {
             $save = null;
         }
     } else {
         $save = $this->addElement('submit', 'save', array('decorators' => $this->buttonDecorators, 'label' => 'Save', 'class' => "button-submit"));
     }
     return $save;
 }
Пример #16
0
    /**
     * @param string $label
     * @param string $onclick
     * @param string $additionalClass
     * @param string $id
     * @param bool $disabled
     * @param string $title
     * @return string
     */
    public function button($action, $controller = '', $label = '', $id = '', $disabled = false, $title = '', $additionalClass = '', $userParams = null, array $windowOptions = null)
    {
        $module = '';
        if (is_array($action)) {
            $controller = $action['controller'];
            $module = $action['module'];
            $title = $action['tooltip'];
            $onClickFunction = $action['onClickFunction'];
            $label = $action['label'];
            $id = $action['id'];
            $disabled = $action['disabled'];
            $additionalClass = $action['class'];
            $userParams = $action['params'];
            $windowOptions = $action['windowOptions'];
            $action = $action['action'];
            if ($label == '') {
                $label = $title;
            }
        }
        $req = Zend_Controller_Front::getInstance()->getRequest();
        if (trim($controller) == '') {
            $controller = $req->getControllerName();
        }
        if ($module == '') {
            $module = $req->getModuleName();
        }
        $class = "{$action}-button";
        $disabledClass = $disabled ? ' button-disabled ' : '';
        $onclick = '';
        if ($label == '') {
            $label = ucfirst($action);
        }
        if ($title == '') {
            $title = "Click to " . ucfirst($action) . " {$controller}.";
        }
        if ($id == '') {
            $id = 'btn_' . $action;
        }
        //echo $action;
        $resource = strtolower("{$module}:{$controller}");
        $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, $action);
        //	echo (int)$isAllowed,"<br/>";
        if ($isAllowed and $disabled == false) {
            if ($windowOptions != null) {
                if (!isset($userParams["print"])) {
                    $userParams["print"] = 'html';
                }
                $link = $this->view->url($action, $controller, $module, $userParams, true);
                $width = $windowOptions['width'];
                $height = $windowOptions['height'];
                if ($windowOptions['type'] == 'print') {
                    $onclick = "onclick=\"openPrintWindows('{$link}','{$id}','{$width}','{$height}')\"";
                } else {
                    $onclick = "onclick=\"openWindows('{$link}','{$id}','{$width}','{$height}')\"";
                }
            } else {
                $link = $this->view->url($action, $controller, null, $userParams, true);
                $onclick = "onclick=\"location.href='{$link}'\"";
            }
        } else {
            $disabled = true;
        }
        if ($disabled == true) {
            $disabledClass = ' button-disabled ';
            $disabled = 'disabled="disabled"';
        }
        $output = <<<button
\t\t<input type="button" value="{$label}" 
\t\t \t\t\tid='{$id}'
\t\t \t\t\tname='{$id}'
\t\t\t\t\t{$onclick}
\t\t\t\t\t{$disabled}
\t\t\t\t\ttitle='{$this->view->escape($title)}'
\t\t\t\t\tclass='btn btn-default {$class} {$disabledClass} {$additionalClass}'
\t\t\t\t    />
button;
        return $output;
    }
Пример #17
0
 public function Table(App_Grid_Filter $filter, array $list = null)
 {
     $this->_gridid = $this->getGridId();
     $this->_formid = $this->getFormId();
     $req = Zend_Controller_Front::getInstance()->getRequest();
     $this->_request = $req;
     if ($filter->isPrepared() != true) {
         $filter->setup();
     }
     $module = $req->getModuleName();
     $controller = $req->getControllerName();
     $resource = strtolower("{$module}:{$controller}");
     $isAllowedEdit = Sam_Acl::getInstance()->isAllowed($resource, "edit");
     $isAllowedNew = Sam_Acl::getInstance()->isAllowed($resource, "new");
     $isAllowedDelete = Sam_Acl::getInstance()->isAllowed($resource, "delete");
     if ($filter->isPrepared() == true) {
         $filter->setRequest($req);
         if (isset($filter->getGridConfig()->pagination) and trim($filter->getGridConfig()->pagination) == 'false') {
             //echo 'enabledPagination ';
             $this->_enabledPagination = false;
         }
         if (isset($filter->getGridConfig()->newrowMethod) and trim($filter->getGridConfig()->newrowMethod) == 'blankrow') {
             $this->_enabledAddNewRowAction = true;
         } elseif ($filter->getGridConfig()->newrowMethod == 'dialog' or $filter->getGridConfig()->newrowMethod == 'OpenNewDialog') {
             $this->_enabledOpenNewDialogAction = true;
         }
         $this->_tableType = $filter->getGridConfig()->type;
         // แก้ใน global 1 ด้วย
         if (trim($filter->getGridConfig()->type) == self::TABLE_TYPE_EDITINLINE) {
             $this->_enabledInlineEdit = true;
             $this->_enabledRowOnClicAction = false;
             $this->_tableType = self::TABLE_TYPE_EDITINLINE;
             if (!$isAllowedEdit) {
                 $this->_tableType = self::TABLE_TYPE_DEFAULT;
                 $this->_enabledInlineEdit = false;
             }
         }
         if (isset($filter->getGridConfig()->scrollbar) and in_array($filter->getGridConfig()->scrollbar, array('false', 'disabled'))) {
             $this->_enabledScollbar = false;
         }
         if ($filter->getGridConfig()->onRowClickAction == 'false' or $filter->getGridConfig()->onRowClickAction == 'disabled') {
             $this->_enabledRowOnClicAction = false;
         }
         if (true == $filter->isDeleteButtonDisabled() or false == $isAllowedDelete) {
             $this->_enabledDeleteAction = false;
         }
         if (true == $filter->isEditButtonDisabled()) {
             $this->_enabledEditIconOnClicAction = false;
         } else {
             $this->_enabledEditIconOnClicAction = true;
             $this->_openEditFormIn = trim($filter->getGridConfig()->editMethod) != '' ? $filter->getGridConfig()->editMethod : $this->_openEditFormIn;
         }
         // if(true ==$this->_enabledInlineEdit ){
         // 	$this->_enabledEditIconOnClicAction =false;
         // }
     }
     if ($isAllowedNew) {
         if ($this->_enabledAddNewRowAction) {
             $this->addButonOnActionBar('addBlankRecord', array('class' => 'ui-icon-circle-plus', 'text' => 'New', 'width' => '100px'));
         }
         if ($this->_enabledOpenNewDialogAction) {
             $this->addButonOnActionBar('btnOpenNewDialog', array('class' => 'ui-icon-circle-plus', 'text' => 'New', 'width' => '100px'));
         }
     }
     if ($this->_enabledInlineEdit) {
         $this->addButonOnActionBar('btnSaveGrid', array('class' => 'ui-icon-disk', 'text' => 'Save', 'width' => '100px'));
     }
     $ui = $filter->getUiName();
     $this->_modelName = $filter->getModelName();
     if ($this->_tableType == self::TABLE_TYPE_TREETABLE) {
         $this->_tablebodyClass = " ";
     }
     // Add Action Button
     // เพิ่มปุ่ม   edit กดแล้วไปหน้า edit เลย
     if ($this->_enabledEditIconOnClicAction == true and $isAllowedEdit == true) {
         $filter->addAction(array('action' => 'edit', 'iconUrl' => '/images/grid/edit.png', 'class' => 'IMG_ROW_EDIT'));
         //$filter->setGridActions($actions);
         $this->_enabledEditIconOnClicAction = true;
     }
     //เพิ่มปุ่ม delete
     if (true == $this->_enabledDeleteAction and true == $isAllowedDelete) {
         $filter->addAction(array('action' => 'delete', 'iconUrl' => '/images/grid/publish_x.png', 'class' => 'IMGDELETE'));
     }
     $tableConfig = $this->getTableConfig($this->_modelName, $ui);
     $this->_columnConfig = $tableConfig;
     $this->_modelConfig = $this->getModelConfig($this->_modelName);
     if ($list == null) {
         if ($this->_tableType == self::TABLE_TYPE_TREETABLE) {
             $list = $filter->getTreeList();
         } else {
             $list = $filter->getList();
         }
     }
     $this->_filter = $filter;
     if ($this->filter()->isActionDisabled()) {
         $this->_printMode = true;
         $x = $this->renderSimpleTable($filter, $list);
     } else {
         $x = $this->redertable($filter, $list);
     }
     return $x;
 }
Пример #18
0
 function liteGridAction()
 {
     $this->disableLayout();
     $this->view->gridParam = $this->_userparam;
     $this->view->gridRenderer = $this->_gridRenderer;
     //print_r($this->_modelProperties);
     $req = $this->getRequest();
     $model = $this->getObject($this->_model);
     $filter = new App_Grid_Filter($model);
     $filter->setUiName($this->_uiConfig);
     if ($this->_gridSQL != '') {
         $filter->setSQL($this->_gridSQL);
     }
     $printMode = false;
     $this->view->printmode = false;
     if ($this->_request->getParam("print", '') != '') {
         $this->setPrintLayout();
         $filter->disableAction();
         $printMode = true;
         $this->view->printmode = true;
     }
     if ($this->_pdfClass != '' and class_exists($this->_pdfClass)) {
         $module = $this->_request->getModuleName();
         $controller = $this->_request->getControllerName();
         $this->addGridAction(array('action' => 'print', 'class' => 'btn-print-pdf', 'iconUrl' => '/images/icon/printer.png', 'tooltip' => 'พิมพ์รายละเอียด', 'onClickFunction' => "function(rowid,row,grid){\n                  \t\trow = \$(this).parent().parent();\n                  \t\tid = row.attr('id');\n                  \t\tvar link= '/{$module}/{$controller}/print/id/'+id;\n                  \t\topenPrintWindows(link,'print-pdf',450,600);\n            }"));
     }
     //summayrow
     //   print_r($this->_gridCellAligns);
     // $filter->addForm($this->_setForm($form));
     $filter->setCellAligns($this->_gridCellAligns);
     // print_r($this->_summayFields);
     $filter->setSummayFields($this->_summayFields);
     //echo "269",$this->_gridSeparater;
     $filter->setSeparater($this->_gridSeparater);
     $filter->setGridWidth($this->_gridWidth);
     if ($this->_gridActionDisabled == true) {
         $filter->disableAction();
     }
     $controller = $req->getControllerName();
     $module = $req->getModuleName();
     $resource = strtolower("{$module}:{$controller}");
     $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, 'delete');
     //echo ($isAllowed == true)? 'Y':'N';
     //echo ($this->_disableDeleteButton == true)? 'DY':'DN';
     if (!$this->_disableDeleteButton and $isAllowed) {
         $this->addGridAction(array('action' => 'delete', 'iconUrl' => '/images/grid/publish_x.png', 'class' => 'IMGDELETE'));
     }
     if ($this->_gridActions) {
         $filter->setGridActions($this->_gridActions);
     }
     $filter->setView($this->view);
     if (count($this->_helperFunctions) > 0) {
         foreach ($this->_helperFunctions as $propKey => $helperName) {
             $filter->addHelperFunction($propKey, $helperName);
         }
     }
     if (count($this->_conditions) > 0) {
         foreach ($this->_conditions as $condition) {
             $field = trim($condition[0]);
             $field = $this->_modelProperties[$field];
             $filter->addCondition($field, trim($condition[1]), trim($condition[2]));
         }
     }
     if ($this->_gridHeaders != null) {
         $filter->setHeaderTitles($this->_gridHeaders);
     }
     $filter->setFields($this->_gridFields);
     $filter->setRowsWidth($this->_gridFieldWidth);
     $filter->setRequest($req);
     $filter->setSortBy((int) $this->_sort);
     $filter->setDirection($this->_direction);
     $filter->setRecordsPerPage($this->_recordsPerPage);
     $this->view->filter = $filter;
     $this->view->gridSelectedAction = $this->_gridSelectedAction;
     $this->render('ajaxgrid', null, true);
 }