Esempio n. 1
0
	static function typeinfo($id) {
		$type = type::getInstance ();
		if (is_array ( $id ))
			$id = $id ['typeid'];
		
		$typeinfo [] = $type->type [$id];
		$typeinfo [0] ['url'] = type::url ( $id );
		if(!$typeinfo){
			return;
		}
		
		$types = $type->son ( $id );
		$tys = array ();
		foreach ( $types as $typeid ) {
			$_type = $type->type [$typeid];
			if ($stype && ! preg_match ( '/-/', $stype ) && $_type ['stype'] != $stype)
				continue;
			if ($stype && preg_match ( '/-/', $stype ) && '-' . $_type ['stype'] == $stype)
				continue;
			$_type ['url'] = type::url ( $_type ['typeid'] );
			$tys [] = $_type;
		}
		if(!empty($tys)){
			$typeinfo = array_merge($typeinfo,$tys);
		}
		//var_dump($typeinfo);
		return $typeinfo;
	}
Esempio n. 2
0
 function list_action() {
     $this->view->page=front::get('page') ?front::get('page') : 1;
     $this->pagesize=config::get('list_pagesize');
     $limit=(($this->view->page -1) * $this->pagesize).','.$this->pagesize;
     $type=new type();
     $types=array();
     $types=$type->sons(front::get('typeid'));
     $types[]=front::get('typeid');
     $where='typeid in ('.implode(',',$types).') AND checked=1 AND state=1';
     $this->view->type=$type->getrow('typeid='.front::get('typeid'));
     $this->view->pages=@$this->view->type['ispages'];
     $this->view->typeid=front::get('typeid');
     $archive=new archive();
     $archives=$archive->getrows($where,$limit,'listorder desc,aid desc');
     foreach ($archives as $order=>$arc) {
         $archives[$order]['url']=archive::url($arc);
         $archives[$order]['typename']=type::name($arc['typeid']);
         $archives[$order]['typeurl']=type::url($arc['typeid']);
         $archives[$order]['adddate']=sdate($arc['adddate']);
         $archives[$order]['stitle']=strip_tags($arc['title']);
         $archives[$order]['sthumb'] = @strstr($arc['thumb'], "http://") ? $arc['thumb'] : config::get('base_url') . '/' . $arc['thumb'];
     }
     $this->view->archives=$archives;
     $this->view->record_count=$archive->rec_count($where);
     front::$record_count=$this->view->record_count;
     $this->type=type::getInstance();
 	if (front::get('t') == 'wap') {
         $this->out('wap/type_list.html');
         return;
     }
     $template=$this->type->type[front::get('typeid')]['template'];
     if ($template&&file_exists(TEMPLATE.'/'.$this->view->_style.'/'.$template)) $this->out($template);
     else {
         $tpl=type::gettemplate($this->view->typeid);
         if (type::getishtml($this->view->typeid)) {
             $path=ROOT.type::url($this->view->typeid,@front::$get['page']>1 ?front::$get['page'] : null);
             if (!preg_match('/\.[a-zA-Z]+$/',$path)) $path=rtrim(rtrim($path,'/'),'\\').'/index.html';
             $this->cache_path=$path;
         }
         $this->out($tpl);
     }
 }
Esempio n. 3
0
function typies($id=0,$stype=null) {
	$category=type::getInstance();
	if (is_array($id))
		$id=$id['typeid'];
	$categories=$category->son($id);
	$cats=array();
	foreach ($categories as $catid) {
		$_category=$category->type[$catid];
		if ($stype &&!preg_match('/-/',$stype) &&$_category['stype'] <>$stype)
			continue;
		if ($stype &&preg_match('/-/',$stype) &&'-'.$_category['stype'] == $stype)
			continue;
		if(front::get('t') == 'wap' && !$cat['ismobilenav']){
			continue;
		}
		$_category['url']=type::url($_category['typeid'],1);
		$cats[]=$_category;
	}
	return $cats;
}
Esempio n. 4
0
    function show_action() {
        if (!front::get('aid'))
            front::$get['aid'] = front::get('id');
        front::check_type(front::$get['aid']);
        $this->view->aid = trim(front::get('aid'));
        $this->view->archive = archive::getInstance()->getrow(front::get('aid'));
        $this->view->categorys = category::getpositionlink2($this->view->archive['catid']);
        if (!is_array($this->view->archive))
            $this->out('message/error.html');
        if ($this->view->archive['checked'] < 1)
            exit(lang('未审核!<a href="'.front::$from.'">返回</a>'));
        if (!rank::arcget(front::get('aid'), $this->view->usergroupid)) {
            $this->out('message/error.html');
        }
        $this->view->catid = $this->view->archive['catid'];
        $this->view->topid = category::gettopparent($this->view->catid);
        $this->view->parentid = $this->category->getparent($this->view->catid);
        if (!rank::catget($this->view->catid, $this->view->usergroupid))
            $this->out('message/error.html');
        if (!isset($this->category->category[$this->view->catid]) ||
                !isset($this->category->category[$this->view->topid])) {

        }
        $template = @$this->view->archive['template'];
        $linkword = new linkword();
        $linkwords = $linkword->getrows(null, 1000, 'linkorder desc');
        $content = $this->view->archive['content'];
        $contents = preg_split('%<div style="page-break-after(.*?)</div>%si', $content);
        if ($contents) {
            $this->view->pages = count($contents);
            front::$record_count = $this->view->pages * config::get('list_pagesize');
            $content = $contents[$this->view->page - 1];
        }

        //$content = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', $content);

        foreach ($linkwords as $linkword) {
            $linkword['linktimes'] = (int) $linkword['linktimes'];
            if (trim($linkword['linkurl']) && !preg_match('%^http://$%', trim($linkword['linkurl']))) {
                $link = "<a href='$linkword[linkurl]' target='_blank'>$linkword[linkword]</a>";
            } else {
                $link = "<a href='" . url('archive/search/keyword/' . urlencode($linkword['linkword'])) . "' target='_blank'>$linkword[linkword]</a>";
            }
            $content = _keylinks($content,$linkword['linkword'],$link,$linkword['linktimes']);
        }

        $this->view->likenews = $this->getLike($this->view->archive['tag'], $this->view->archive['keyword']);

        $taghtml = '';
        $tag_table = new tag();
        foreach ($tag_table->urls($this->view->archive['tag']) as $tag => $url) {
            $taghtml.="<a href='$url' target='_blank'>$tag</a>&nbsp;&nbsp;";
        }
        $this->view->archive['tag'] = $taghtml;

        $this->view->archive['special'] = null;
        if ($this->view->archive['spid']) {
            $spurl = special::url($this->view->archive['spid'],special::getishtml($this->view->archive['spid']));
            $sptitle = special::gettitle($this->view->archive['spid']);
            $this->view->archive['special'] = "<a href='$spurl' target='_blank'>$sptitle</a>&nbsp;&nbsp;";
        }
        $this->view->archive['type'] = null;
        if ($this->view->archive['typeid']) {
            $typeurl = type::url($this->view->archive['typeid'],1);
            $typetitle = type::name($this->view->archive['typeid']);
            $this->view->archive['type'] = "<a href='$typeurl' target='_blank'>$typetitle</a>&nbsp;&nbsp;";
        }
        $this->view->archive['area'] = null;
        $this->view->archive['area'] = area::getpositonhtml($this->view->archive['province_id'], $this->view->archive['city_id'], $this->view->archive['section_id']);
        $this->view->archive['content'] = $content;
        $aid = front::$get['aid'];
        $catid = $this->view->catid;
        if(!$this->view->archive['showform']) {
            $this->getshowform($catid);
        }else if($this->view->archive['showform'] && $this->view->archive['showform'] == '1') {
            $this->showform = 1;
        }else {
            $this->showform = $this->view->archive['showform'];
        }
        if(preg_match('/^my_/is',$this->showform)) {
            $this->view->archive['showform'] = $this->showform;
            $o_table = new defind($this->showform);
            front::$get['form'] = $this->showform;
            $this->view->primary_key = $o_table->primary_key;
            $field = $o_table->getFields();
            $fieldlimit = $o_table->getcols('user_modify');
            helper::filterField($field,$fieldlimit);
            $this->view->field = $field;
        }else {
            $this->view->archive['showform'] = '';
        }
        
        $str = "";
        cb_data($this->view->archive);
        foreach( $this->view->archive as $key => $value){
        	if(!preg_match('/^my/',$key) || !$value)
        		continue;
        	$category = category::getInstance();
        	$sonids = $category->sons(setting::$var['archive'][$key]['catid']);
        	if(setting::$var['archive'][$key]['catid'] != $this->view->archive['catid'] && !in_array($this->view->archive['catid'],$sonids) && (setting::$var['archive'][$key]['catid'])){
        		unset($this->view->field[$key]);
        		continue;
        	}
        	$str .= '<p> '.setting::$var['archive'][$key]['cname'].':'. $value.'</p>';
        }
        $this->view->archive['my_fields'] = $str;

        $sql1 = "SELECT aid,title,catid FROM `{$this->archive->name}` WHERE catid = '$catid' AND aid > '$aid' ORDER BY aid ASC LIMIT 0,1";
        $sql2 = "SELECT aid,title,catid FROM `{$this->archive->name}` WHERE catid = '$catid' AND aid < '$aid' ORDER BY aid DESC LIMIT 0,1";
        $n = $this->archive->rec_query_one($sql1);
        $p = $this->archive->rec_query_one($sql2);
        $this->view->archive['p'] = $p;
        $this->view->archive['n'] = $n;
        $this->view->archive['p']['url'] = archive::url($p);
        $this->view->archive['n']['url'] = archive::url($n);

        $this->view->archive['strgrade'] = archive::getgrade($this->view->archive['grade']);
        $prices = getPrices($this->view->archive['attr2']);
        $this->view->archive['attr2'] = $prices['price'];
        $this->view->archive['oldprice'] = $prices['oldprice'];
		$this->view->groupname = $prices['groupname'];
		
		//$this->view->archive['pics'] = unserialize($this->view->archive['pics']);
		if(is_array($this->view->archive['pics']) && !empty($this->view->archive['pics'])){
			foreach ($this->view->archive['pics'] as $k => $v){
				if(strtolower(substr($v,0,7)) == 'http://'){
					$this->view->archive['pics'][$k] = $v;
				}else{
					$this->view->archive['pics'][$k] = $v;
				}
			}
		}
		//$this->view->archive['pics'] = unserialize($this->view->archive['pics']);
		//var_dump($this->view->archive);

        if (front::get('t') == 'wap') {
        	$tpl = category::gettemplate($this->view->catid, 'showtemplatewap');
        	if(!$tpl) $tpl = 'wap/show.html';
            $this->out($tpl);
            return;
        }

        if ($template && file_exists(TEMPLATE . '/' . $this->view->_style . '/' . $template))
            $this->out($template);
        else {
            $tpl = category::gettemplate($this->view->catid, 'showtemplate');
            if (category::getarcishtml($this->view->archive)) {
                $path = ROOT . archive::url($this->view->archive);
                if (!preg_match('/\.[a-zA-Z]+$/', $path))
                    $path = rtrim(rtrim($path, '/'), '\\') . '/index.html';
                $this->cache_path = $path;
            }
            $this->out($tpl);
        }
    }
 /**
  * Genera el asiento contable para una factura de venta.
  * Devuelve TRUE si el asiento se ha generado correctamente, False en caso contrario.
  * Si genera el asiento, este es accesible desde $this->asiento.
  * @param type $factura
  */
 public function generar_asiento_venta(&$factura)
 {
     $ok = FALSE;
     $this->asiento = FALSE;
     $cliente0 = new cliente();
     $subcuenta_cli = FALSE;
     $cliente = $cliente0->get($factura->codcliente);
     if ($cliente) {
         $subcuenta_cli = $cliente->get_subcuenta($factura->codejercicio);
     }
     if ($factura->totalirpf != 0 or $factura->totalrecargo != 0) {
         $this->new_error_msg('Todavía no se pueden generar asientos de facturas con IRPF o recargo.');
     } else {
         if (!$subcuenta_cli) {
             $eje0 = $this->ejercicio->get($factura->codejercicio);
             $this->new_message("No se ha podido generar una subcuenta para el cliente\n            <a href='" . $eje0->url() . "'>¿Has importado los datos del ejercicio?</a>\n            Aun así la <a href='" . $factura->url() . "'>factura</a> se ha generado correctamente,\n            pero sin asiento contable.");
         } else {
             $asiento = new asiento();
             $asiento->codejercicio = $factura->codejercicio;
             $asiento->concepto = "Factura de venta " . $factura->codigo . " - " . $factura->nombrecliente;
             $asiento->documento = $factura->codigo;
             $asiento->editable = FALSE;
             $asiento->fecha = $factura->fecha;
             $asiento->importe = $factura->total;
             $asiento->tipodocumento = 'Factura de cliente';
             if ($asiento->save()) {
                 $asiento_correcto = TRUE;
                 $subcuenta = new subcuenta();
                 $partida0 = new partida();
                 $partida0->idasiento = $asiento->idasiento;
                 $partida0->concepto = $asiento->concepto;
                 $partida0->idsubcuenta = $subcuenta_cli->idsubcuenta;
                 $partida0->codsubcuenta = $subcuenta_cli->codsubcuenta;
                 $partida0->debe = $factura->total;
                 $partida0->coddivisa = $factura->coddivisa;
                 $partida0->tasaconv = $factura->tasaconv;
                 if (!$partida0->save()) {
                     $asiento_correcto = FALSE;
                     $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida0->codsubcuenta . "!");
                 }
                 /// generamos una partida por cada impuesto
                 $subcuenta_iva = $subcuenta->get_cuentaesp('IVAREP', $asiento->codejercicio);
                 foreach ($factura->get_lineas_iva() as $li) {
                     if ($subcuenta_iva and $asiento_correcto) {
                         $partida1 = new partida();
                         $partida1->idasiento = $asiento->idasiento;
                         $partida1->concepto = $asiento->concepto;
                         $partida1->idsubcuenta = $subcuenta_iva->idsubcuenta;
                         $partida1->codsubcuenta = $subcuenta_iva->codsubcuenta;
                         $partida1->haber = $li->totaliva;
                         $partida1->idcontrapartida = $subcuenta_cli->idsubcuenta;
                         $partida1->codcontrapartida = $subcuenta_cli->codsubcuenta;
                         $partida1->cifnif = $cliente->cifnif;
                         $partida1->documento = $asiento->documento;
                         $partida1->tipodocumento = $asiento->tipodocumento;
                         $partida1->codserie = $factura->codserie;
                         $partida1->factura = $factura->numero;
                         $partida1->baseimponible = $li->neto;
                         $partida1->iva = $li->iva;
                         $partida1->coddivisa = $factura->coddivisa;
                         $partida1->tasaconv = $factura->tasaconv;
                         if (!$partida1->save()) {
                             $asiento_correcto = FALSE;
                             $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida1->codsubcuenta . "!");
                         }
                     }
                 }
                 $subcuenta_ventas = $subcuenta->get_cuentaesp('VENTAS', $asiento->codejercicio);
                 if ($subcuenta_ventas and $asiento_correcto) {
                     $partida2 = new partida();
                     $partida2->idasiento = $asiento->idasiento;
                     $partida2->concepto = $asiento->concepto;
                     $partida2->idsubcuenta = $subcuenta_ventas->idsubcuenta;
                     $partida2->codsubcuenta = $subcuenta_ventas->codsubcuenta;
                     $partida2->haber = $factura->neto;
                     $partida2->coddivisa = $factura->coddivisa;
                     $partida2->tasaconv = $factura->tasaconv;
                     if (!$partida2->save()) {
                         $asiento_correcto = FALSE;
                         $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida2->codsubcuenta . "!");
                     }
                 }
                 if ($asiento_correcto) {
                     $factura->idasiento = $asiento->idasiento;
                     if ($factura->save()) {
                         $ok = TRUE;
                         $this->asiento = $asiento;
                     } else {
                         $this->new_error_msg("¡Imposible añadir el asiento a la factura!");
                     }
                 } else {
                     if ($asiento->delete()) {
                         $this->new_message("El asiento se ha borrado.");
                     } else {
                         $this->new_error_msg("¡Imposible borrar el asiento!");
                     }
                 }
             } else {
                 $this->new_error_msg("¡Imposible guardar el asiento!");
             }
         }
     }
     return $ok;
 }
Esempio n. 6
0
 /**
  *
  * @param string $name
  * @param array $fields
  * @param Zend_Paginator_Instance $paginator
  * @param array $extracolumn
  * @param Bool  $sorting
  *
  * @return string
  */
 public function generateGrid($dataArray, $paginator, $extracolumn = array(), $sorting = false, $formgrid = 'false', $addaction = '', $menuName = '', $addpermission, $sortStr = '', $actnArr)
 {
     $view_link = isset($dataArray['view_link']) ? $dataArray['view_link'] : "";
     $name = isset($dataArray['objectname']) ? $dataArray['objectname'] : "";
     $by = isset($dataArray['by']) ? $dataArray['by'] : "";
     $search_filters = isset($dataArray['search_filters']) ? $dataArray['search_filters'] : array();
     $fields = isset($dataArray['tableheader']) ? $dataArray['tableheader'] : array();
     $searchArray = isset($dataArray['searchArray']) ? $dataArray['searchArray'] : array();
     $jsGridFnname = isset($dataArray['jsGridFnName']) ? $dataArray['jsGridFnName'] : "";
     $perPage = isset($dataArray['perPage']) ? $dataArray['perPage'] : "20";
     $page = isset($dataArray['pageNo']) ? $dataArray['pageNo'] : "1";
     $call = isset($dataArray['call']) ? $dataArray['call'] : "";
     $dashboardCall = isset($dataArray['dashboardcall']) ? $dataArray['dashboardcall'] : "No";
     $sortname = isset($dataArray['sort']) ? $dataArray['sort'] : "";
     $grid_type = isset($dataArray['grid_type']) ? $dataArray['grid_type'] : "";
     $status_value = isset($dataArray['status_value']) ? $dataArray['status_value'] : "";
     $add_link = isset($dataArray['add_link']) ? $dataArray['add_link'] : "";
     $sd_req_model = new Default_Model_Servicerequests();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $request = Zend_Controller_Front::getInstance();
     $params = $request->getRequest()->getParams();
     $dataclass = '';
     // Store Extra Columns
     $this->extra = $extracolumn;
     $sortIconStr = "";
     $sort = Zend_Controller_Front::getInstance()->getRequest()->getParam('sort', 'DESC');
     // checking and handling sorting.
     if ($sort == "") {
         $sortIconStr = "<span class='s-ico'>\r\n\t\t\t<span class='ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-n'></span>\r\n\t\t\t<span class='ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-s'></span></span>";
     } else {
         if ($sort == 'ASC') {
             $sort = 'DESC';
             //For Sort Icons....
             $sortIconStr = "<span class='s-ico'>\r\n\t\t\t<span class='ui-icon-desc ui-icon ui-icon-triangle-1-n'></span>\r\n\t\t\t</span>";
         } else {
             $sort = 'ASC';
             //For Sort Icons....
             $sortIconStr = "<span class='s-ico'>\r\n\t\t\t<span class='ui-icon-asc  ui-icon ui-icon-triangle-1-s'></span></span>";
         }
     }
     if ($call != "ajaxcall") {
         $sortIconStr = "";
     }
     if ($addaction != '') {
         $action = $addaction;
     }
     $con = '';
     $output = "<div class='table-header'><span>" . $menuName . "</span>";
     if ($addaction != '') {
         $output .= "<div class='add-btn-div'>";
         if ($add_link != '') {
             $output .= "<input type='button' title = 'Raise a Request' onclick='window.location.href=\"" . $add_link . "\"' value='Raise a Request' class='sprite addrequest' />";
         } else {
             $output .= "<input type='button' title = 'Raise a Request' onclick='window.location.href=\"" . DOMAIN . $name . '/' . $action . "\"' value='Raise a Request' class='sprite addrequest' />";
         }
         $output .= "</div>";
     }
     $output .= "</div>";
     if ($addpermission == 'false') {
         $output = "<div class='table-header'><span>" . $menuName . "</span></div>";
     }
     $output .= "<div id='" . $name . "' class='details_data_display_block newtablegrid'>";
     $output .= "<table class='grid' align='center'  width='100%' cellspacing='0' cellpadding='4' border='0'><thead><tr>";
     // this foreach loop display the column header  in �th� tag.
     $colinr = 0;
     if (!empty($fields)) {
         $tabindx = 0;
         if (empty($actnArr)) {
             unset($fields['action']);
         }
         foreach ($fields as $key => $value) {
             if (isset($value['align'])) {
                 $align = $value['align'] != '' ? 'align="' . $value['align'] . '" ' : '';
             }
             if (isset($value['sortkey'])) {
                 $sortkey = $value['sortkey'] != '' ? 'align="' . $value['sortkey'] . '" ' : '';
             }
             if (isset($value['style'])) {
                 $style = $value['style'] != '' ? 'style="' . $value['style'] . '" ' : '';
             }
             $value = is_array($value) && !isset($value['sortkey']) ? $value['value'] : $value;
             if ($value == 'Action') {
                 $width = 'width=90';
             } else {
                 $width = '';
             }
             $output .= "<th " . $width . ">";
             // Check if Sorting is set to True
             if ($sorting) {
                 // Disable Sorting if Key is in Extra Columns
                 if (@$this->extra[$key]['name'] != '' && !is_array($value)) {
                     if ($value == "Action") {
                         $output .= "<span class='action-text'>Action</span>";
                     } else {
                         $output .= $value;
                     }
                 } else {
                     if (is_array($value)) {
                         $key = $value['sortkey'];
                         $value = $value['value'];
                     }
                     $welcome = 'false';
                     $urlString = $_SERVER['REQUEST_URI'];
                     if (strpos($urlString, 'welcome') !== false) {
                         $welcome = 'true';
                     }
                     if ($formgrid == 'true') {
                         $output .= "<a href='javascript:void(0);' onclick=javascript:paginationndsorting('" . DOMAIN . $name . "/index/sort/" . $sort . "/by/" . $key . "/objname/" . $name . "/page/" . $page . "/per_page/" . $perPage . "/call/ajaxcall/{$con}/');>" . $value . "</a>";
                         //For Sort Icons....
                         if ($key == $sortStr) {
                             $output .= $sortIconStr;
                         }
                     } else {
                         if ($welcome == 'true') {
                             $output .= "<a href='javascript:void(0);' onclick=javascript:paginationndsorting('" . DOMAIN . $name . "/index/sort/" . $sort . "/by/" . $key . "/objname/" . $name . "/page/" . $page . "/per_page/" . $perPage . "/call/ajaxcall/{$con}/');>" . $value . "</a>";
                             //For Sort Icons....
                             if ($key == $sortStr) {
                                 $output .= $sortIconStr;
                             }
                         } else {
                             $output .= "<a href='javascript:void(0);' onclick=javascript:paginationndsorting('" . $this->view->url(array('sort' => $sort, 'by' => $key, 'objname' => $name, 'page' => $page, 'per_page' => $perPage)) . "');>" . $value . "</a>";
                             //For Sort Icons....
                             if ($key == $sortStr) {
                                 $output .= $sortIconStr;
                             }
                         }
                     }
                 }
             } else {
                 //For Sort Icons....
                 if ($key == $sortStr) {
                     $output .= $sortIconStr;
                 }
                 $output .= $value;
             }
             $output .= "</th>";
             $colinr++;
             $tabindx++;
         }
         //end of for each loop
         $output .= "</tr><tr id='search_tr_{$name}'>";
         $tabindx = 0;
         foreach ($fields as $key => $value) {
             if (isset($value['align'])) {
                 $align = @$value['align'] != '' ? 'align="' . $value['align'] . '" ' : '';
             }
             if (isset($value['sortkey'])) {
                 $sortkey = @$value['sortkey'] != '' ? 'align="' . $value['sortkey'] . '" ' : '';
             }
             if (isset($value['style'])) {
                 $style = @$value['style'] != '' ? 'style="' . $value['style'] . '" ' : '';
             }
             $value = is_array($value) && !isset($value['sortkey']) ? $value['value'] : $value;
             if ($value == 'Action') {
                 $width = 'width=90';
             } else {
                 $width = '';
             }
             $output .= "<th " . $width . ">";
             // Check if Sorting is set to True
             if ($sorting) {
                 // Disable Sorting if Key is in Extra Columns
                 if (@$this->extra[$key]['name'] != '' && !is_array($value)) {
                     if ($value == "Action") {
                         $output .= "<span class='action-text'></span>";
                     } else {
                         $output .= $value;
                     }
                 } else {
                     if (is_array($value)) {
                         $key = $value['sortkey'];
                         $value = $value['value'];
                     }
                     $welcome = 'false';
                     $urlString = $_SERVER['REQUEST_URI'];
                     if ($key != 'id') {
                         $sText = '';
                         if (!empty($searchArray)) {
                             $display = 'display: block;';
                         } else {
                             $display = 'display: none;';
                         }
                         if (is_array($searchArray)) {
                             if (array_key_exists($key, $searchArray)) {
                                 $sText = $searchArray[$key];
                             } else {
                                 $sText = '';
                             }
                         }
                         if (isset($search_filters[$key])) {
                             $search_function = 'getsearchdata("' . $name . '","",this.id,event';
                             $output .= sapp_Global::grid_data($search_filters, $key, $name, $display, $sText, $tabindx, $search_function);
                         } else {
                             $output .= "<input tabIndex={$tabindx} type='text' name='{$name}' id='{$key}' style='{$display}' class='searchtxtbox_{$name} table_inputs grid_search_inputs' value='{$sText}' onkeydown='getsearchdata(\"{$name}\",\"\",this.id,event,\"text\")' />";
                         }
                     }
                 }
             } else {
                 //For Sort Icons....
                 if ($key == $sortStr) {
                     $output .= $sortIconStr;
                 }
                 $output .= $value;
             }
             $output .= "</th>";
             $colinr++;
             $tabindx++;
         }
         //end of for each loop
     }
     if ($grid_type != '') {
         $output .= "<input type='hidden' id='service_grid' value='" . sapp_Global::_encrypt($grid_type) . "' />";
     }
     if ($status_value != '') {
         $output .= "<input type='hidden' id='service_grid_status' value='" . sapp_Global::_encrypt($status_value) . "' />";
     }
     $output .= "</tr></thead>";
     $output .= "<tbody>";
     // Start Looping Data
     $ii = 0;
     foreach ($paginator as $p) {
         $cell_color = $ii % 2 == 0 ? "row1" : "row2";
         $ii++;
         $bodyCount = 0;
         //$output.="<tr onclick='window.location=\"" . $this->_parseString($view_link, $p) . "\"' class='$cell_color cursor'>";
         $output .= "<tr class='{$cell_color} '>";
         // Reset Fields Array to Top
         if (!empty($fields)) {
             reset($fields);
             foreach ($fields as $k => $v) {
                 $tdclass = '';
                 // Look for additional attributes
                 $characterlimit = 40;
                 if (is_array($v)) {
                     $class = @$v['class'] != '' ? 'class="' . $v['class'] . '" ' : '';
                     $align = @$v['align'] != '' ? 'align="' . $v['align'] . '" ' : '';
                     $valign = @$v['valign'] != '' ? 'valign="' . $v['valign'] . '" ' : '';
                     if (isset($v['characterlimit'])) {
                         $characterlimit = $v['characterlimit'];
                     }
                     $output .= "<td {$tdclass}{$align}{$valign}>";
                 } else {
                     if ($k == 'description' && $menuName == 'Screening Types') {
                         $characterlimit = 80;
                     }
                     $output .= "<td {$tdclass}>";
                 }
                 // Check to see if this Field is in Extra Columns
                 if (isset($this->extra[$k]['value'])) {
                     $output .= $this->_parseExtra($k, $p);
                 } else {
                     $valToInclude = strlen(trim($p[$k])) > $characterlimit ? substr(trim($p[$k]), 0, $characterlimit) . ".." : trim($p[$k]);
                     if ($k == 'executor_id') {
                         if (!empty($valToInclude)) {
                             #$output .= "<span " . $dataclass . " title='" . htmlentities(trim($p[$k]), ENT_QUOTES, "UTF-8") . "' ><a onclick='displaydeptform(\'' . DOMAIN . $name . '/assignservicerequestpopup/id/{{id}}') name='{{id}}'>Allocate Executor</a></span>";
                             $isAdmin = $sd_req_model->IsAdminForServiceTicket($loginUserId, $p["ticket_number"]);
                             if ($isAdmin == "1") {
                                 $output .= "<span " . $dataclass . " title='" . htmlentities(trim($p[$k]), ENT_QUOTES, "UTF-8") . "' ><a href='" . DOMAIN . $name . '/assignservicerequestpopup/id/' . $p["id"] . "' target='_blank'>" . ($valToInclude == -1 ? "Allocate" : "Reallocate") . " Executor</a></span>";
                             }
                         }
                     } else {
                         if ($k == 'ticket_number') {
                             if (!empty($valToInclude)) {
                                 $temp_ticketnumber = "<span " . $dataclass . " title='" . htmlentities(trim($p[$k]), ENT_QUOTES, "UTF-8") . "' >" . htmlentities($valToInclude, ENT_QUOTES, "UTF-8") . "</span>";
                                 $output .= "<span " . $dataclass . " title='" . htmlentities(trim($p[$k]), ENT_QUOTES, "UTF-8") . "' ><a href='" . $this->_parseString($view_link, $p) . "'>" . $temp_ticketnumber . "</a></span>";
                             }
                         } else {
                             $p = (array) $p;
                             if (isset($p[$k])) {
                                 $output .= "<span " . $dataclass . " title='" . htmlentities(trim($p[$k]), ENT_QUOTES, "UTF-8") . "' >" . htmlentities($valToInclude, ENT_QUOTES, "UTF-8") . "</span>";
                             }
                             // Customize grid fields data - END
                         }
                     }
                 }
                 $dataclass = '';
                 $output .= "</td>";
                 $bodyCount++;
             }
         }
         // Close the Table Row
         $output .= "</tr>";
     }
     if ($ii == 0) {
         $output .= "<tr><td colspan='{$colinr}' class='no-data-td'><p class='no-data'>No data found</p></td></tr>";
     }
     $output .= "</tbody>";
     $output .= "</table>\r\n                    <script type='text/javascript' language='javascript'>\r\n                    \$(document).ready(function(){                                                                        \r\n                        if(\$('.searchtxtbox_" . $name . "').is(':visible'))\r\n                        {                                        \r\n                            \$('#search_tr_" . $name . "').show();\t\r\n                        }\r\n                        else                                         \r\n                            \$('#search_tr_" . $name . "').hide();\t\r\n                    });\r\n                </script>    \r\n                </div>";
     // Attach Pagination
     if ($paginator) {
         $params = array();
         $params['jsGridFnName'] = $jsGridFnname;
         $params['perPage'] = $perPage;
         $params['objname'] = $name;
         $params['searchArray'] = $searchArray;
         $params['formgrid'] = $formgrid;
         $params['con'] = $con;
         $params['dashboardcall'] = $dashboardCall;
         $params['sortname'] = $sortname;
         $params['by'] = $by;
         $output .= $this->view->paginationControl($paginator, 'Sliding', 'partials/pagination.phtml', $params);
     }
     $output .= "<script type='text/javascript' language='javascript'>\$('#{$name}').slimScrollHorizontal({\r\n\t\t\t\t\t\t\t\t\t  alwaysVisible: false,\r\n\t\t\t\t\t\t\t\t\t  start: 'left',\r\n\t\t\t\t\t\t\t\t\t  position: 'bottom',\r\n\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t}).css({ background: '#ccc', paddingBottom: '10px' }); </script>";
     $output .= "<script type='text/javascript' language='javascript'>\r\n\t\t\t\t\t\tvar id = \$('#columnId').val();\r\n\t\t\t\t\t\tvar coldata = \$('#'+id).val();\r\n\t\t\t\t\t\tvar focusID = \$('#columnId').val();\r\n                                                var fval = \$('#'+focusID).attr('data-focus');\r\n                                                if(fval == '' || fval == null)\r\n\t\t\t\t\t\t\$('#'+focusID).focus().val('').val(coldata);\r\n                                                \r\n\t\t\t\t\t</script>";
     return $output;
 }
Esempio n. 7
0
 function make_show_action() {
     header('Cache-control: private, must-revalidate');
     @set_time_limit(0);
     $submit = front::post('submit') ? front::post('submit') : front::get('submit');
     if (!$submit)
         return;
     chkpw('cache_content');
     //time::start();
     $post = front::$post + front::$get;
     unset($post['submit']);
     $c_url = preg_replace('#&make_page=(\d+)#', '', $_SERVER['QUERY_STRING']);
     $c_url = preg_replace('#&aid_start=(\d+)#', '', $c_url);
     $c_url = preg_replace('#&aid_end=(\d+)#', '', $c_url);
     $c_url = preg_replace('#&catid=(\d+)#', '', $c_url);
     $c_url = preg_replace('#&submit=(\d+)#', '', $c_url);
     $c_url = 'index.php?' . $c_url;
     $c_url.='&submit=1';
     
     $category = category::getInstance(); //实例化栏目类
     
     if ($post['aid_start']) {
         $aid_start = $post['aid_start'];
         $aid_end = $post['aid_end'];
         $where = "aid>=$aid_start and aid<=$aid_end AND checked=1 AND (ishtml IS NULL OR ishtml!=2)";
         $c_url.='&aid_start=' . $aid_start . '&aid_end=' . $aid_end;
     } elseif (isset($post['catid'])) {
         $catid = $post['catid'];
         $categories = $category->sons($catid);
         $categories[] = $catid;
         $categories = implode(',', $categories);
         $where = "catid in(" . $categories . ') and checked=1 AND (ishtml IS NULL OR ishtml!=2)';
         $c_url.='&catid=' . $catid;
     }else
         return;
     $case = 'archive';
     $act = 'show';
     $_GET = array('case' => $case, 'act' => $act);
     $front = new front();
     front::$admin = false;
     front::$html = true;
     front::$rewrite = false;
     $case = $case . '_act';
     $case = new $case();
     $case->init();
     $method = $act . '_action';
     //$time_start = time::getTime();
     
     $archive = new archive(); //实例化文章类
     
     if (config::get('group_on')) { //启用分组生成
         $make_page = $post['make_page'] == '' ? 1 : $post['make_page'];
         $archive->getrows($where);
         $archive_num = $archive->record_count;
         $group_count = config::get('group_count');
         $make_page_num = ceil($archive_num / $group_count);
         $totalpage = (($make_page - 1) * $group_count) . ',' . $group_count;
         $c_url.='&make_page=' . ($make_page + 1);
     } else {
         $totalpage = "";
     }
     
     $archives = $archive->getrows($where, $totalpage, '1'); //取到要生成的所有文章
     
     $cpage = 0;
     foreach ($archives as $arc) {
         if (!category::getarcishtml($arc))  //如果文章设置不生成则跳过
             continue;
         if($arc['linkto']){ //如果有跳转连接则跳过生成
         	continue;
         }
         $case->view->archive = $arc;
         front::$get['aid'] = $case->view->aid = $case->view->archive['aid'];
         $case->view->catid = $case->view->archive['catid'];
         
         $case->view->topid = category::gettopparent($case->view->catid);
         $case->view->parentid = $category->getparent($case->view->catid);
         
         $template = $case->view->archive['template'];
         $content = $case->view->archive['content'];
         
         $case->view->categories = category::getpositionlink2($case->view->catid);
         
         //关键字连接
         $linkword = new linkword();
         $linkwords = $linkword->getrows(null, 1000, 'linkorder desc');
         foreach ($linkwords as $linkword) {
             if (trim($linkword['linkurl']) && !preg_match('%^http://$%', trim($linkword['linkurl']))) {
                 $linkword['linktimes'] = (int) $linkword['linktimes'];
                 $link = "<a href='$linkword[linkurl]' target='_blank'>$linkword[linkword]</a>";
             } else {
                 $link = "<a href='" . url('archive/search/keyword/' . urlencode($linkword['linkword'])) . "' target='_blank'>$linkword[linkword]</a>";
             }
             if (isset($link)) {
                 $content = preg_replace("%(?!\"]*>)$linkword[linkword](?!\s*\")%i", "\\1$link\\2", $content, $linkword['linktimes']);
             }
             unset($link);
         }
         
         //相关文章
         $case->view->likenews = $case->getLike($case->view->archive['tag'], $case->view->archive['keyword']);
         
         //内容分页
         $contents = preg_split('%<div style="page-break-after(.*?)</div>%si', $content);
         if (!empty($contents)) {
             $case->view->pages = count($contents);
             front::$record_count = $case->view->pages * config::get('list_pagesize');
             $case->view->pages = count($contents);
         } else {
             $case->view->pages = 1;
         }
         
         //标签连接
         $taghtml = '';
         $tag_table = new tag();
         foreach ($tag_table->urls($case->view->archive['tag']) as $tag => $url) {
             $taghtml.="<a href='$url' target='_blank'>$tag</a>&nbsp;&nbsp;";
         }
         $case->view->archive['tag'] = $taghtml;
         
         //专题连接
         $case->view->archive['special'] = null;
         if ($case->view->archive['spid']) {
             $spurl = special::url($case->view->archive['spid'],special::getishtml($case->view->archive['spid']));
             $sptitle = special::gettitle($case->view->archive['spid']);
             $case->view->archive['special'] = "<a href='$spurl' target='_blank'>$sptitle</a>&nbsp;&nbsp;";
         }
         
         //分类连接
         $case->view->archive['type'] = null;
         if ($case->view->archive['typeid']) {
             $typeurl = type::url($case->view->archive['typeid'],1);
             $typetitle = type::name($case->view->archive['typeid']);
             $case->view->archive['type'] = "<a href='$typeurl' target='_blank'>$typetitle</a>&nbsp;&nbsp;";
         }
         
         //地区连接
         $case->view->archive['area'] = null;
         $case->view->archive['area'] = area::getpositonhtml($case->view->archive['province_id'], $case->view->archive['city_id'], $case->view->archive['section_id']);
         
         //$arc = $case->view->archive;
         for ($c = 1; $c <= $case->view->pages; $c++) {
             front::$get['page'] = $c;
             $case->view->page = $c;
             if (!empty($contents)) {
                 $content = $contents[$c - 1];
             }
             $case->view->archive['content'] = $content;
             
             //自定义字段
             cb_data($case->view->archive);
             $str = "";
             foreach( $case->view->archive as $key => $value){
             	if(!preg_match('/^my/',$key) || !$value)
             		continue;
             	$sonids = $category->sons(setting::$var['archive'][$key]['catid']);
             	$sonids[] = setting::$var['archive'][$key]['catid'];
             	if(!in_array($case->view->archive['catid'],$sonids) && intval(setting::$var['archive'][$key]['catid'])){
             		//unset($case->view->field[$key]);
             		continue;
             	}
             	$str .= '<p> '.setting::$var['archive'][$key]['cname'].':'. $value.'</p>';
             }
             $arc['my_fields'] = $str;
             
             //上一篇,下一篇
             $aid = $case->view->archive['aid'];
             $catid = $case->view->archive['catid'];
             $sql1 = "SELECT * FROM `{$archive->name}` WHERE catid = '$catid' AND aid > '$aid' ORDER BY aid ASC LIMIT 0,1";
             $sql2 = "SELECT * FROM `{$archive->name}` WHERE catid = '$catid' AND aid < '$aid' ORDER BY aid DESC LIMIT 0,1";
             $n = $archive->rec_query_one($sql1);
             $p = $archive->rec_query_one($sql2);
             $case->view->archive['p'] = $p;
             $case->view->archive['n'] = $n;
             $case->view->archive['p']['url'] = archive::url($p);
             $case->view->archive['n']['url'] = archive::url($n);
             
             //评级
             $case->view->archive['strgrade'] = archive::getgrade($arc['grade']);
             
             //图片
             $case->view->archive['pics'] = unserialize($case->view->archive['pics']);
             if(is_array($case->view->archive['pics']) && !empty($case->view->archive['pics'])){
             	foreach ($case->view->archive['pics'] as $k => $v){
             		if(strtolower(substr($v,0,7)) == 'http://'){
             			$case->view->archive['pics'][$k] = $v;
             		}else{
             			$case->view->archive['pics'][$k] = $v;
             		}
             	}
             }
             $case->view->archive['pics'] = serialize($case->view->archive['pics']);
             
             if ($template && file_exists(TEMPLATE . '/' . $case->view->_style . '/' . $template))
                 $tpl = $template;
             else
                 $tpl = category::gettemplate($case->view->catid, 'showtemplate');
             $content = $case->fetch($tpl);
             $path = ROOT . archive::url($case->view->archive, front::$get['page'] > 1 ? front::$get['page'] : null, true);
             if (!preg_match('/\.[a-zA-Z]+$/', $path))
                 $path = rtrim(rtrim($path, '/'), '\\') . '/index.html';
             $path = rtrim($path, '/');
             $path = rtrim($path, '\\');
             $path = str_replace('//', '/', $path);
             tool::mkdir(dirname($path));
             file_put_contents($path, $content);
             $cpage++;
             if ($case->view->pages > 1 && $c == 1) {
                 $path = ROOT . archive::url($case->view->archive, 1, true);
                 if (!preg_match('/\.[a-zA-Z]+$/', $path))
                     $path = rtrim(rtrim($path, '/'), '\\') . '/index.html';
                 $path = rtrim($path, '/');
                 $path = rtrim($path, '\\');
                 $path = str_replace('//', '/', $path);
                 tool::mkdir(dirname($path));
                 //file_put_contents('logs.txt', file_get_contents('logs.txt')."\r\n".$path);
                 $f = fopen($path,'w');
                 fwrite($f, $content);
                 fclose($f);
                 $cpage++;
             }
         }
     }
     $totalpage = count($archives);
     if (!isset($archives[0]))
         $totalpage = 0;
     if ($make_page >= $make_page_num) {
         $show_msg = "本组生成html <b>{$cpage}</b> 页!  生成html完毕,本次共生成 <b>{$archive_num}</b> 页! 3秒后自动返回内容生成首页面!\n";
         $c_url = preg_replace('#&make_page=(\d+)#', '', $_SERVER['QUERY_STRING']);
         $c_url = preg_replace('#&aid_start=(\d+)#', '', $c_url);
         $c_url = preg_replace('#&aid_end=(\d+)#', '', $c_url);
         $c_url = preg_replace('#&catid=(\d+)#', '', $c_url);
         $c_url = preg_replace('#&submit=(\d+)#', '', $c_url);
         $c_url = 'index.php?' . $c_url;
     } else {
         $show_msg = "第 <b>{$make_page}</b> 组成功生成html <b>{$cpage}</b> 页! 本次共需生成 <b>{$archive_num}</b> 页! 已经生成 <b>" . ($make_page * $group_count) . "</b> 页! 3秒后自动跳入下组生成!\n";
     }
     $getnexturl = "<script>";
     $getnexturl.="var t=4;\n";
     $getnexturl.="setInterval('testTime()',3000);\n";
     $getnexturl.="function testTime() \n";
     $getnexturl.=" { \n";
     $getnexturl.="if(t == 0) location = '" . $c_url . "'; \n";
     $getnexturl.=" t--;\n";
     $getnexturl.="}\n</script> \n";
     if ($cpage > 0) {
         if (!config::get('group_on')) {
             front::flash("成功生成html <b>{$cpage}</b> 页!用时".time::getTime()."!\n");
         } else {
             front::flash($show_msg . "\n" . $getnexturl);
         }
     } else {
         front::flash("没有需要生成的html,可能您选择的栏目暂无内容或者网站并未开启内容生成静态功能!");
     }
     front::$admin = true;
     front::$post = $post;
 }
Esempio n. 8
0
 /**
  * Genera el asiento contable para una factura de venta.
  * Devuelve TRUE si el asiento se ha generado correctamente, False en caso contrario.
  * Si genera el asiento, este es accesible desde $this->asiento.
  * @param type $factura
  */
 public function generar_asiento_venta(&$factura)
 {
     $ok = FALSE;
     $this->asiento = FALSE;
     $cliente0 = new cliente();
     $subcuenta_cli = FALSE;
     /// obtenemos las tasas de conversión, para las ocasiones en que la factura está en otra divisa
     $tasaconv = 1;
     $tasaconv2 = $factura->tasaconv;
     if ($factura->coddivisa != $this->empresa->coddivisa) {
         $div0 = new divisa();
         $divisa = $div0->get($this->empresa->coddivisa);
         if ($divisa) {
             $tasaconv = $divisa->tasaconv / $factura->tasaconv;
             $tasaconv2 = $divisa->tasaconv_compra;
         }
     }
     /// obtenemos el clientes y su subcuenta
     $cliente = $cliente0->get($factura->codcliente);
     if ($cliente) {
         $subcuenta_cli = $cliente->get_subcuenta($factura->codejercicio);
     }
     if (!$subcuenta_cli) {
         $eje0 = $this->ejercicio->get($factura->codejercicio);
         $this->new_message("No se ha podido generar una subcuenta para el cliente\n            <a href='" . $eje0->url() . "'>¿Has importado los datos del ejercicio?</a>");
         if (!$this->soloasiento) {
             $this->new_message("Aun así la <a href='" . $factura->url() . "'>factura</a> se ha generado correctamente,\n            pero sin asiento contable.");
         }
     } else {
         $asiento = new asiento();
         $asiento->codejercicio = $factura->codejercicio;
         if ($factura->idfacturarect) {
             $asiento->concepto = ucfirst(FS_FACTURA_RECTIFICATIVA) . " de " . $factura->codigo . " (ventas) - " . $factura->nombrecliente;
         } else {
             $asiento->concepto = "Factura de venta " . $factura->codigo . " - " . $factura->nombrecliente;
         }
         $asiento->documento = $factura->codigo;
         $asiento->editable = FALSE;
         $asiento->fecha = $factura->fecha;
         $asiento->importe = abs($factura->total * $tasaconv);
         $asiento->tipodocumento = 'Factura de cliente';
         if ($asiento->save()) {
             $asiento_correcto = TRUE;
             $subcuenta = new subcuenta();
             $partida0 = new partida();
             $partida0->idasiento = $asiento->idasiento;
             $partida0->concepto = $asiento->concepto;
             $partida0->idsubcuenta = $subcuenta_cli->idsubcuenta;
             $partida0->codsubcuenta = $subcuenta_cli->codsubcuenta;
             $partida0->debe = $factura->total * $tasaconv;
             $partida0->coddivisa = $this->empresa->coddivisa;
             $partida0->tasaconv = $tasaconv2;
             $partida0->codserie = $factura->codserie;
             if (!$partida0->save()) {
                 $asiento_correcto = FALSE;
                 $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida0->codsubcuenta . "!");
             }
             /// generamos una partida por cada impuesto
             foreach ($factura->get_lineas_iva() as $li) {
                 $subcuenta_iva = FALSE;
                 /// ¿El impuesto tiene una subcuenta específica?
                 if (isset($this->impuestos[$li->codimpuesto])) {
                     if ($this->impuestos[$li->codimpuesto]->codsubcuentarep) {
                         $subcuenta_iva = $subcuenta->get_by_codigo($this->impuestos[$li->codimpuesto]->codsubcuentarep, $asiento->codejercicio);
                     }
                 }
                 if (!$subcuenta_iva) {
                     $subcuenta_iva = $subcuenta->get_cuentaesp('IVAREP', $asiento->codejercicio);
                 }
                 if ($subcuenta_iva and $asiento_correcto) {
                     $partida1 = new partida();
                     $partida1->idasiento = $asiento->idasiento;
                     $partida1->concepto = $asiento->concepto;
                     $partida1->idsubcuenta = $subcuenta_iva->idsubcuenta;
                     $partida1->codsubcuenta = $subcuenta_iva->codsubcuenta;
                     $partida1->haber = $li->totaliva * $tasaconv;
                     $partida1->idcontrapartida = $subcuenta_cli->idsubcuenta;
                     $partida1->codcontrapartida = $subcuenta_cli->codsubcuenta;
                     $partida1->cifnif = $cliente->cifnif;
                     $partida1->documento = $asiento->documento;
                     $partida1->tipodocumento = $asiento->tipodocumento;
                     $partida1->codserie = $factura->codserie;
                     $partida1->factura = $factura->numero;
                     $partida1->baseimponible = $li->neto * $tasaconv;
                     $partida1->iva = $li->iva;
                     $partida1->coddivisa = $this->empresa->coddivisa;
                     $partida1->tasaconv = $tasaconv2;
                     if (!$partida1->save()) {
                         $asiento_correcto = FALSE;
                         $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida1->codsubcuenta . "!");
                     }
                     if ($li->recargo != 0) {
                         $partida11 = new partida();
                         $partida11->idasiento = $asiento->idasiento;
                         $partida11->concepto = $asiento->concepto;
                         $partida11->idsubcuenta = $subcuenta_iva->idsubcuenta;
                         $partida11->codsubcuenta = $subcuenta_iva->codsubcuenta;
                         $partida11->haber = $li->totalrecargo * $tasaconv;
                         $partida11->idcontrapartida = $subcuenta_cli->idsubcuenta;
                         $partida11->codcontrapartida = $subcuenta_cli->codsubcuenta;
                         $partida11->cifnif = $cliente->cifnif;
                         $partida11->documento = $asiento->documento;
                         $partida11->tipodocumento = $asiento->tipodocumento;
                         $partida11->codserie = $factura->codserie;
                         $partida11->factura = $factura->numero;
                         $partida11->baseimponible = $li->neto * $tasaconv;
                         $partida11->recargo = $li->recargo;
                         $partida11->coddivisa = $this->empresa->coddivisa;
                         $partida11->tasaconv = $tasaconv2;
                         if (!$partida11->save()) {
                             $asiento_correcto = FALSE;
                             $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida11->codsubcuenta . "!");
                         }
                     }
                 } else {
                     if (!$subcuenta_iva) {
                         $asiento_correcto = FALSE;
                         $this->new_error_msg('No se encuentra la subcuenta de ' . FS_IVA);
                     }
                 }
             }
             $subcuenta_ventas = $subcuenta->get_cuentaesp('VENTAS', $asiento->codejercicio);
             if ($subcuenta_ventas and $asiento_correcto) {
                 $partida2 = new partida();
                 $partida2->idasiento = $asiento->idasiento;
                 $partida2->concepto = $asiento->concepto;
                 $partida2->idsubcuenta = $subcuenta_ventas->idsubcuenta;
                 $partida2->codsubcuenta = $subcuenta_ventas->codsubcuenta;
                 $partida2->haber = $factura->neto * $tasaconv;
                 $partida2->coddivisa = $this->empresa->coddivisa;
                 $partida2->tasaconv = $tasaconv2;
                 $partida2->codserie = $factura->codserie;
                 if (!$partida2->save()) {
                     $asiento_correcto = FALSE;
                     $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida2->codsubcuenta . "!");
                 }
             } else {
                 if (!$subcuenta_ventas) {
                     $asiento_correcto = FALSE;
                     $this->new_error_msg('No se encuentra la subcuenta de ventas');
                 }
             }
             /// ¿IRPF?
             if ($factura->totalirpf != 0 and $asiento_correcto) {
                 $subcuenta_irpf = $subcuenta->get_cuentaesp('IRPF', $asiento->codejercicio);
                 if (!$subcuenta_irpf) {
                     $subcuenta_irpf = $subcuenta->get_by_codigo('4730000000', $asiento->codejercicio);
                 }
                 if ($subcuenta_irpf) {
                     $partida3 = new partida();
                     $partida3->idasiento = $asiento->idasiento;
                     $partida3->concepto = $asiento->concepto;
                     $partida3->idsubcuenta = $subcuenta_irpf->idsubcuenta;
                     $partida3->codsubcuenta = $subcuenta_irpf->codsubcuenta;
                     $partida3->debe = $factura->totalirpf * $tasaconv;
                     $partida3->coddivisa = $this->empresa->coddivisa;
                     $partida3->tasaconv = $tasaconv2;
                     $partida3->codserie = $factura->codserie;
                     if (!$partida3->save()) {
                         $asiento_correcto = FALSE;
                         $this->new_error_msg("¡Imposible generar la partida para la subcuenta " . $partida3->codsubcuenta . "!");
                     }
                 } else {
                     if (!$subcuenta_irpf) {
                         $asiento_correcto = FALSE;
                         $this->new_error_msg('No se encuentra la subcuenta de ' . FS_IRPF);
                     }
                 }
             }
             /// comprobamos si algún artículo tiene una subcuenta asociada
             if ($asiento_correcto) {
                 $partidaA = new partida();
                 $partidaA->idasiento = $asiento->idasiento;
                 $partidaA->concepto = $asiento->concepto;
                 $partidaA->coddivisa = $this->empresa->coddivisa;
                 $partidaA->tasaconv = $tasaconv2;
                 /// importe a restar a la partida2
                 $restar = 0;
                 /**
                  * Para cada artículo de la factura, buscamos su subcuenta de compra o compra con irpf
                  */
                 $ap = new articulo_propiedad();
                 foreach ($factura->get_lineas() as $lin) {
                     $subcart = FALSE;
                     $aprops = $ap->array_get($lin->referencia);
                     if (isset($aprops['codsubcuentaventa'])) {
                         $subcart = $subcuenta->get_by_codigo($aprops['codsubcuentaventa'], $factura->codejercicio);
                     }
                     if (!$subcart) {
                         /// no hay / no se encuentra ninguna subcuenta asignada al artículo
                     } else {
                         if ($subcart->idsubcuenta != $subcuenta_ventas->idsubcuenta) {
                             if (is_null($partidaA->idsubcuenta)) {
                                 $partidaA->idsubcuenta = $subcart->idsubcuenta;
                                 $partidaA->codsubcuenta = $subcart->codsubcuenta;
                                 $partidaA->haber = $lin->pvptotal * $tasaconv;
                             } else {
                                 if ($partidaA->idsubcuenta == $subcart->idsubcuenta) {
                                     $partidaA->haber += $lin->pvptotal * $tasaconv;
                                 } else {
                                     $partidaA->haber = round($partidaA->haber, FS_NF0);
                                     $restar += $partidaA->haber;
                                     if (!$partidaA->save()) {
                                         $asiento_correcto = FALSE;
                                         $this->new_error_msg("¡Imposible generar la partida para la subcuenta del artículo " . $lin->referencia . "!");
                                     }
                                     $partidaA = new partida();
                                     $partidaA->idasiento = $asiento->idasiento;
                                     $partidaA->concepto = $asiento->concepto;
                                     $partidaA->idsubcuenta = $subcart->idsubcuenta;
                                     $partidaA->codsubcuenta = $subcart->codsubcuenta;
                                     $partidaA->haber = $lin->pvptotal * $tasaconv;
                                     $partidaA->coddivisa = $this->empresa->coddivisa;
                                     $partidaA->tasaconv = $tasaconv2;
                                 }
                             }
                         }
                     }
                 }
                 if ($partidaA->idsubcuenta and $partidaA->codsubcuenta) {
                     $partidaA->haber = round($partidaA->haber, FS_NF0);
                     $restar += $partidaA->haber;
                     if ($partidaA->save()) {
                         $partida2->haber -= $restar;
                         $partida2->save();
                     } else {
                         $asiento_correcto = FALSE;
                         $this->new_error_msg("¡Imposible generar la partida para la subcuenta del artículo " . $lin->referencia . "!");
                     }
                 }
             }
             if ($asiento_correcto) {
                 /// si es una factura rectificativa, invertimos los importes
                 if ($factura->idfacturarect) {
                     $this->invertir_asiento($asiento);
                 }
                 $factura->idasiento = $asiento->idasiento;
                 if ($factura->save()) {
                     $ok = $this->check_asiento($asiento);
                     if (!$ok) {
                         $this->new_error_msg('El asiento está descuadrado.');
                     }
                     $this->asiento = $asiento;
                 } else {
                     $this->new_error_msg("¡Imposible añadir el asiento a la factura!");
                 }
             } else {
                 if ($asiento->delete()) {
                     $this->new_message("El asiento se ha borrado.");
                 } else {
                     $this->new_error_msg("¡Imposible borrar el asiento!");
                 }
             }
         } else {
             $this->new_error_msg("¡Imposible guardar el asiento!");
         }
     }
     return $ok;
 }
    <?php 
    } else {
        ?>
    <a href="<?php 
        echo type::url($typeid, $p);
        ?>
"><?php 
        echo $p;
        ?>
</a>
    <?php 
    }
    ?>

    <?php 
}
?>
    <?php 
if (pages('down')) {
    ?>
    <a href="<?php 
    echo type::url($typeid, pages('down'));
    ?>
"><?php 
    echo lang(downpage);
    ?>
</a>
    <?php 
}
?>
</div>
 /**
  * Devuelve la URL de esta página (index.php?page=LO-QUE-SEA)
  * @return type
  */
 public function url()
 {
     return $this->page->url();
 }
Esempio n. 11
0
 static function listdata($parentid=0,$limit=10,$order='typeid asc',$where=null,$includeson=true) {
     $type=new type();
     $where='parentid='.($parentid?$parentid:'0').($where ?' and '.$where : '');
     $types=$type->getrows($where,$limit,$order);
     foreach ($types as $order=>$type) {
         $types[$order]['url']=type::url($type['typeid']);
     }
     return $types;
 }