svn+ssh://danydb@svn/svn/phpcompta/branches/rel560 ........ r4147 | danydb | 2011-05-31 21:27:49 +0200 (Tue, 31 May 2011) | 2 lines revoke from ... cause problem on MAC ........ r4148 | danydb | 2011-05-31 23:36:28 +0200 (Tue, 31 May 2011) | 1 line better error message with database::get_value ........ r4149 | danydb | 2011-06-01 02:12:08 +0200 (Wed, 01 Jun 2011) | 1 line Ajax disconnected ........ r4150 | danydb | 2011-06-01 23:44:53 +0200 (Wed, 01 Jun 2011) | 1 line update SQL script ........ r4151 | danydb | 2011-06-01 23:46:25 +0200 (Wed, 01 Jun 2011) | 2 lines update database version ........ r4152 | danydb | 2011-06-04 12:39:20 +0200 (Sat, 04 Jun 2011) | 1 line 0000281: Ajax : déconnecté ........ r4153 | danydb | 2011-06-04 12:40:37 +0200 (Sat, 04 Jun 2011) | 1 line Better error message ........ r4154 | danydb | 2011-06-04 12:41:30 +0200 (Sat, 04 Jun 2011) | 1 line Bug for MacOSX ........ r4155 | danydb | 2011-06-04 12:58:06 +0200 (Sat, 04 Jun 2011) | 1 line remove debug info ........ r4156 | danydb | 2011-06-04 16:24:57 +0200 (Sat, 04 Jun 2011) | 2 lines Fix bug with debug flag ........ r4157 | danydb | 2011-06-04 16:25:44 +0200 (Sat, 04 Jun 2011) | 1 line remove debug ........ r4158 | danydb | 2011-06-06 21:30:08 +0200 (Mon, 06 Jun 2011) | 2 lines Alert : show the missing accounting ........ r4159 | danydb | 2011-06-06 23:30:08 +0200 (Mon, 06 Jun 2011) | 2 lines bug fixed : settype transform SQL NULL into 0 ........ r4160 | danydb | 2011-06-07 23:24:54 +0200 (Tue, 07 Jun 2011) | 2 lines 0000283: Compte contrepartie ........
179 lines
5.2 KiB
PHP
179 lines
5.2 KiB
PHP
<?php
|
|
/*
|
|
* This file is part of PhpCompta.
|
|
*
|
|
* PhpCompta is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* PhpCompta is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with PhpCompta; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
/* $Revision$ */
|
|
|
|
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
|
|
|
/*!\file
|
|
* \brief this file answer to the Ajax request from js/accounting_item.js
|
|
* - op
|
|
- sf show form of search
|
|
- param j : ledger -> php jrn
|
|
- param c : control for storing the pcm_val -> javascript account
|
|
- param l : control for storing the pcm_lib -> javascript label
|
|
- param ctl : the node to update (ipopup)
|
|
- param q : the acc_query -> javascript query
|
|
* - ctl (to return)
|
|
*
|
|
*
|
|
*/
|
|
require_once ("ac_common.php");
|
|
require_once('class_acc_ledger.php');
|
|
require_once ('class_database.php');
|
|
require_once('function_javascript.php');
|
|
require_once('class_acc_account_ledger.php');
|
|
|
|
extract($_REQUEST);
|
|
$var=array('gDossier','op','ctl');
|
|
$cont=0;
|
|
/* check if mandatory parameters are given */
|
|
foreach ($var as $v)
|
|
{
|
|
if ( ! isset ($_REQUEST [$v] ) )
|
|
{
|
|
echo "$v is not set ";
|
|
$cont=1;
|
|
}
|
|
}
|
|
ajax_disconnected($ctl);
|
|
|
|
set_language();
|
|
|
|
if ( $cont != 0 ) exit();
|
|
$cn=new Database(dossier::id());
|
|
include_once ("class_user.php");
|
|
$User=new User($cn);
|
|
$User->Check();
|
|
if ($User->get_ledger_access(dossier::id()) == 'X') exit();
|
|
$xml="";
|
|
|
|
switch ($op)
|
|
{
|
|
/*----------------------------------------------------------------------
|
|
* Show the form and the result
|
|
*
|
|
----------------------------------------------------------------------*/
|
|
case "sf":
|
|
$ipopup=$ctl;
|
|
$attr=sprintf('this.ctl=\'%s\';',$ipopup);
|
|
$ctl.='_content';
|
|
$it=new IText('acc_query');
|
|
$it->size=30;
|
|
$it->value=(isset($q))?$q:'';
|
|
$str_poste=$it->input();
|
|
$str_submit=HtmlInput::submit('sf',_('Recherche'));
|
|
$r='';
|
|
$r.='<div style="float:right;height:10px;display:block;margin-top:2px;margin-right:2px">';
|
|
$r.= '<A style="background-color:blue;color:white;text-decoration:none" HREF="javascript:void(0)" onclick="removeDiv(\'search_account\');">Fermer</A>';
|
|
$r.='</div>';
|
|
$r.='<div> '.h2info(_('Poste Comptable')).'</div>';
|
|
|
|
$r.='<form id="sp" method="get" onsubmit="'.$attr.'search_get_poste(this);return false;">';
|
|
ob_start();
|
|
require_once('template/account_search.php');
|
|
$r.=ob_get_contents();
|
|
ob_clean();
|
|
$r.=dossier::hidden();
|
|
$r.=(isset ($c))?HtmlInput::hidden('account',$c):"";
|
|
$r.=(isset ($l))?HtmlInput::hidden('label',$l):"";
|
|
$r.=(isset ($j))?HtmlInput::hidden('jrn',$j):"";
|
|
$r.=(isset ($nover))?HtmlInput::hidden('nover','1'):"";
|
|
$r.=(isset ($nosearch))?HtmlInput::hidden('nosearch','1'):"";
|
|
$r.=(isset ($bracket))?HtmlInput::hidden('bracket','1'):"";
|
|
|
|
|
|
$r.='</form>';
|
|
$sql="select pcm_val,pcm_lib,pcm_val_parent,pcm_type ".
|
|
" from tmp_pcmn ";
|
|
$sep=" where ";
|
|
/* build the sql stmt */
|
|
if ( isset($j) && $j > 0 && isNumber($j))
|
|
{
|
|
/* create a filter on the ledger */
|
|
$ledger=new Acc_Account_Ledger($cn,0);
|
|
$fd_id=$ledger->build_sql_account($j);
|
|
if ( $fd_id != '' )
|
|
{
|
|
$sql.=" $sep (".$fd_id.')';
|
|
$sep=" and ";
|
|
}
|
|
}
|
|
/* show result */
|
|
if ( isset($q) && strlen(trim($q)) > 0)
|
|
{
|
|
$q=sql_string($q);
|
|
$sql.=sprintf(" $sep ( pcm_val::text like '%s%%' or pcm_lib::text ilike '%%%s%%') ",
|
|
$q,$q);
|
|
}
|
|
$sql.=' order by pcm_val::text limit 50';
|
|
if ( isset($q) && strlen(trim($q))> 0 )
|
|
{
|
|
$array=$cn->get_array($sql);
|
|
}
|
|
if ( ! isset($q) ) $array=array();
|
|
if ( isset($q) && strlen(trim($q))==0) $array=array();
|
|
|
|
/* set the javascript */
|
|
for ($i=0;$i<count($array);$i++)
|
|
{
|
|
$pcm_val=$array[$i]['pcm_val'];
|
|
if ( isset($bracket))
|
|
{
|
|
$pcm_val='['.$pcm_val.']';
|
|
}
|
|
if (isset($nover))
|
|
{
|
|
/* no overwrite */
|
|
$str=sprintf("$('%s').value=$('%s').value+' '+'%s';",
|
|
$c,$c,$pcm_val);
|
|
|
|
}
|
|
else
|
|
{
|
|
$str=sprintf("$('%s').value='%s';",
|
|
$c,$pcm_val);
|
|
}
|
|
|
|
if ( isset($l) )
|
|
{
|
|
$str.=sprintf("set_value('%s',g('%s').innerHTML);",
|
|
$l,"lib$i");
|
|
|
|
}
|
|
$str.="removeDiv('search_account');";
|
|
$array[$i]['javascript']=$str;
|
|
}
|
|
ob_start();
|
|
|
|
require_once('template/account_result.php');
|
|
$r.=ob_get_contents();
|
|
ob_clean();
|
|
|
|
$html=$r;
|
|
break;
|
|
}
|
|
$html=escape_xml($html);
|
|
header('Content-type: text/xml; charset=UTF-8');
|
|
echo <<<EOF
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<data>
|
|
<ctl>$ctl</ctl>
|
|
<code>$html</code>
|
|
</data>
|
|
EOF;
|