protected function _getCell($default = '', $defaultAlign = 'left', $filedId = '') { $columnConfig = $this->_columnConfig; if ($filedId != '') { $textOnCell = $this->_getCellText($filedId, $default); //if($align==''){ $align = in_array($columnConfig[$filedId]['align'], array('left', 'center', 'right')) ? $columnConfig[$filedId]['align'] : $defaultAlign; //} } else { $textOnCell = $default; } //echo $this->_modelConfig->getPropByName($filedId)->type; if ($this->_modelConfig->getPropByName($filedId)->type == 'boolean') { $align = 'center'; $textOnCell = $this->_getCellTick($textOnCell, $filedId); } else { if ($this->_modelConfig->getPropByName($filedId)->type == 'currency') { $align = 'right'; $textOnCell = App_Formatter::toMoney($textOnCell); } } //$type= $this->_modelConfig->getPropByName($filedId)->type; return "<td style='display:table-cell; vertical-align:middle;text-align:{$align}' align='{$align}' ><span >{$type}{$textOnCell}</span></td>"; }
protected function _getCell($default = '', $defaultAlign = 'left', $filedId = '', $id = '') { $req = Zend_Controller_Front::getInstance()->getRequest(); $editid = $req->getParam("editid", ''); $columnConfig = $this->_columnConfig; $text = ''; if ($filedId != '') { $text = $textOnCell = $this->_getCellText($filedId, $default); //echo $text; $align = in_array($columnConfig[$filedId]['align'], array('left', 'center', 'right')) ? $columnConfig[$filedId]['align'] : $defaultAlign; //} } else { $text = $textOnCell = $default; } //echo $this->_modelConfig->getPropByName($filedId)->type; if ($this->_modelConfig->getPropByName($filedId)->type == 'boolean') { $align = 'center'; if ($editid != '' and $editid == $id) { $textOnCell = $this->getFormElement($filedId, $editid, $text); } else { $textOnCell = $this->_getCellTick($textOnCell, $filedId); //$textOnCell=$this->_getCellText($filedId,$default); } } elseif ($this->_modelConfig->getPropByName($filedId)->type == 'currency') { $align = 'right'; if ($editid != '' and $editid == $id) { $textOnCell = $this->getFormElement($filedId, $editid, $text); } else { $textOnCell = App_Formatter::toMoney($text); } } else { if ($editid != '' and $editid == $id) { $textOnCell = $this->getFormElement($filedId, $editid, $text); } else { $textOnCell = $text; } //$textOnCell=$this->getFormElement($filedId); } //echo $textOnCell; //$type = ''; //$type= $this->_modelConfig->getPropByName($filedId)->type; //style='display:table-cell; vertical-align:middle;text-align:$align' align='$align' return "<td class='center' style='vertical-align:text-top' >" . $textOnCell . "</td>"; }
/** * Generates an url given the name of a route. * * @access public * * @param array $urlOptions Options passed to the assemble method of the Route object. * @param mixed $name The name of a Route to use. If null it will use the current Route * @param bool $reset Whether or not to reset the route defaults with those provided * @return string Url for the link href attribute. */ public function printmoney($money) { return App_Formatter::toMoney($money); }
protected function _getCell($default = '', $defaultAlign = 'left', $filedId = '', $row = null, $rowid = null, $width = '') { //return "<td>$default</td>" ; $columnConfig = $this->_columnConfig; if ($filedId != '') { $textOnCell = $this->_getCellText($filedId, $default); //if($align==''){ $align = in_array($columnConfig->fields[$filedId]->align, App_Model_Config::$alignList) ? $columnConfig->fields[$filedId]->align : $defaultAlign; //} } else { $textOnCell = $default; } //echo $this->_modelConfig->getPropByName($filedId)->type; $property = $this->_modelConfig->getPropByName($filedId); $type = $this->_modelConfig->getPropByName($filedId)->type; if ($property->type == 'boolean') { $type = 'boolean'; $align = 'center'; $textOnCell = $this->_getCellTick($textOnCell, $filedId); } elseif (isset($property->multiOptions->options)) { if ($this->filter()->isEnabledInlineEdit()) { $align = 'right'; $lov = $property->multiOptions->options; $textOnCell = $this->filter()->fieldTranform($row, $filedId); //$textOnCell = $this->view->inputLOV($filedId,$textOnCell,$lov,array('showPleaseSelect'=>false,'class'=>'change-inline-lov')) ; } } elseif (isset($property->multiOptions)) { //$align='right'; //$lov =$property->multiOptions->options; $textOnCell = $this->filter()->fieldTranform($row, $filedId); $textOnCell = $this->_displayCell($filedId, $property, $textOnCell, $row, $rowid); //$textOnCell = $this->view->inputLOV($filedId,$textOnCell,$lov,array('showPleaseSelect'=>false,'class'=>'change-inline-lov')) ; } elseif ($type == 'currency' or $type == 'decimal') { $align = 'left'; $textOnCell = App_Formatter::toMoney($textOnCell); } elseif ($this->_modelConfig->getPropByName($filedId)->input == 'filepicker') { $align = 'center'; $textOnCell = str_replace("docs/files", "docs/downloadfile", $textOnCell); $textOnCell = "<a href='{$textOnCell}'><img src='/images/icon/download-icon.png'></a>"; } else { $textOnCell = $this->_displayCell($filedId, $property, $textOnCell, $row, $rowid); } if ($this->_enabledInlineEdit) { $inputTypr = trim($this->filter()->getInputOfField($filedId)); $property = $this->_modelConfig->getPropByName($filedId); $minlength = $property->minlength; $maxlength = $property->maxlength; if ($minlength != '') { $minlength = "minlength='{$minlength}'"; } if ($maxlength != '') { $maxlength = "maxlength='{$maxlength}'"; } $min = $property->min; $max = $property->max; if ($min != '') { $min = " min='{$min}' "; } if (max != '') { $max = " max='{$max}' "; } if ($min != '' and $max != '') { //$min = $property->min; // $max = $property->max; //$range = "range='{ $min,$max }'"; //$max=$min=''; } //echo $property->input; // echo $property->class; if ($inputTypr != '') { $newfieldname = "{$filedId}_{$rowid}"; $val = $row->{$filedId}; // echo $inputTypr; switch ($inputTypr) { case 'text': $class = ''; if ($type == 'currency' or $type == 'decimal') { $val = App_Formatter::toMoney($val); $align = 'right'; //$class .= ' currency '; } if ($property->required) { $class .= ' required '; } $textOnCell = "<input {$range} {$max} {$min} {$minlength} {$maxlength} class=' {$class} ' name='{$newfieldname}' type='text' style='width:90%;height:20px;padding-right:2px;border: none;text-align:{$align}' value='{$val}' />"; break; case 'currency': case 'decimal': $val = App_Formatter::toMoney($val); $align = 'right'; if ($property->required) { $class .= ' required '; } $textOnCell = "<input {$range} {$max} {$min} {$minlength} {$maxlength} class='currency {$class} ' name='{$newfieldname}' type='text' style='width:90%;height:20px;padding-right:2px;border: none;text-align:{$align}' value='{$val}' />"; break; $textOnCell = "<textarea name='{$newfieldname}' type='text' style='width:96%;height:20px;padding-right:2px'>{$val}</textarea>"; break; case 'datepicker': $textOnCell = "<input class='datepicker' name='{$newfieldname}' type='text' style='width:80%;height:20px;padding-right:2px;border: none;' value='{$val}' readonly='readonly' />"; break; case 'radio': //ActiveOnceRadio $property = $this->_modelConfig->getPropByName($filedId); $checked = ""; if ((int) $val == 1) { $checked = ' checked="checked" '; } $textOnCell = "<input id='{$newfieldname}' class='selectOnceRow' name='isActive' type='radio' style='padding-right:2px;border: none;' value='1' {$checked} />"; break; case 'select': $property = $this->_modelConfig->getPropByName($filedId); if (isset($property->multiOptions->options)) { $align = 'right'; $lov = $property->multiOptions->options; $textOnCell = $this->view->inputLOV($newfieldname, $val, $lov, array('showPleaseSelect' => false, 'class' => 'change-inline-lov')); } elseif (isset($property->multiOptions)) { $model = $property->multiOptions->model; $pkField = $property->multiOptions->pk; $labelField = $property->multiOptions->label; $align = 'right'; $textOnCell = $this->view->formInputSelect($newfieldname, $val, $model, $pkField, $labelField); } break; case 'reference': $property = $this->_modelConfig->getPropByName($filedId); if (isset($property->multiOptions)) { $model = $property->multiOptions->model; $pkField = $property->multiOptions->pk; $labelField = $property->multiOptions->label; $align = 'right'; $textOnCell = $this->view->formInputSelect($newfieldname, $val, $model, $pkField, $labelField); } break; case 'autocomplete': $property = $this->_modelConfig->getPropByName($filedId); $textOnCell = $this->view->formAutocomplete($newfieldname, $val, array('resource' => '/dataresource/' . $property->autocompleteOptions->resourceName)); break; case 'autocompleteAccountCode': if ((int) $row->useAccountCode == 1) { $property = $this->_modelConfig->getPropByName($filedId); $textOnCell = $this->view->formAutocompleteAccountCode($newfieldname, $val, array('periodId' => $row->periodId)); } else { $textOnCell = "-"; } break; case 'autocompleteLabelAccountName': if ((int) $row->useAccountCode == 1) { $class = ''; $style .= " background: none;"; if ($type == 'currency' or $type == 'decimal') { $val = App_Formatter::toMoney($val); $align = 'right'; //$class .= ' currency '; } if ($property->required) { $class .= ' required '; } $textOnCell = "<input {$range} {$max} {$min} {$minlength} {$maxlength} class=' {$class} ' name='{$newfieldname}' type='text' style='width:90%;height:20px;padding-right:2px;border: none;text-align:{$align};{$style}' value='{$val}' />"; } else { $textOnCell = "-"; } break; case 'fsRatioFactorValue': if ($row->type == 'currency') { $val = App_Formatter::toMoney($val); $align = 'right'; $class .= ' currency '; } elseif ($row->type == 'integer') { $align = 'right'; $val = (int) $val; } else { $align = 'right'; if ($val == '') { $val = '0'; } } if ((int) $row->useAccountCode == 1) { $readonly = ' readonly="readonly" '; $style .= " background: none;"; } $textOnCell = "<input {$readonly} {$range} {$max} {$min} {$minlength} {$maxlength} class=' {$class} ' name='{$newfieldname}' type='text' style='width:90%;height:20px;padding-right:2px;border: none;text-align:{$align}; {$style}' value='{$val}' />"; break; } } } else { } if (trim($align) == '') { $align = trim($defaultAlign) != '' ? $defaultAlign : 'left'; } //$type= $this->_modelConfig->getPropByName($filedId)->type; if ($textOnCell == '') { $textOnCell = ' '; } return "<td style='display:table-cell; vertical-align:middle;text-align:{$align}; width:{$width}' align=\"{$align}\" field='{$filedId}' fieldtype='{$type}' value='{$default}'>{$textOnCell}</td>"; }
public function reder($rootfolder) { ob_start(); $this->view->script()->addPlugin(App_View_Helper_Script::JQUERY_ALERT); $this->view->script()->addPlugin(App_View_Helper_Script::TREE_TABLE); $this->view->script()->addPlugin(App_View_Helper_Script::FILE_UPLOADER); $contextMenu1 = array('newfile' => array('label' => 'new file', 'icon' => 'add'), 'newfolder' => array('label' => 'new folder', 'icon' => 'add'), 'delete' => array('label' => 'delete', 'icon' => 'delete')); $rootFolderMenu = array('newfile' => array('label' => 'new file', 'icon' => 'add'), 'newfolder' => array('label' => 'new folder', 'icon' => 'add')); $fileMenuOption = array('delete' => array('label' => 'delete', 'icon' => 'delete')); if (false == $this->_isAllowDelete) { $contextMenu1['delete'] = false; $fileMenuOption['delete'] = false; } if (false == $this->_isAllowAdd) { $contextMenu1['newfile'] = false; $contextMenu1['newfolder'] = false; $rootFolderMenu['newfile'] = false; $rootFolderMenu['newfolder'] = false; } $this->view->contextMenu('myMenu1', null, $contextMenu1)->render(); $this->view->contextMenu('rootFolderMenu', null, $rootFolderMenu)->render(); $this->view->contextMenu('fileMenu', null, $fileMenuOption)->render(); ?> <table id="folder-tree" class='extensions doc example'> <thead> <tr> <th>Title</th> <th width="20px" >Type</th> <th width="80px" >Size</th> <th width="5px" >Load</th> <?php if ($this->_isAllowDelete) { ?> <th width="5px">Delete</th> <?php } ?> </tr> </thead> <tbody> <tr type='rootfolder' style="background-color: #FFFFCC" id="node-<?php echo $this->rootFolder->id; ?> " class='rootfolder folder' > <td><span class="folder"><?php echo $this->rootFolder->name; ?> </span></td> <td>Folder</td> <td></td> <td></td> <?php if ($this->_isAllowDelete) { ?> <td></td> <?php } ?> </tr> <?php // print_r( $this->rootFolder ); echo echo $this->genFolderRows($rootfolder); ?> <?php // LOAD FILE foreach ($this->rootFolder->getFileList() as $file) { ?> <tr id="node-<?php echo $file->id; ?> " class="file child-of-node-<?php echo $file->folderId; ?> "> <td><span class="file"><?php echo $file->name; ?> </span></td> <td>.<?php echo strtoupper($file->getExtension()); ?> </td> <td align="right"><?php echo App_Formatter::toMoney($file->size / 1000); ?> MB</td> <td><a target="_blank" href="<?php echo $file->url; ?> "><?php echo ICON_IMG_DOWNLOAD; ?> </a></td> <?php if ($this->_isAllowDelete) { ?> <td><?php echo IMGDELETE; ?> </td> <?php } ?> </tr> <?php } ?> </tbody> </table> <div id='dialog-add-subfolder'></div> <?php $this->view->jQuery()->onLoadCaptureStart(); ?> function openSubFolderDialog(t){ var id = $(t).attr('id').split('node-')[1]; $( "#dialog-add-subfolder" ).load('<?php echo $this->view->url(array('action' => 'new-folder-dialog', 'controller' => 'file-manager', 'module' => 'system')); ?> ?parenfoldertid='+id ,function(){ $( "#dialog-add-subfolder" ).dialog( "destroy" ); $( "#dialog-add-subfolder" ).dialog({ open:function(){ }, title:'Add Folder Dialog', modal: true, resizable: false, height:255, width:600, buttons: { Ok: function() { var thisDialog = $(this); var formdata = $('form#form_newFolderdialog').serialize(); //alert(formdata); $.post('<?php echo $this->view->url(array('action' => 'add-sub-folder', 'controller' => 'file-manager', 'module' => 'system')); ?> ', formdata , function(data){ if( data.result =='success'){ location.href='<?php echo $this->view->url(); ?> '; }else{ jAlert(data.message, 'Error!!!',function(){ }); } }, "json"); } } }); }); }; $("#folder-tree").treeTable({ initialState: "expanded" }); // Configure draggable nodes $("#folder-tree .file, #folder-tree .folder").draggable({ helper: "clone", opacity: .75, refreshPositions: true, // Performance? revert: "invalid", revertDuration: 300, scroll: true }); $("#folder-tree .folder").each(function() { $($(this).parents("tr")[0]).droppable({ accept: ".file, .folder", drop: function(e, ui) { $($(ui.draggable).parents("tr")[0]).appendBranchTo(this); }, hoverClass: "accept", over: function(e, ui) { if(this.id != $(ui.draggable.parents("tr")[0]).id && !$(this).is(".expanded")) { $(this).expand(); } } }); }); // Make visible that a row is clicked $("table#folder-tree tbody tr").mousedown(function() { $("tr.selected").removeClass("selected"); // Deselect currently selected rows $(this).addClass("selected"); }); // Make sure row is selected when span is clicked $("table#folder-tree tbody tr span").mousedown(function() { $($(this).parents("tr")[0]).trigger("mousedown"); }); $('#folder-tree tr.folder').contextMenu('myMenu1',{ bindings: { 'newfile': function(t) { $(t).filepicker({ folderid:$(t).attr('id').split('node-')[1], autoOpen:true, success:function(el,file,result){ location.href='<?php echo $this->view->url(); ?> '; }, error:function(el,file,result){ alert(result.message); } }); }, 'newfolder':function(t){ openSubFolderDialog(t); }, 'delete': function(t) { deletefolder(t); } } }); $('#folder-tree tr.rootfolder').contextMenu('rootFolderMenu',{ bindings: { 'newfile': function(t) { $(t).filepicker({ folderid:$(t).attr('id').split('node-')[1], autoOpen:true, success:function(el,file,result){ location.href='<?php echo $this->view->url(); ?> '; }, error:function(el,file,result){ alert(result.message); } }); }, 'newfolder':function(t){ openSubFolderDialog(t); } } }); function deletefile(t){ var id = $(t).attr('id').split('node-')[1]; $.alerts.confirm('Are you sure want to delete file : '+ $(t).find('td:eq(0)').text()+' ?', 'Confirm Delete', function(result){ if(result == true){ $('#div_loader').show(); $.post('<?php echo $this->view->url(array('action' => 'delete-file', 'controller' => 'file-manager', 'module' => 'system')); ?> ', {'fileid':id}, function(data){ $('#div_loader').hide(); if( data.result =='success'){ $(t).remove(); }else{ jAlert(data.message, 'เตือน'); } }, "json"); } }); } function deletefolder(t){ var id = $(t).attr('id').split('node-')[1]; $.alerts.confirm('Are you sure want to delete folder : '+ $(t).find('td:eq(0)').text()+' ?', 'Confirm Delete', function(result){ if(result == true){ $('#div_loader').show(); $.post('<?php echo $this->view->url(array('action' => 'delete-folder', 'controller' => 'file-manager', 'module' => 'system')); ?> ', {'folderid':id}, function(data){ $('#div_loader').hide(); if( data.result =='success'){ $(t).remove(); }else{ jAlert(data.message, 'เตือน'); } }, "json"); } }); } $('#folder-tree tr.file ').contextMenu('fileMenu',{ bindings: { 'delete': function(t) { deletefile(t); } } }); $('#folder-tree tr.file .IMGDELETE').bind('click',function(){ //trObj = $(this).parent().parent(); trObj = $(this).parents('tr').eq(0); deletefile(trObj) }); $('#folder-tree tr.folder .IMGDELETE').bind('click',function(){ //trObj = $(this).parent().parent(); trObj = $(this).parents('tr').eq(0); deletefolder(trObj); }); <?php $this->view->jQuery()->onLoadCaptureEnd(); $contents = ob_get_contents(); ob_clean(); return $contents; }
protected function _getCell($default = '', $defaultAlign = 'left', $filedId = '') { $columnConfig = $this->_columnConfig; if ($filedId != '') { $textOnCell = $this->_getCellText($filedId, $default); //if($align==''){ $align = in_array($columnConfig[$filedId]['align'], array('left', 'center', 'right')) ? $columnConfig[$filedId]['align'] : $defaultAlign; //} } else { $textOnCell = $default; } //echo $this->_modelConfig->getPropByName($filedId)->type; $property = $this->_modelConfig->getPropByName($filedId); if ($property->type == 'boolean') { $align = 'center'; $textOnCell = $this->_getCellTick($textOnCell, $filedId); } else { if (isset($property->multiOptions->options)) { $align = 'right'; $lov = $property->multiOptions->options; $textOnCell = $this->view->inputLOV($filedId, $textOnCell, $lov, array('showPleaseSelect' => false, 'class' => 'change-inline-lov')); } else { if ($this->_modelConfig->getPropByName($filedId)->type == 'currency') { $align = 'right'; $textOnCell = App_Formatter::toMoney($textOnCell); } } } $type = ''; //$type= $this->_modelConfig->getPropByName($filedId)->type; return "<td style='display:table-cell; vertical-align:middle;text-align:{$align}' align='{$align}' >{$type}{$textOnCell}</td>"; }