From 0e5fcddfc199d3408bac83caadec2b99b0327a5c Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 14 Sep 2010 15:27:31 +0000 Subject: [PATCH] Reformat the code with - astyle --style=ansi Broke : the <<<Check(); -if ( $user->check_dossier(dossier::id()) == 'P') { - redirect("extension.php?".dossier::get(),0); - exit(); +if ( $user->check_dossier(dossier::id()) == 'P') +{ + redirect("extension.php?".dossier::get(),0); + exit(); } html_page_start($_SESSION['g_theme']); @@ -50,42 +51,46 @@ load_all_script(); /* Check Browser version if < IE6 then unsupported */ $browser=$_SERVER['HTTP_USER_AGENT']; if ( strpos($browser,'MSIE 6')!=false || - strpos($browser,'MSIE 5')!=false ) { + strpos($browser,'MSIE 5')!=false ) +{ -echo << -
-
Close this notice
-
-
Warning!
-
-
Vous utilisez un navigateur dépassé depuis près de 8 ans!
-
Pour une meilleure expérience web, prenez le temps de mettre votre navigateur à jour.
-
-
Get Firefox 3.5
-
Get Safari 4
-
Get Google Chrome
-
-
- +
+
Close this notice
+
+
Warning!
+
+
Vous utilisez un navigateur dépassé depuis près de 8 ans!
+
Pour une meilleure expérience web, prenez le temps de mettre votre navigateur à jour.
+
+
Get Firefox 3.5
+
Get Safari 4
+
Get Google Chrome
+
+
+ EOF; exit(); } -if ( $cn->exist_table('version') == false ) { - echo '

'._("Base de donnée invalide").'

'; - $base=dirname($_SERVER['REQUEST_URI']); - echo HtmlInput::button_anchor('Retour',$base.'/user_login.php'); - exit(); +if ( $cn->exist_table('version') == false ) +{ + echo '

'._("Base de donnée invalide").'

'; + $base=dirname($_SERVER['REQUEST_URI']); + echo HtmlInput::button_anchor('Retour',$base.'/user_login.php'); + exit(); } -if ( DBVERSION < dossier::get_version($cn)) { - echo '

'._("Attention: la version de base de donnée est supérieure à la version du programme, vous devriez mettre à jour").'

'; - } -if ( DBVERSION > dossier::get_version($cn)) { - echo '

'._("Votre base de données n'est pas à jour").' '; - $a=_("cliquez ici pour appliquer le patch"); - $base=dirname($_SERVER['REQUEST_URI']).'/admin/setup.php'; - echo ''.$a.'

'; +if ( DBVERSION < dossier::get_version($cn)) +{ + echo '

'._("Attention: la version de base de donnée est supérieure à la version du programme, vous devriez mettre à jour").'

'; +} +if ( DBVERSION > dossier::get_version($cn)) +{ + echo '

'._("Votre base de données n'est pas à jour").' '; + $a=_("cliquez ici pour appliquer le patch"); + $base=dirname($_SERVER['REQUEST_URI']).'/admin/setup.php'; + echo ''.$a.'

'; } echo '
'; diff --git a/html/admin_repo.php b/html/admin_repo.php index a20992ec6..b6322e00a 100644 --- a/html/admin_repo.php +++ b/html/admin_repo.php @@ -34,9 +34,10 @@ $User->Check(); html_page_start($User->theme); -if ($User->admin != 1) { - html_page_stop(); - return; +if ($User->admin != 1) +{ + html_page_stop(); + return; } echo '

Administration Globale

'; @@ -50,33 +51,35 @@ echo MenuAdmin()."
"; ?>
diff --git a/html/ajax.php b/html/ajax.php index 3d2142118..4ea7f7045 100644 --- a/html/ajax.php +++ b/html/ajax.php @@ -17,21 +17,28 @@ $user=new User($cn); $user->check(true); /* if a code has been asked */ -if (isset($_REQUEST['plugin_code']) ) { +if (isset($_REQUEST['plugin_code']) ) +{ - $ext=new Extension($cn); - $ext->search('code',$_REQUEST['plugin_code']); - if ( $ext->get_parameter('id') != 0 ) { - /* security */ - if ( !isset ($_SESSION['g_user']) || $ext->can_request($_SESSION['g_user']) == 0 ) { - exit(); + $ext=new Extension($cn); + $ext->search('code',$_REQUEST['plugin_code']); + if ( $ext->get_parameter('id') != 0 ) + { + /* security */ + if ( !isset ($_SESSION['g_user']) || $ext->can_request($_SESSION['g_user']) == 0 ) + { + exit(); + } + /* call the ajax script */ + require_once('ext'.DIRECTORY_SEPARATOR.dirname(trim($ext->get_parameter('filepath'))).DIRECTORY_SEPARATOR.'ajax.php'); + } + else + { + alert(j(_("Cette extension n'existe pas "))); + exit(); } - /* call the ajax script */ - require_once('ext'.DIRECTORY_SEPARATOR.dirname(trim($ext->get_parameter('filepath'))).DIRECTORY_SEPARATOR.'ajax.php'); - } else { - alert(j(_("Cette extension n'existe pas "))); - exit(); - } } +?> +?> ?> \ No newline at end of file diff --git a/html/ajax_card.php b/html/ajax_card.php index 89f0e9388..8dbbae236 100644 --- a/html/ajax_card.php +++ b/html/ajax_card.php @@ -64,320 +64,350 @@ require_once ('class_fiche_attr.php'); $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; - } +foreach ($var as $v) +{ + if ( ! isset ($_REQUEST [$v] ) ) + { + echo "$v is not set "; + $cont=1; + } } if ( $cont != 0 ) exit(); extract($_REQUEST ); set_language(); $cn=new Database($gDossier); -$user=new User($cn); $user->check(true);$user->check_dossier($gDossier,true); +$user=new User($cn); +$user->check(true); +$user->check_dossier($gDossier,true); $html=var_export($_REQUEST,true); -switch($op) { - /* ------------------------------------------------------------ */ - /* Remove a attribut */ - /* ------------------------------------------------------------ */ +switch($op) +{ + /* ------------------------------------------------------------ */ + /* Remove a attribut */ + /* ------------------------------------------------------------ */ case 'rmfa': - ob_start(); - if( ! isset($_GET['ad_id']) || isNumber($_GET['ad_id']) ==0) - throw new Exception ( "Parametre ad_id est invalide",11); - $ad_id= $_GET['ad_id']; - try { - $cn->start(); - $fa=new Fiche_Attr($cn,$ad_id); - $fa->delete(); - $cn->commit(); - } catch (Exception $e) { - $cn->rollback(); - echo $e->getMessage(); - } - $html=ob_get_contents(); - ob_clean(); - break; - /* ------------------------------------------------------------ */ - /* Display card detail */ - /* ------------------------------------------------------------ */ + ob_start(); + if( ! isset($_GET['ad_id']) || isNumber($_GET['ad_id']) ==0) + throw new Exception ( "Parametre ad_id est invalide",11); + $ad_id= $_GET['ad_id']; + try + { + $cn->start(); + $fa=new Fiche_Attr($cn,$ad_id); + $fa->delete(); + $cn->commit(); + } + catch (Exception $e) + { + $cn->rollback(); + echo $e->getMessage(); + } + $html=ob_get_contents(); + ob_clean(); + break; + /* ------------------------------------------------------------ */ + /* Display card detail */ + /* ------------------------------------------------------------ */ case 'dc': - $f=new Fiche($cn); - if ( $qcode != '') - { - $f->get_by_qcode($qcode); - $html=$f->Display(true); - } - else - $html=h2info('Aucune fiche demandée'); - break; - /* ------------------------------------------------------------ */ - /* Blank card */ - /* ------------------------------------------------------------ */ -case 'bc': - if ( $user->check_action(FICADD)==1 ) { - $r=''; $f=new Fiche($cn); - $popup=str_replace('_content','',$ctl); - $r.='
'; - $r.=dossier::hidden(); - $r.=(isset($ref))?HtmlInput::hidden('ref',1):''; - $r.=HtmlInput::hidden('fd_id',$fd_id); - $r.=HtmlInput::hidden('ctl',$ctl); - $r.=$f->blank($fd_id); - $r.=HtmlInput::submit('sc','Sauve'); - $r.='
'; - $html=$r; - } else { - $html=alert(_('Action interdite'),true); - } - break; - /* ------------------------------------------------------------ */ - /* Show Type */ - /* Before inserting a new card, the type must be selected */ - /* ------------------------------------------------------------ */ -case 'st': - $sql="select fd_id,fd_label from fiche_def"; - /* if we filter thanks the ledger*/ - if ( $ledger != -1 ) + if ( $qcode != '') { - /* we want the card for deb or cred or both of this ledger */ - switch( $fil ) - { - case -1: - $l=new Acc_Ledger($cn,$ledger); - $sql.=' where fd_id in ('.$l->get_all_fiche_def().')'; - break; - case 'cred': - $l=new Acc_Ledger($cn,$ledger); - $prop=$l->get_propertie(); - if ( $prop['jrn_def_fiche_cred']=='')$prop=-1; - $sql.=' where fd_id in ('.$prop['jrn_def_fiche_cred'].')'; - break; - case 'deb': - $l=new Acc_Ledger($cn,$ledger); - $prop=$l->get_propertie(); - if ( $prop=='')$prop=-1; - $sql.=' where fd_id in ('.$prop['jrn_def_fiche_deb'].')'; - break; - } - } - else - { - /* we filter thanks a given model of card */ - if ( isset($cat)) { - $sql=$sql.sprintf(' where frd_id = '.FormatString ($cat)); - } - else - /* we filter thanks a given list of category of card - */ - if ( isset($fil) && strlen(trim($fil)) > 0 ){ - $sql=$sql.sprintf(" where fd_id in (%s)", - FormatString($fil)); - } + $f->get_by_qcode($qcode); + $html=$f->Display(true); } - $array=$cn->make_array($sql); - if ( empty($array)) { - $html=_("Aucune catégorie de fiche ne correspondant à". - " votre demande"); - $html.=$sql; - } else { - $r=''; - $isel=new ISelect('fd_id'); - $isel->value=$array; - $popup=str_replace('_content','',$ctl); - $r.='
'; - $r.=dossier::hidden(); - $r.=(isset($ref))?HtmlInput::hidden('ref',1):''; - $r.='

choisissez le type de fiche à ajouter

'; - $r.=$isel->input(); - $r.=HtmlInput::submit('st','choix'); - $r.='
'; - $html=$r; - } - break; - /*---------------------------------------------------------------------- - * SC save card - * save the new card (insert) - * - ----------------------------------------------------------------------*/ -case 'sc': - if ( $user->check_action(FICADD)==1 ) { - $f=new Fiche($cn); - $f->insert($fd_id,$_POST); - $html='

Fiche sauvée

'; - $html.=$f->Display(true); - $js=""; - if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); - $html.=$js; - } else { - $html=alert(_('Action interdite'),true); - } + else + $html=h2info('Aucune fiche demandée'); break; - /*---------------------------------------------------------------------- - * Search a card - * - *----------------------------------------------------------------------*/ -case 'fs': - require_once('class_acc_ledger.php'); - $r=''; - $r.='
'; - $q=new IText('query'); - $q->value=(isset($query))?$query:''; - $r.=_('Fiche contenant'); - $r.=$q->input(); - $r.=HtmlInput::submit('fs',_('Recherche')); - $r.=dossier::hidden().HtmlInput::hidden('op','fs'); - $array=array(); - foreach (array('query','inp','jrn','label','typecard','price','tvaid') as $i) { - if (isset(${$i}) ){ - $r.=HtmlInput::hidden($i,${$i}); - $sql_array[$i]=${$i}; + /* ------------------------------------------------------------ */ + /* Blank card */ + /* ------------------------------------------------------------ */ +case 'bc': + if ( $user->check_action(FICADD)==1 ) + { + $r=''; + $f=new Fiche($cn); + $popup=str_replace('_content','',$ctl); + $r.=''; + $r.=dossier::hidden(); + $r.=(isset($ref))?HtmlInput::hidden('ref',1):''; + $r.=HtmlInput::hidden('fd_id',$fd_id); + $r.=HtmlInput::hidden('ctl',$ctl); + $r.=$f->blank($fd_id); + $r.=HtmlInput::submit('sc','Sauve'); + $r.='
'; + $html=$r; } - } - /* what is the type of the ledger */ - $type="GL"; - if (isset($jrn) && $jrn > 1) { - $ledger=new Acc_Ledger($cn,$jrn); - $type=$ledger->get_type(); - } - $fiche=new Fiche($cn); - /* Build the SQL and show result */ - $sql=$fiche->build_sql($sql_array); - - /* We limit the search to 20 records */ - $sql=$sql.' order by vw_name limit 20'; - $a=$cn->get_array($sql); - - for($i=0;$icheck_action(FICCAT)==1 ) { - + else + { + $html=alert(_('Action interdite'),true); + } + break; + /* ------------------------------------------------------------ */ + /* Show Type */ + /* Before inserting a new card, the type must be selected */ + /* ------------------------------------------------------------ */ +case 'st': + $sql="select fd_id,fd_label from fiche_def"; + /* if we filter thanks the ledger*/ + if ( $ledger != -1 ) + { + /* we want the card for deb or cred or both of this ledger */ + switch( $fil ) + { + case -1: + $l=new Acc_Ledger($cn,$ledger); + $sql.=' where fd_id in ('.$l->get_all_fiche_def().')'; + break; + case 'cred': + $l=new Acc_Ledger($cn,$ledger); + $prop=$l->get_propertie(); + if ( $prop['jrn_def_fiche_cred']=='')$prop=-1; + $sql.=' where fd_id in ('.$prop['jrn_def_fiche_cred'].')'; + break; + case 'deb': + $l=new Acc_Ledger($cn,$ledger); + $prop=$l->get_propertie(); + if ( $prop=='')$prop=-1; + $sql.=' where fd_id in ('.$prop['jrn_def_fiche_deb'].')'; + break; + } + } + else + { + /* we filter thanks a given model of card */ + if ( isset($cat)) + { + $sql=$sql.sprintf(' where frd_id = '.FormatString ($cat)); + } + else + /* we filter thanks a given list of category of card + */ + if ( isset($fil) && strlen(trim($fil)) > 0 ) + { + $sql=$sql.sprintf(" where fd_id in (%s)", + FormatString($fil)); + } + } + $array=$cn->make_array($sql); + if ( empty($array)) + { + $html=_("Aucune catégorie de fiche ne correspondant à". + " votre demande"); + $html.=$sql; + } + else + { + $r=''; + $isel=new ISelect('fd_id'); + $isel->value=$array; + $popup=str_replace('_content','',$ctl); + $r.='
'; + $r.=dossier::hidden(); + $r.=(isset($ref))?HtmlInput::hidden('ref',1):''; + $r.='

choisissez le type de fiche à ajouter

'; + $r.=$isel->input(); + $r.=HtmlInput::submit('st','choix'); + $r.='
'; + $html=$r; + } + break; /*---------------------------------------------------------------------- - * Add a category, display first the form + * SC save card + * save the new card (insert) + * + ----------------------------------------------------------------------*/ +case 'sc': + if ( $user->check_action(FICADD)==1 ) + { + $f=new Fiche($cn); + $f->insert($fd_id,$_POST); + $html='

Fiche sauvée

'; + $html.=$f->Display(true); + $js=""; + if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); + $html.=$js; + } + else + { + $html=alert(_('Action interdite'),true); + } + break; + /*---------------------------------------------------------------------- + * Search a card * *----------------------------------------------------------------------*/ - $ipopup=str_replace('_content','',$ctl); - switch($cat) { - case FICHE_TYPE_CLIENT: - $msg=_(' de clients'); - $base=$cn->get_value("select p_value from parm_code where p_code='CUSTOMER'"); - break; - case FICHE_TYPE_FOURNISSEUR: - $msg=_(' de fournisseurs'); - $base=$cn->get_value("select p_value from parm_code where p_code='SUPPLIER'"); - break; - case FICHE_TYPE_ADM_TAX: - $msg=_(' d\'administration'); - $base=''; - break; +case 'fs': + require_once('class_acc_ledger.php'); + $r=''; + $r.='
'; + $q=new IText('query'); + $q->value=(isset($query))?$query:''; + $r.=_('Fiche contenant'); + $r.=$q->input(); + $r.=HtmlInput::submit('fs',_('Recherche')); + $r.=dossier::hidden().HtmlInput::hidden('op','fs'); + $array=array(); + foreach (array('query','inp','jrn','label','typecard','price','tvaid') as $i) + { + if (isset(${$i}) ) + { + $r.=HtmlInput::hidden($i,${$i}); + $sql_array[$i]=${$i}; + } } + /* what is the type of the ledger */ + $type="GL"; + if (isset($jrn) && $jrn > 1) + { + $ledger=new Acc_Ledger($cn,$jrn); + $type=$ledger->get_type(); + } + $fiche=new Fiche($cn); + /* Build the SQL and show result */ + $sql=$fiche->build_sql($sql_array); - $html=''; - $html.="

"._("Ajout d'une catégorie")." ".$msg."

"; - /* show the form */ - $html.= '
'; - $html.=$ctl; - $html.= ''; - $html.= dossier::hidden(); - $html.=HtmlInput::hidden('cat',$cat); - $search=new IPoste("class_base"); - $search->size=40; - $search->value=$base; - $search->label=_("Recherche poste"); - $search->set_attribute('gDossier',dossier::id()); - $search->set_attribute('account',$search->name); - $search->set_attribute('ipopup','ipop_account'); + /* We limit the search to 20 records */ + $sql=$sql.' order by vw_name limit 20'; + $a=$cn->get_array($sql); + + for($i=0;$iinput(); ob_start(); - require('template/category_of_card.php'); - $html.=ob_get_contents(); + require_once('template/card_result.php'); + $r.=ob_get_contents(); ob_clean(); - $submit=HtmlInput::submit('save',_('Sauve')); - $html.= '

'; - $html.= $submit; - $html.= '

'; - $html.= ''; - $html.= '
'; - } else { - $html=alert(_('Action interdite'),true); - } - break; -case 'scc': - /*---------------------------------------------------------------------- - * Save card Category into the database and return a ok message - * - *----------------------------------------------------------------------*/ - $html=''; - if ( $user->check_action(FICCAT) == 1 ) { - if ( strlen(trim($_POST['nom_mod'])) != 0 && - strlen(trim($_POST['class_base'])) != 0 ) { - $array=array("FICHE_REF"=>$cat, - "nom_mod"=>$_POST['nom_mod'], - "class_base"=>$_POST['class_base']); - if ( isset ($_POST['create'])) $array['create']=1; - $catcard=new Fiche_Def($cn); - if ( $catcard->Add($array) == -1) - $html.="alert('"._('Catégorie existe déjà')."')"; - else - $html.="alert('"._('Catégorie sauvée')."')"; - $html.=create_script($html); - } else { - $html.="alert('"._("Le nom et la classe base ne peuvent être vide")."')"; - $html.=create_script($html); + $ctl=$ctl.'_content'; + $html=$r; + break; +case 'ac': + if ( $user->check_action(FICCAT)==1 ) + { - $invalid=1; + /*---------------------------------------------------------------------- + * Add a category, display first the form + * + *----------------------------------------------------------------------*/ + $ipopup=str_replace('_content','',$ctl); + switch($cat) + { + case FICHE_TYPE_CLIENT: + $msg=_(' de clients'); + $base=$cn->get_value("select p_value from parm_code where p_code='CUSTOMER'"); + break; + case FICHE_TYPE_FOURNISSEUR: + $msg=_(' de fournisseurs'); + $base=$cn->get_value("select p_value from parm_code where p_code='SUPPLIER'"); + break; + case FICHE_TYPE_ADM_TAX: + $msg=_(' d\'administration'); + $base=''; + break; + } + + $html=''; + $html.="

"._("Ajout d'une catégorie")." ".$msg."

"; + /* show the form */ + $html.= '
'; + $html.=$ctl; + $html.= '
'; + $html.= dossier::hidden(); + $html.=HtmlInput::hidden('cat',$cat); + $search=new IPoste("class_base"); + $search->size=40; + $search->value=$base; + $search->label=_("Recherche poste"); + $search->set_attribute('gDossier',dossier::id()); + $search->set_attribute('account',$search->name); + $search->set_attribute('ipopup','ipop_account'); + + $str_poste=$search->input(); + ob_start(); + require('template/category_of_card.php'); + $html.=ob_get_contents(); + ob_clean(); + $submit=HtmlInput::submit('save',_('Sauve')); + $html.= '

'; + $html.= $submit; + $html.= '

'; + $html.= '
'; + $html.= '
'; } - $ipop=str_replace('_content','',$ctl); - $html.=create_script('hideIPopup(\''.$ipop.'\');'); - } else { - $html=alert(_('Action interdite'),true); - } - break; + else + { + $html=alert(_('Action interdite'),true); + } + break; +case 'scc': + /*---------------------------------------------------------------------- + * Save card Category into the database and return a ok message + * + *----------------------------------------------------------------------*/ + $html=''; + if ( $user->check_action(FICCAT) == 1 ) + { + if ( strlen(trim($_POST['nom_mod'])) != 0 && + strlen(trim($_POST['class_base'])) != 0 ) + { + $array=array("FICHE_REF"=>$cat, + "nom_mod"=>$_POST['nom_mod'], + "class_base"=>$_POST['class_base']); + if ( isset ($_POST['create'])) $array['create']=1; + $catcard=new Fiche_Def($cn); + if ( $catcard->Add($array) == -1) + $html.="alert('"._('Catégorie existe déjà')."')"; + else + $html.="alert('"._('Catégorie sauvée')."')"; + $html.=create_script($html); + } + else + { + $html.="alert('"._("Le nom et la classe base ne peuvent être vide")."')"; + $html.=create_script($html); + + $invalid=1; + } + $ipop=str_replace('_content','',$ctl); + $html.=create_script('hideIPopup(\''.$ipop.'\');'); + } + else + { + $html=alert(_('Action interdite'),true); + } + break; } // switch $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); echo << - -$ctl -$html - - - - + + $ctl + $html + EOF; diff --git a/html/ajax_extension.php b/html/ajax_extension.php index ba213318e..0523db305 100644 --- a/html/ajax_extension.php +++ b/html/ajax_extension.php @@ -41,158 +41,169 @@ $cn=new Database(dossier::id()); /* check user */ $user=new User($cn); set_language(); -$user->check(true);$user->check_dossier(dossier::id(),true); +$user->check(true); +$user->check_dossier(dossier::id(),true); if ($user->check_action(EXTENSION)==0 ) exit; $var=array('gDossier','action'); $cont=0; /* check if mandatory parameters are given */ -foreach ($var as $v) { - if ( ! isset ($_REQUEST [$v] ) ) { - echo "$v is not set "; - $cont=1; - } +foreach ($var as $v) +{ + if ( ! isset ($_REQUEST [$v] ) ) + { + echo "$v is not set "; + $cont=1; + } } extract ($_REQUEST); -$r="";$extra="";$ctl=""; -switch($action) { - /*---------------------------------------------------------------------- - *detail of an extension - * - *----------------------------------------------------------------------*/ - case 'de': - $ext=new Extension($cn); - $ext->set_parameter("id",$ex_id); - $ext->load(); - $str_hidden=HtmlInput::hidden('ex_id',$ex_id); - $name=new IText('name',$ext->get_parameter("name")); - $str_name=$name->input(); +$r=""; +$extra=""; +$ctl=""; +switch($action) +{ + /*---------------------------------------------------------------------- + *detail of an extension + * + *----------------------------------------------------------------------*/ +case 'de': + $ext=new Extension($cn); + $ext->set_parameter("id",$ex_id); + $ext->load(); + $str_hidden=HtmlInput::hidden('ex_id',$ex_id); + $name=new IText('name',$ext->get_parameter("name")); + $str_name=$name->input(); - $code=new IText('code',$ext->get_parameter("code")); - $str_code=$code->input(); + $code=new IText('code',$ext->get_parameter("code")); + $str_code=$code->input(); - $desc=new IText('desc',$ext->get_parameter("desc")); - $str_desc=$desc->input(); + $desc=new IText('desc',$ext->get_parameter("desc")); + $str_desc=$desc->input(); - $file=new IText('file',$ext->get_parameter("filepath")); - $str_file=$file->input(); + $file=new IText('file',$ext->get_parameter("filepath")); + $str_file=$file->input(); - $enable=new ISelect('enable'); - $array=array( - array ('label'=>_('Oui'),'value'=>'Y'), - array('label'=>_('Non'),'value'=>'N') - ); - $enable->value=$array; - $enable->selected=$ext->get_parameter('enable'); - $str_enable=$enable->input(); - $r.='
'; - $r.='
'; - $r.=dossier::hidden(); - /* property of the extension */ - ob_start(); - require_once('template/extension-detail.php'); - $r.=ob_get_contents(); - ob_clean(); - /* security */ - $ans=array(array('value'=>'Y','label'=>_('Accès')), - array('value'=>'N','label'=>_('Interdit')) - ); - $array=User::get_list(dossier::id()); + $enable=new ISelect('enable'); + $array=array( + array ('label'=>_('Oui'),'value'=>'Y'), + array('label'=>_('Non'),'value'=>'N') + ); + $enable->value=$array; + $enable->selected=$ext->get_parameter('enable'); + $str_enable=$enable->input(); + $r.='
'; + $r.=''; + $r.=dossier::hidden(); + /* property of the extension */ + ob_start(); + require_once('template/extension-detail.php'); + $r.=ob_get_contents(); + ob_clean(); + /* security */ + $ans=array(array('value'=>'Y','label'=>_('Accès')), + array('value'=>'N','label'=>_('Interdit')) + ); + $array=User::get_list(dossier::id()); - for ($i=0;$ivalue=$ans; - $i_select->selected=($ext->can_request($array[$i]['use_login'])==1)?'Y':'N'; - $array[$i]['access']=$i_select->input(); - } - require_once('template/extension-sec.php'); - $r.=ob_get_contents(); - ob_clean(); + for ($i=0;$ivalue=$ans; + $i_select->selected=($ext->can_request($array[$i]['use_login'])==1)?'Y':'N'; + $array[$i]['access']=$i_select->input(); + } + require_once('template/extension-sec.php'); + $r.=ob_get_contents(); + ob_clean(); - /* submit */ - $r.=HtmlInput::submit('ex_save',_('Sauve')); - $r.=''; - $r.='
'; - $ctl='dtext'; - break; - /* ---------------------------------------------------------------------- - * new extension - *----------------------------------------------------------------------*/ - case 'ne': - $ext=new Extension($cn); - $ext->set_parameter("id",0); - $str_hidden=HtmlInput::hidden('ex_id',0); + /* submit */ + $r.=HtmlInput::submit('ex_save',_('Sauve')); + $r.=''; + $r.='
'; + $ctl='dtext'; + break; + /* ---------------------------------------------------------------------- + * new extension + *----------------------------------------------------------------------*/ +case 'ne': + $ext=new Extension($cn); + $ext->set_parameter("id",0); + $str_hidden=HtmlInput::hidden('ex_id',0); - $name=new IText('name',""); - $str_name=$name->input(); + $name=new IText('name',""); + $str_name=$name->input(); - $code=new IText('code',""); - $str_code=$code->input(); + $code=new IText('code',""); + $str_code=$code->input(); - $desc=new IText('desc',""); - $str_desc=$desc->input(); + $desc=new IText('desc',""); + $str_desc=$desc->input(); - $file=new IText('file',""); - $str_file=$file->input(); + $file=new IText('file',""); + $str_file=$file->input(); - $enable=new ISelect('enable'); - $array=array( - array ('label'=>_('Oui'),'value'=>'Y'), - array('label'=>_('Non'),'value'=>'N') - ); - $enable->value=$array; - $enable->selected='Y'; - $str_enable=$enable->input(); - $r.='
'; - $r.='
'; - $r.=dossier::hidden(); - ob_start(); - require_once('template/extension-detail.php'); - $r.=ob_get_contents(); - ob_clean(); + $enable=new ISelect('enable'); + $array=array( + array ('label'=>_('Oui'),'value'=>'Y'), + array('label'=>_('Non'),'value'=>'N') + ); + $enable->value=$array; + $enable->selected='Y'; + $str_enable=$enable->input(); + $r.='
'; + $r.=''; + $r.=dossier::hidden(); + ob_start(); + require_once('template/extension-detail.php'); + $r.=ob_get_contents(); + ob_clean(); - /* security */ - $ans=array(array('value'=>'Y','label'=>_('Accès')), - array('value'=>'N','label'=>_('Interdit')) - ); - $array=User::get_list(dossier::id()); - for ($i=0;$ivalue=$ans; - $i_select->selected=($ext->can_request($array[$i]['use_login'])==1)?'Y':'N'; - $array[$i]['access']=$i_select->input(); - } - require_once('template/extension-sec.php'); - $r.=ob_get_contents(); - ob_clean(); + /* security */ + $ans=array(array('value'=>'Y','label'=>_('Accès')), + array('value'=>'N','label'=>_('Interdit')) + ); + $array=User::get_list(dossier::id()); + for ($i=0;$ivalue=$ans; + $i_select->selected=($ext->can_request($array[$i]['use_login'])==1)?'Y':'N'; + $array[$i]['access']=$i_select->input(); + } + require_once('template/extension-sec.php'); + $r.=ob_get_contents(); + ob_clean(); - $r.=HtmlInput::submit('ex_save',_('Sauve')); - $r.=''; - $r.='
'; - $ctl='dtext'; - break; - /*---------------------------------------------------------------------- - * save the extension - * - *----------------------------------------------------------------------*/ + $r.=HtmlInput::submit('ex_save',_('Sauve')); + $r.=''; + $r.='
'; + $ctl='dtext'; + break; + /*---------------------------------------------------------------------- + * save the extension + * + *----------------------------------------------------------------------*/ case 'se': - ob_start(); - $ext=new Extension($cn); - $ext->fromArray($_POST); - try { - $ext->save(); - $ext->save_security($_POST); - }catch (Exception $e) { - $r=alert(j( $e->getMessage()),true); - } - $html=ob_get_contents(); - ob_clean(); - break; + ob_start(); + $ext=new Extension($cn); + $ext->fromArray($_POST); + try + { + $ext->save(); + $ext->save_security($_POST); + } + catch (Exception $e) + { + $r=alert(j( $e->getMessage()),true); + } + $html=ob_get_contents(); + ob_clean(); + break; case 're': - $ext=new Extension($cn); - $ext->set_parameter('id',$ex_id); - $ext->delete(); - break; + $ext=new Extension($cn); + $ext->set_parameter('id',$ex_id); + $ext->delete(); + break; } $html=escape_xml($r); @@ -200,9 +211,9 @@ $html=escape_xml($r); header('Content-type: text/xml; charset=UTF-8'); echo << - -$ctl -$html -$extra - + + $ctl + $html + $extra + EOF; diff --git a/html/ajax_history.php b/html/ajax_history.php index ed1fd31b2..c652b6071 100644 --- a/html/ajax_history.php +++ b/html/ajax_history.php @@ -41,51 +41,59 @@ $div=$_REQUEST['div']; /////////////////////////////////////////////////////////////////////////// /* first detail for a card */ /////////////////////////////////////////////////////////////////////////// -if ( isset($_GET['f_id'])){ - $fiche=new Fiche($cn,$_GET['f_id']); - $year=$user->get_exercice(); - if ( $year == 0 ) { - $html="erreur aucune période par défaut, allez dans préférence pour en choisir une"; - } else { - $per=new Periode($cn); - $limit_periode=$per->get_limit($year); - $array['from_periode']=$limit_periode[0]->first_day(); - $array['to_periode']=$limit_periode[1]->last_day(); +if ( isset($_GET['f_id'])) +{ + $fiche=new Fiche($cn,$_GET['f_id']); + $year=$user->get_exercice(); + if ( $year == 0 ) + { + $html="erreur aucune période par défaut, allez dans préférence pour en choisir une"; + } + else + { + $per=new Periode($cn); + $limit_periode=$per->get_limit($year); + $array['from_periode']=$limit_periode[0]->first_day(); + $array['to_periode']=$limit_periode[1]->last_day(); - ob_start(); - require_once('template/history_top.php'); - $fiche->HtmlTable($array); - $html=ob_get_contents(); - ob_clean(); - } + ob_start(); + require_once('template/history_top.php'); + $fiche->HtmlTable($array); + $html=ob_get_contents(); + ob_clean(); + } } /////////////////////////////////////////////////////////////////////////// // for an account /////////////////////////////////////////////////////////////////////////// -if ( isset($_REQUEST['pcm_val'])) { - $poste=new Acc_Account_Ledger($cn,$_REQUEST['pcm_val']); - $year=$user->get_exercice(); - if ( $year == 0 ) { - $html="erreur aucune période par défaut, allez dans préférence pour en choisir une"; - } else { - $per=new Periode($cn); - $limit_periode=$per->get_limit($year); - $array['from_periode']=$limit_periode[0]->first_day(); - $array['to_periode']=$limit_periode[1]->last_day(); +if ( isset($_REQUEST['pcm_val'])) +{ + $poste=new Acc_Account_Ledger($cn,$_REQUEST['pcm_val']); + $year=$user->get_exercice(); + if ( $year == 0 ) + { + $html="erreur aucune période par défaut, allez dans préférence pour en choisir une"; + } + else + { + $per=new Periode($cn); + $limit_periode=$per->get_limit($year); + $array['from_periode']=$limit_periode[0]->first_day(); + $array['to_periode']=$limit_periode[1]->last_day(); - ob_start(); - require_once('template/history_top.php'); - $poste->HtmlTable($array); - $html=ob_get_contents(); - ob_clean(); - } + ob_start(); + require_once('template/history_top.php'); + $poste->HtmlTable($array); + $html=ob_get_contents(); + ob_clean(); + } } $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); echo << - -$div -$html - + + $div + $html + EOF; diff --git a/html/ajax_import.php b/html/ajax_import.php index ff08bac6c..572612082 100644 --- a/html/ajax_import.php +++ b/html/ajax_import.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief ajax file called by the import screen */ @@ -41,38 +41,38 @@ $User->check_dossier(dossier::id()); $User->can_request('GEBQ'); $User->Check(); if ( isset ($_GET['action']) && - $_GET['action']=='update' - ) + $_GET['action']=='update' + ) - { +{ $code=FormatString($_GET['code']); $count=FormatString($_GET['count']); $poste=FormatString($_GET['poste']); $concern=FormatString($_GET['concerned']); $sql = "update import_tmp set poste_comptable='$poste' ,status='w',". - "jr_rapt='$concern' where code='$code'"; - + "jr_rapt='$concern' where code='$code'"; + $Res=$cn->exec_sql($sql); exit(); - } +} if ( isset ($_GET['action']) && - $_GET['action']=='delete' - ) + $_GET['action']=='delete' + ) - { +{ $code=FormatString($_GET['code']); $sql="update import_tmp set status='d' where code='".$code."'"; $cn->exec_sql($sql); exit(); - } +} if ( isset ($_GET['action']) && - $_GET['action']=='not_confirmed' - ) + $_GET['action']=='not_confirmed' + ) - { +{ $code=FormatString($_GET['code']); $sql="update import_tmp set status='n' where code='".$code."'"; $cn->exec_sql($sql); exit(); - } +} diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php index 2dc3cf58e..7c748a9ef 100644 --- a/html/ajax_ledger.php +++ b/html/ajax_ledger.php @@ -38,9 +38,9 @@ require_once('class_acc_reconciliation.php'); require_once('class_anc_operation.php'); require_once('class_idate.php'); require_once('class_ibox.php'); - /** - *@todo Check if we receive the needed data (jr_id...) - */ +/** + *@todo Check if we receive the needed data (jr_id...) + */ $action=$_REQUEST['act']; $jr_id=$_REQUEST['jr_id']; $div=$_REQUEST['div']; /* the div source and target for javascript */ @@ -54,21 +54,22 @@ $cn=new Database(dossier::id()); // check if the user is valid and can access this folder $User=new User($cn); $User->check(); -if ( $User->check_dossier(dossier::id(),true)=='X' ) { - ob_start(); - require_once ('template/ledger_detail_forbidden.php'); - $html=ob_get_contents(); - ob_clean(); - $html=escape_xml($html); - header('Content-type: text/xml; charset=UTF-8'); -echo << - -$div -$html - +if ( $User->check_dossier(dossier::id(),true)=='X' ) +{ + ob_start(); + require_once ('template/ledger_detail_forbidden.php'); + $html=ob_get_contents(); + ob_clean(); + $html=escape_xml($html); + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $div + $html + EOF; -exit(); + exit(); } @@ -78,169 +79,197 @@ $op=new Acc_Operation($cn); $op->jr_id=$_REQUEST['jr_id']; $ledger=$op->get_ledger(); $access=$User->get_ledger_access($ledger); -if ( $access == 'X' ) { - ob_start(); - require_once ('template/ledger_detail_forbidden.php'); - $html=ob_get_contents(); - ob_clean(); - - $html=escape_xml($html); - header('Content-type: text/xml; charset=UTF-8'); -echo << - -$div -$html - -EOF; -exit(); -} -$html=var_export($_REQUEST,true); -switch ($action) { - /////////////////////////////////////////////////////////////////////////// - // remove op - /////////////////////////////////////////////////////////////////////////// -case 'rmop': - if ( $access=='W'){ +if ( $access == 'X' ) +{ ob_start(); - /* get the ledger */ - try { - $cn->start(); - $oLedger=new Acc_Ledger($cn,$ledger); - $oLedger->jr_id=$_REQUEST['jr_id']; - $oLedger->delete(); - $cn->commit(); - echo _("Opération Effacée"); - } catch (Exception $e) { - $e->getMessage(); - $cn->rollback; - } + require_once ('template/ledger_detail_forbidden.php'); $html=ob_get_contents(); ob_clean(); - } - break; - ////////////////////////////////////////////////////////////////////// - // DE Detail - ////////////////////////////////////////////////////////////////////// + + $html=escape_xml($html); + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $div + $html + +EOF; + exit(); +} +$html=var_export($_REQUEST,true); +switch ($action) +{ + /////////////////////////////////////////////////////////////////////////// + // remove op + /////////////////////////////////////////////////////////////////////////// +case 'rmop': + if ( $access=='W') + { + ob_start(); + /* get the ledger */ + try + { + $cn->start(); + $oLedger=new Acc_Ledger($cn,$ledger); + $oLedger->jr_id=$_REQUEST['jr_id']; + $oLedger->delete(); + $cn->commit(); + echo _("Opération Effacée"); + } + catch (Exception $e) + { + $e->getMessage(); + $cn->rollback; + } + $html=ob_get_contents(); + ob_clean(); + } + break; + ////////////////////////////////////////////////////////////////////// + // DE Detail + ////////////////////////////////////////////////////////////////////// case 'de': ob_start(); - try { - $op->get(); /* get detail op (D/C) */ - $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ - - $oLedger=new Acc_Ledger($cn,$ledger); - if ( $obj==null || $obj->signature == 'ODS' ) { - /* only the details */ - require_once('template/ledger_detail_misc.php'); - } elseif ( $obj->signature=='ACH') { - require_once('template/ledger_detail_ach.php'); - } elseif ($obj->signature=='FIN') { - require_once('template/ledger_detail_fin.php'); - }elseif ( $obj->signature=='VEN') { - require_once('template/ledger_detail_ven.php'); + try + { + $op->get(); /* get detail op (D/C) */ + $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ + + $oLedger=new Acc_Ledger($cn,$ledger); + if ( $obj==null || $obj->signature == 'ODS' ) + { + /* only the details */ + require_once('template/ledger_detail_misc.php'); + } + elseif ( $obj->signature=='ACH') + { + require_once('template/ledger_detail_ach.php'); + } + elseif ($obj->signature=='FIN') + { + require_once('template/ledger_detail_fin.php'); + } + elseif ( $obj->signature=='VEN') + { + require_once('template/ledger_detail_ven.php'); + } } - } catch (Exception $e) { - echo 'Fermer'; - echo '

Désolé il y a une erreur

'; - } - $html=ob_get_contents(); - ob_clean(); + catch (Exception $e) + { + echo 'Fermer'; + echo '

Désolé il y a une erreur

'; + } + $html=ob_get_contents(); + ob_clean(); - break; - ///////////////////////////////////////////////////////////////////////////// - // form for the file - ///////////////////////////////////////////////////////////////////////////// - case 'file': - $op->get(); $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ + break; + ///////////////////////////////////////////////////////////////////////////// + // form for the file + ///////////////////////////////////////////////////////////////////////////// +case 'file': + $op->get(); + $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ - if ( $obj->det->jr_pj_name=='') { - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; - - if ( $access=='W') { - echo '
'; - $sp=new ISpan('file'.$div);$sp->style="display:none;width:155;height:15;background-color:red;color:white;font-size:10"; - $sp->value="Chargement"; - echo $sp->input(); - echo HtmlInput::hidden('act','loadfile'); - echo dossier::hidden(); - echo HtmlInput::hidden('jr_id',$jr_id); - echo HtmlInput::hidden('div',$div); - - echo ''; - echo '
'; - } else { - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; + if ( $obj->det->jr_pj_name=='') + { + echo ""; + $repo=new Database(); + $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; - echo _('Aucun fichier'); - } - echo '
'; - echo ''; - exit(); - } else { - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; + if ( $access=='W') + { + echo '
'; + $sp=new ISpan('file'.$div); + $sp->style="display:none;width:155;height:15;background-color:red;color:white;font-size:10"; + $sp->value="Chargement"; + echo $sp->input(); + echo HtmlInput::hidden('act','loadfile'); + echo dossier::hidden(); + echo HtmlInput::hidden('jr_id',$jr_id); + echo HtmlInput::hidden('div',$div); - $x=''; - if ($access=='W') - $x=sprintf('enlever', - $gDossier,$div,$jr_id); - echo $x; - $filename= $obj->det->jr_pj_name; - if ( strlen($obj->det->jr_pj_name) > 20 ) { - $filename=substr($obj->det->jr_pj_name,0,23); - } - $h=sprintf('%s', - $gDossier,$ledger,$obj->det->jr_grpt_id,h( $filename)); - echo $h; - echo '
'; - echo ''; - exit(); + echo ''; + echo ''; + } + else + { + echo ""; + $repo=new Database(); + $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; + + echo _('Aucun fichier'); + } + echo '
'; + echo ''; + exit(); + } + else + { + echo ""; + $repo=new Database(); + $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; + + $x=''; + if ($access=='W') + $x=sprintf('enlever', + $gDossier,$div,$jr_id); + echo $x; + $filename= $obj->det->jr_pj_name; + if ( strlen($obj->det->jr_pj_name) > 20 ) + { + $filename=substr($obj->det->jr_pj_name,0,23); + } + $h=sprintf('%s', + $gDossier,$ledger,$obj->det->jr_grpt_id,h( $filename)); + echo $h; + echo '
'; + echo ''; + exit(); } ///////////////////////////////////////////////////////////////////////////// // load a file ///////////////////////////////////////////////////////////////////////////// - case 'loadfile': - if ( $access == 'W' && isset ($_FILES)) { - $cn->start(); - // remove the file - $grpt=$cn->get_value('select jr_grpt_id from jrn where jr_id=$1',array($jr_id)); - $cn->save_upload_document($grpt); - $cn->commit(); - // Show a link to the new file - $op->get(); $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ +case 'loadfile': + if ( $access == 'W' && isset ($_FILES)) + { + $cn->start(); + // remove the file + $grpt=$cn->get_value('select jr_grpt_id from jrn where jr_id=$1',array($jr_id)); + $cn->save_upload_document($grpt); + $cn->commit(); + // Show a link to the new file + $op->get(); + $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; - $x=sprintf('enlever', - $gDossier,$div,$jr_id); - echo $x; - $filename= $obj->det->jr_pj_name; - if ( strlen($obj->det->jr_pj_name) > 20 ) { - $filename=substr($obj->det->jr_pj_name,1,20); - } - $h=sprintf('%s', - $gDossier,$ledger,$obj->det->jr_grpt_id,h($filename)); - echo $h; - echo '
'; + echo ""; + $repo=new Database(); + $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; + $x=sprintf('enlever', + $gDossier,$div,$jr_id); + echo $x; + $filename= $obj->det->jr_pj_name; + if ( strlen($obj->det->jr_pj_name) > 20 ) + { + $filename=substr($obj->det->jr_pj_name,1,20); + } + $h=sprintf('%s', + $gDossier,$ledger,$obj->det->jr_grpt_id,h($filename)); + echo $h; + echo '
'; } exit(); @@ -248,143 +277,159 @@ case 'de': // remove a file ///////////////////////////////////////////////////////////////////////////// case 'rmf': - if ( $access == 'W' ){ - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; - - echo '
'; - $sp=new ISpan('file'.$div);$sp->style="display:none;width:155;height:15;background-color:red;color:white;font-size:10"; - $sp->value="Chargement"; - echo $sp->input(); + if ( $access == 'W' ) + { + echo ""; + $repo=new Database(); + $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; - echo HtmlInput::hidden('act','loadfile'); - echo dossier::hidden(); - echo HtmlInput::hidden('jr_id',$jr_id); - echo HtmlInput::hidden('div',$div); - - echo ''; - echo ''; - $ret=$cn->exec_sql("select jr_pj from jrn where jr_id=$1",array($jr_id)); - if (Database::num_row($ret) != 0) { - $r=Database::fetch_array($ret,0); - $old_oid=$r['jr_pj']; - if (strlen($old_oid) != 0) - { - // check if this pj is used somewhere else - $c=$cn->count_sql("select * from jrn where jr_pj=".$old_oid); - if ( $c == 1 ) - $cn->lo_unlink($old_oid); - } - $cn->exec_sql("update jrn set jr_pj=null, jr_pj_name=null, ". - "jr_pj_type=null where jr_id=$1",array($jr_id)); - } - } - echo '
'; - exit(); + echo '
'; + $sp=new ISpan('file'.$div); + $sp->style="display:none;width:155;height:15;background-color:red;color:white;font-size:10"; + $sp->value="Chargement"; + echo $sp->input(); + + echo HtmlInput::hidden('act','loadfile'); + echo dossier::hidden(); + echo HtmlInput::hidden('jr_id',$jr_id); + echo HtmlInput::hidden('div',$div); + + echo ''; + echo '
'; + $ret=$cn->exec_sql("select jr_pj from jrn where jr_id=$1",array($jr_id)); + if (Database::num_row($ret) != 0) + { + $r=Database::fetch_array($ret,0); + $old_oid=$r['jr_pj']; + if (strlen($old_oid) != 0) + { + // check if this pj is used somewhere else + $c=$cn->count_sql("select * from jrn where jr_pj=".$old_oid); + if ( $c == 1 ) + $cn->lo_unlink($old_oid); + } + $cn->exec_sql("update jrn set jr_pj=null, jr_pj_name=null, ". + "jr_pj_type=null where jr_id=$1",array($jr_id)); + } + } + echo '
'; + exit(); ///////////////////////////////////////////////////////////////////////////// // Save operation detail ///////////////////////////////////////////////////////////////////////////// - case 'save': +case 'save': ob_start(); - try { - $cn->start(); - if ( $access=="W") { - $cn->exec_sql('update jrn set jr_comment=$1,jr_pj_number=$2 where jr_id=$3', - array($_POST['lib'],$_POST['npj'],$jr_id)); - $rapt=$_POST['rapt']; - if (trim($rapt) != '') { - $rec=new Acc_Reconciliation ($cn); - $rec->set_jr_id($jr_id); + try + { + $cn->start(); + if ( $access=="W") + { + $cn->exec_sql('update jrn set jr_comment=$1,jr_pj_number=$2 where jr_id=$3', + array($_POST['lib'],$_POST['npj'],$jr_id)); + $rapt=$_POST['rapt']; + if (trim($rapt) != '') + { + $rec=new Acc_Reconciliation ($cn); + $rec->set_jr_id($jr_id); - if (strpos($rapt,",") != 0 ) { - $aRapt=explode(',',$rapt); - /* reconcialition */ - foreach ($aRapt as $rRapt) { - if ( isNumber($rRapt) == 1 ) - { - // Add a "concerned operation to bound these op.together - $rec->insert($rRapt); - } - } - } else - if ( isNumber($rapt) == 1 ) - { - $rec->insert($rapt); - } - } - //////////////////////////////////////////////////// - // CA - ////////////////////////////////////////////////// - $owner = new Own($cn); - if ( $owner->MY_ANALYTIC != "nu" ) - { - // for each item, insert into operation_analytique */ - $op=new Anc_Operation($cn); - $op->save_update_form($_POST); - } - } - echo _('Opération sauvée'); - $cn->commit(); - } catch (Exception $e) { - echo $e->getMessage(); - } + if (strpos($rapt,",") != 0 ) + { + $aRapt=explode(',',$rapt); + /* reconcialition */ + foreach ($aRapt as $rRapt) + { + if ( isNumber($rRapt) == 1 ) + { + // Add a "concerned operation to bound these op.together + $rec->insert($rRapt); + } + } + } + else + if ( isNumber($rapt) == 1 ) + { + $rec->insert($rapt); + } + } + //////////////////////////////////////////////////// + // CA + ////////////////////////////////////////////////// + $owner = new Own($cn); + if ( $owner->MY_ANALYTIC != "nu" ) + { + // for each item, insert into operation_analytique */ + $op=new Anc_Operation($cn); + $op->save_update_form($_POST); + } + } + echo _('Opération sauvée'); + $cn->commit(); + } + catch (Exception $e) + { + echo $e->getMessage(); + } $html=ob_get_contents(); ob_clean(); break; - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // remove a reconciliation -///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// case 'rmr': - if ( $access=='W') { - $rec=new Acc_Reconciliation($cn); - $rec->set_jr_id($jr_id); - $rec->remove($_GET['jr_id2']); - } - break; - //////////////////////////////////////////////////////////////////////////////// - // ask for a date for reversing the operation -case 'ask_extdate': - $date=new IDate('p_date'); - $html= 'Fermer'; - $html.="
"; - $html.=HtmlInput::hidden('jr_id',$_REQUEST['jr_id']).HtmlInput::hidden('div',$div).dossier::hidden().HtmlInput::hidden('act','reverseop'); - $html.='

entrez une date

'.$date->input(); - $html.=HtmlInput::submit('x','accepter'); - $html.='
'; - break; - //////////////////////////////////////////////////////////////////////////////// - // Reverse an operation - //////////////////////////////////////////////////////////////////////////////// -case 'reverseop': - if ( $access=='W') { - ob_start(); - try { - $cn->start(); - $oLedger=new Acc_Ledger($cn,$ledger); - $oLedger->jr_id=$_REQUEST['jr_id']; - $oLedger->reverse($_REQUEST['p_date']); - $cn->commit(); - echo _("Opération extournée"); - } catch (Exception $e) { - $e->getMessage(); - $cn->rollback(); + if ( $access=='W') + { + $rec=new Acc_Reconciliation($cn); + $rec->set_jr_id($jr_id); + $rec->remove($_GET['jr_id2']); } - } - $html=ob_get_contents(); - ob_clean(); - break; + break; + //////////////////////////////////////////////////////////////////////////////// + // ask for a date for reversing the operation +case 'ask_extdate': + $date=new IDate('p_date'); + $html= 'Fermer'; + $html.="
"; + $html.=HtmlInput::hidden('jr_id',$_REQUEST['jr_id']).HtmlInput::hidden('div',$div).dossier::hidden().HtmlInput::hidden('act','reverseop'); + $html.='

entrez une date

'.$date->input(); + $html.=HtmlInput::submit('x','accepter'); + $html.='
'; + break; + //////////////////////////////////////////////////////////////////////////////// + // Reverse an operation + //////////////////////////////////////////////////////////////////////////////// +case 'reverseop': + if ( $access=='W') + { + ob_start(); + try + { + $cn->start(); + $oLedger=new Acc_Ledger($cn,$ledger); + $oLedger->jr_id=$_REQUEST['jr_id']; + $oLedger->reverse($_REQUEST['p_date']); + $cn->commit(); + echo _("Opération extournée"); + } + catch (Exception $e) + { + $e->getMessage(); + $cn->rollback(); + } + } + $html=ob_get_contents(); + ob_clean(); + break; } $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); echo << - -$div -$html - + + $div + $html + EOF; diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 941a41d3e..62330879b 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -44,55 +44,59 @@ require_once ('class_user.php'); $var=array('gDossier'); $cont=0; /* check if mandatory parameters are given */ -foreach ($var as $v) { - if ( ! isset ($_REQUEST [$v] ) ) { - echo "$v is not set "; - $cont=1; - } +foreach ($var as $v) +{ + if ( ! isset ($_REQUEST [$v] ) ) + { + echo "$v is not set "; + $cont=1; + } } if ( $cont != 0 ) exit(); extract($_GET ); set_language(); $cn=new Database($gDossier); -$user=new User($cn); $user->check(true);$user->check_dossier($gDossier,true); +$user=new User($cn); +$user->check(true); +$user->check_dossier($gDossier,true); $html=var_export($_REQUEST,true); -switch($op) - { +switch($op) +{ //-------------------------------------------------- // get the last date of a ledger - case 'lastdate': +case 'lastdate': require_once('class_acc_ledger_fin.php'); $ledger=new Acc_Ledger_Fin($cn,$_GET['p_jrn']); $html=$ledger->get_last_date(); $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); -echo << - -e_date -$html - + echo << + + e_date + $html + EOF; break; - case 'bkname': +case 'bkname': require_once('class_acc_ledger_fin.php'); $ledger=new Acc_Ledger_Fin($cn,$_GET['p_jrn']); $html=$ledger->get_bank_name(); $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); -echo << - -bkname -$html - + echo << + + bkname + $html + EOF; break; // display new calendar - case 'cal': - require_once('class_calendar.php'); +case 'cal': + require_once('class_calendar.php'); /* others report */ $cal=new Calendar(); $cal->set_periode($per); @@ -100,57 +104,59 @@ EOF; $html=""; $html=$cal->display(); $html=escape_xml($html); -header('Content-type: text/xml; charset=UTF-8'); -echo << - -$html - + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $html + EOF; - break; - /* remove a cat of document */ - case 'rem_cat_doc': - require_once('class_document_type.php'); + break; + /* remove a cat of document */ +case 'rem_cat_doc': + require_once('class_document_type.php'); // if user can not return error message - if( $user->check_action(PARCATDOC)==0 ) { - $html="nok"; - header('Content-type: text/xml; charset=UTF-8'); -echo << - -$html - + if( $user->check_action(PARCATDOC)==0 ) + { + $html="nok"; + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $html + EOF; -return; + return; } - // remove the cat if no action + // remove the cat if no action $count_md=$cn->get_value('select count(*) from document_modele where md_type=$1',array($dt_id)); - $count_a=$cn->get_value('select count(*) from action_gestion where ag_type=$1',array($dt_id)); + $count_a=$cn->get_value('select count(*) from action_gestion where ag_type=$1',array($dt_id)); - if ( $count_md != 0 || $count_a != 0 ) { - $html="nok"; - header('Content-type: text/xml; charset=UTF-8'); -echo << - -$html - + if ( $count_md != 0 || $count_a != 0 ) + { + $html="nok"; + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $html + EOF; -exit; - } -$cn->exec_sql('delete from document_type where dt_id=$1',array($dt_id)); - $html=$dt_id; - header('Content-type: text/xml; charset=UTF-8'); -echo << - -$html - + exit; + } + $cn->exec_sql('delete from document_type where dt_id=$1',array($dt_id)); + $html=$dt_id; + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $html + EOF; - return; - break; - case 'dsp_tva': - $cn=new Database($gDossier); + return; + break; +case 'dsp_tva': + $cn=new Database($gDossier); $Res=$cn->exec_sql("select * from tva_rate order by tva_rate desc"); $Max=Database::num_row($Res); $r=""; @@ -162,70 +168,81 @@ EOF; $r.=th(_('Symbole')); $r.=th(_('Explication')); - for ($i=0;$i<$Max;$i++) { - $row=Database::fetch_array($Res,$i); - if ( ! isset($compute)) { - if ( ! isset($code) ) { - $script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\""; - } else { - $script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');\""; - } - } else { - if ( ! isset($code) ) { - $script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');clean_tva('$compute');compute_ledger('$compute');\""; - } else { - $script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');clean_tva('$compute');compute_ledger('$compute');\""; - } + for ($i=0;$i<$Max;$i++) + { + $row=Database::fetch_array($Res,$i); + if ( ! isset($compute)) + { + if ( ! isset($code) ) + { + $script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\""; + } + else + { + $script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');\""; + } + } + else + { + if ( ! isset($code) ) + { + $script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');clean_tva('$compute');compute_ledger('$compute');\""; + } + else + { + $script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');clean_tva('$compute');compute_ledger('$compute');\""; + } - } - $set= ''; - $r.=''; - $r.=td($set); - $r.=td($row['tva_id']); - $r.=td($row['tva_rate']); - $r.=td($row['tva_label']); - $r.=td($row['tva_comment']); - $r.=''; + } + $set= ''; + $r.=''; + $r.=td($set); + $r.=td($row['tva_id']); + $r.=td($row['tva_rate']); + $r.=td($row['tva_label']); + $r.=td($row['tva_comment']); + $r.=''; } $r.=''; $r.='
'; $html=escape_xml($r); - -header('Content-type: text/xml; charset=UTF-8'); -echo << - -$html -$popup - -EOF; -break; - case 'label_tva': - $cn=new Database($gDossier); - if ( isNumber($id) == 0 ) - $value = _('tva inconnue'); - else { - $Res=$cn->get_array("select * from tva_rate where tva_id = $1",array($id)); - if ( count($Res) == 0 ) - $value=_('tva inconnue'); - else - $value=$Res[0]['tva_label']; + + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $html + $popup + + EOF; + break; +case 'label_tva': + $cn=new Database($gDossier); + if ( isNumber($id) == 0 ) + $value = _('tva inconnue'); + else + { + $Res=$cn->get_array("select * from tva_rate where tva_id = $1",array($id)); + if ( count($Res) == 0 ) + $value=_('tva inconnue'); + else + $value=$Res[0]['tva_label']; } -header('Content-type: text/xml; charset=UTF-8'); -echo << - -$code -$value - + header('Content-type: text/xml; charset=UTF-8'); + echo << + + $code + $value + EOF; break; /** *display the lettering */ - case 'dl': - require_once('class_lettering.php'); +case 'dl': + require_once('class_lettering.php'); $exercice=$user->get_exercice(); $periode=new Periode($cn); list($first_per,$last_per)=$periode->get_limit($exercice); @@ -236,8 +253,8 @@ EOF; // retrieve info for the given j_id (date, amount,side and comment) $sql="select j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,J_POSTE,j_qcode,jr_id, -jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_id) - where j_id=$1"; + jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_id) + where j_id=$1"; $arow=$cn->get_array($sql,array($j_id)); $row=$arow[0]; $r=''; @@ -292,10 +309,10 @@ jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_ $line=td('Debit / Credit'); $iside=new ISelect('side'); $iside->value=array( - array('label'=>_('Debit'),'value'=>0), - array('label'=>_('Credit'),'value'=>1), - array('label'=>_('Les 2'),'value'=>3) - ); + array('label'=>_('Debit'),'value'=>0), + array('label'=>_('Credit'),'value'=>1), + array('label'=>_('Les 2'),'value'=>3) + ); /** * * if $side is not then @@ -303,20 +320,26 @@ jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_ * - if jl_id does not exist or is < 0 then show by default the opposite * side */ - if ( ! isset ($side )) { - // find the jl_id of the j_id - $jl_id=$cn->get_value('select comptaproc.get_letter_jnt($1)',array($j_id)); - if ($jl_id == null ) { - // get the other side - $iside->selected=(isset($side))?$side:(($row['j_debit']=='t')?1:0); - $side=(isset($side))?$side:(($row['j_debit']=='t')?1:0); - } else { - // show everything - $iside->selected=3; - $side=3; - } - } else { - $iside->selected=$side; + if ( ! isset ($side )) + { + // find the jl_id of the j_id + $jl_id=$cn->get_value('select comptaproc.get_letter_jnt($1)',array($j_id)); + if ($jl_id == null ) + { + // get the other side + $iside->selected=(isset($side))?$side:(($row['j_debit']=='t')?1:0); + $side=(isset($side))?$side:(($row['j_debit']=='t')?1:0); + } + else + { + // show everything + $iside->selected=3; + $side=3; + } + } + else + { + $iside->selected=$side; } $r.=tr($line.td($iside->input())); @@ -340,46 +363,51 @@ jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_ if ( isset($_REQUEST['f_id'])) $form.=HtmlInput::hidden('f_id',$_REQUEST['f_id']); /* check if date are valid */ if ( (isset($search_end) && isDate($search_end) == null) || - (isset($search_start) && isDate ($search_start) == null)) - { - ob_start(); - alert(_('Date malformée, désolé')); - $html=ob_get_contents(); - ob_clean(); + (isset($search_start) && isDate ($search_start) == null)) + { + ob_start(); + alert(_('Date malformée, désolé')); + $html=ob_get_contents(); + ob_clean(); - $html=escape_xml($html); + $html=escape_xml($html); - header('Content-type: text/xml; charset=UTF-8'); -echo << - -detail -$html - + header('Content-type: text/xml; charset=UTF-8'); + echo << + + detail + $html + EOF; -exit(); + exit(); } // display a list of operation from the other side + box button - if ( $ot == 'account') { - $obj=new Lettering_Account($cn,$row['j_poste']); - if ( isset($search_start)) $obj->start=$search_start; - if ( isset ($search_end)) $obj->end=$search_end; - if ( isset ($max_amount)) $obj->fil_amount_max=$max_amount; - if ( isset ($min_amount)) $obj->fil_amount_min=$min_amount; - if ( isset ($side)) $obj->fil_deb=$side; + if ( $ot == 'account') + { + $obj=new Lettering_Account($cn,$row['j_poste']); + if ( isset($search_start)) $obj->start=$search_start; + if ( isset ($search_end)) $obj->end=$search_end; + if ( isset ($max_amount)) $obj->fil_amount_max=$max_amount; + if ( isset ($min_amount)) $obj->fil_amount_min=$min_amount; + if ( isset ($side)) $obj->fil_deb=$side; - $form.=$obj->show_letter($j_id); - } else if ($ot=='card') { - $obj=new Lettering_Card($cn,$row['j_qcode']); - if ( isset($search_start)) $obj->start=$search_start; - if ( isset ($search_end)) $obj->end=$search_end; - if ( isset ($max_amount)) $obj->fil_amount_max=$max_amount; - if ( isset ($min_amount)) $obj->fil_amount_min=$min_amount; - if ( isset ($side)) $obj->fil_deb=$side; - $form.=$obj->show_letter($j_id); - } else { - $form.='Mauvais type objet'; + $form.=$obj->show_letter($j_id); + } + else if ($ot=='card') + { + $obj=new Lettering_Card($cn,$row['j_qcode']); + if ( isset($search_start)) $obj->start=$search_start; + if ( isset ($search_end)) $obj->end=$search_end; + if ( isset ($max_amount)) $obj->fil_amount_max=$max_amount; + if ( isset ($min_amount)) $obj->fil_amount_min=$min_amount; + if ( isset ($side)) $obj->fil_deb=$side; + $form.=$obj->show_letter($j_id); + } + else + { + $form.='Mauvais type objet'; } $form.=HtmlInput::submit('record',_('Sauver')).$ret->input(); @@ -390,12 +418,12 @@ exit(); $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); -echo << - -detail -$html - + echo << + + detail + $html + EOF; break; - } +} diff --git a/html/ajax_poste.php b/html/ajax_poste.php index 2b3677c94..4e44c6f99 100644 --- a/html/ajax_poste.php +++ b/html/ajax_poste.php @@ -43,11 +43,13 @@ 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; - } +foreach ($var as $v) +{ + if ( ! isset ($_REQUEST [$v] ) ) + { + echo "$v is not set "; + $cont=1; + } } set_language(); @@ -59,100 +61,113 @@ $User->Check(); if ($User->get_ledger_access(dossier::id()) == 'X') exit(); $xml=""; -switch ($op) { - /*---------------------------------------------------------------------- - * Show the form and the result - * - ----------------------------------------------------------------------*/ +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')); + $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='
'; - 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=''; + 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.='
'; - $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 "; + $r.=''; + $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 0) + { + $q=sql_string($q); + $sql.=sprintf(" $sep ( pcm_val::text like '%s%%' or pcm_lib::text ilike '%%%s%%') ", + $q,$q); } - - if ( isset($l) ){ - $str.=sprintf("set_value('%s',g('%s').innerHTML);", - $l,"lib$i"); - + $sql.=' order by pcm_val::text limit 50'; + if ( isset($q) && strlen(trim($q))> 0 ) + { + $array=$cn->get_array($sql); } - $str.="hideIPopup('$ipopup');"; - $array[$i]['javascript']=$str; - } - ob_start(); + if ( ! isset($q) ) $array=array(); + if ( isset($q) && strlen(trim($q))==0) $array=array(); - require_once('template/account_result.php'); - $r.=ob_get_contents(); - ob_clean(); + /* set the javascript */ + for ($i=0;$i - -$ctl -$html - + + $ctl + $html + EOF; diff --git a/html/ajax_report.php b/html/ajax_report.php index 85b3b4d99..619fce488 100644 --- a/html/ajax_report.php +++ b/html/ajax_report.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief Fid for the ajax request for cards */ @@ -32,13 +32,13 @@ require_once('class_dossier.php'); require_once('class_acc_report.php'); require_once('class_user.php'); if ( ! isset($_GET['gDossier']) || - ! isset($_GET['f']) ) - { + ! isset($_GET['f']) ) +{ $a='{"answer":"nok"}'; header("Content-type: text/html; charset: utf8",true); print $a; exit(); - } +} $cn=new Database(dossier::id()); $User=new User($cn); @@ -46,31 +46,32 @@ $User->Check(); $User->check_dossier(dossier::id()); $User->can_request('PARRAP',0); - + $gDossier=dossier::id(); -if ( ! is_dir('tmp') ) { - mkdir ('tmp'); +if ( ! is_dir('tmp') ) +{ + mkdir ('tmp'); } $cn=new Database($gDossier); if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) -{ - $rap=new Acc_Report($cn,$_GET['f']); +{ + $rap=new Acc_Report($cn,$_GET['f']); - $name=tempnam('tmp','report_').'.bin'; + $name=tempnam('tmp','report_').'.bin'; - $file= fopen($name,"a+"); - $rap->export($file); - fclose ($file); - $name='tmp'.DIRECTORY_SEPARATOR.basename($name); - $name=dirname($_SERVER['REQUEST_URI']).DIRECTORY_SEPARATOR.$name; + $file= fopen($name,"a+"); + $rap->export($file); + fclose ($file); + $name='tmp'.DIRECTORY_SEPARATOR.basename($name); + $name=dirname($_SERVER['REQUEST_URI']).DIRECTORY_SEPARATOR.$name; - $a='{"answer":"ok","link":"'.$name.'"}'; + $a='{"answer":"ok","link":"'.$name.'"}'; } - else - $a='{"answer":"nok"}'; +else + $a='{"answer":"nok"}'; header("Content-type: text/html; charset: utf8",true); print $a; ?> diff --git a/html/backup.php b/html/backup.php index 1f56804e2..82c2251f8 100644 --- a/html/backup.php +++ b/html/backup.php @@ -29,50 +29,55 @@ $User=new User($rep); $User->Check(); -if ($User->admin != 1) { - echo ""; - return; +if ($User->admin != 1) +{ + echo ""; + return; } /*!\file * \brief Make and restore backup */ -if ( isset ($_REQUEST['sa']) ) { - if ( defined ('PG_PATH') ) - putenv("PATH=".PG_PATH); - +if ( isset ($_REQUEST['sa']) ) +{ + if ( defined ('PG_PATH') ) + putenv("PATH=".PG_PATH); - if ( ! isset ($_REQUEST['d']) || - ! isset($_REQUEST['t'])) + + if ( ! isset ($_REQUEST['d']) || + ! isset($_REQUEST['t'])) { - echo "Erreur : paramètre manquant "; - exit(); - } - - $sa=$_REQUEST['sa']; - // backup - if ( $sa=='b') { - $cmd=escapeshellcmd (PG_DUMP); - putenv("PGPASSWORD=".phpcompta_password); - putenv("PGUSER=".phpcompta_user); - - if ( $_REQUEST['t'] == 'd' ) { - $database=domaine."dossier".$_REQUEST['d']; - $args= " -Fc -Z9 --no-owner -p ".phpcompta_psql_port." ".$database; - header('Content-type: application/octet'); - header('Content-Disposition:attachment;filename="'.$database.'.bin"',FALSE); - - passthru ($cmd.$args,$a); - + echo "Erreur : paramètre manquant "; + exit(); } - if ( $_REQUEST['t'] == 'm' ) { - $database=domaine."mod".$_REQUEST['d']; - $args= " -Fc -Z9 --no-owner -p ".phpcompta_psql_port." ".$database; - header('Content-type: bin/x-application'); - header('Content-Disposition: attachment;filename="'.$database.'.bin"',FALSE); - $a=passthru ($cmd.$args); - } - } - } + $sa=$_REQUEST['sa']; + // backup + if ( $sa=='b') + { + $cmd=escapeshellcmd (PG_DUMP); + putenv("PGPASSWORD=".phpcompta_password); + putenv("PGUSER=".phpcompta_user); + + if ( $_REQUEST['t'] == 'd' ) + { + $database=domaine."dossier".$_REQUEST['d']; + $args= " -Fc -Z9 --no-owner -p ".phpcompta_psql_port." ".$database; + header('Content-type: application/octet'); + header('Content-Disposition:attachment;filename="'.$database.'.bin"',FALSE); + + passthru ($cmd.$args,$a); + + } + + if ( $_REQUEST['t'] == 'm' ) + { + $database=domaine."mod".$_REQUEST['d']; + $args= " -Fc -Z9 --no-owner -p ".phpcompta_psql_port." ".$database; + header('Content-type: bin/x-application'); + header('Content-Disposition: attachment;filename="'.$database.'.bin"',FALSE); + $a=passthru ($cmd.$args); + } + } +} diff --git a/html/bal_csv.php b/html/bal_csv.php index a19217dd9..7f1ef6e79 100644 --- a/html/bal_csv.php +++ b/html/bal_csv.php @@ -38,46 +38,50 @@ require_once ('class_user.php'); $User=new User($cn); $User->Check(); if ( $User->check_action(IMPBAL) == 0) - { +{ NoAccess(); exit; - } +} echo 'poste;libelle;deb;cred;solde deb;solde cred'; printf("\n"); $bal=new Acc_Balance($cn); $bal->jrn=null; -switch( $_GET['p_filter']){ +switch( $_GET['p_filter']) +{ case 0: - $bal->jrn=null; - break; + $bal->jrn=null; + break; case 1: - if ( isset($_GET['r_jrn'])) { - $selected=$_GET['r_jrn']; - $array_ledger=$User->get_ledger('ALL',3); - for ($e=0;$ejrn[]=$array_ledger[$e]['jrn_def_id']; + if ( isset($_GET['r_jrn'])) + { + $selected=$_GET['r_jrn']; + $array_ledger=$User->get_ledger('ALL',3); + for ($e=0;$ejrn[]=$array_ledger[$e]['jrn_def_id']; + } } - } - break; + break; case 2: - if ( isset($_GET['r_cat'])) $bal->filter_cat($_GET['r_cat']); - break; + if ( isset($_GET['r_cat'])) $bal->filter_cat($_GET['r_cat']); + break; } $bal->from_poste=$_GET['from_poste']; $bal->to_poste=$_GET['to_poste']; $row=$bal->get_row($_GET['from_periode'], - $_GET['to_periode']); -foreach ($row as $r) { - echo $r['poste'].';'. + $_GET['to_periode']); +foreach ($row as $r) +{ + echo $r['poste'].';'. $r['label'].';'. nb($r['sum_deb']).';'. nb($r['sum_cred']).';'. nb($r['solde_deb']).';'. nb($r['solde_cred']); - printf("\n"); + printf("\n"); } diff --git a/html/bilan.php b/html/bilan.php index 1f909a074..8e0ec0324 100644 --- a/html/bilan.php +++ b/html/bilan.php @@ -18,7 +18,7 @@ */ /* $Revision$ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*! \file +/*! \file * \brief send a Bilan in RTF format */ include_once("ac_common.php"); @@ -48,23 +48,23 @@ $bilan->load(); /*\!bug the headers shouldn't be sent here, but it doesn't work * a html header is send before, to fix asap */ if ( $bilan->b_type=='odt') - { - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Cache-Control: must-revalidate"); - header('Content-type: application/vnd.oasis.opendocument.text'); - header('Content-Disposition: attachment;filename="'.$bilan->b_name.'.odt"',FALSE); - header("Accept-Ranges: bytes"); +{ + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Cache-Control: must-revalidate"); + header('Content-type: application/vnd.oasis.opendocument.text'); + header('Content-Disposition: attachment;filename="'.$bilan->b_name.'.odt"',FALSE); + header("Accept-Ranges: bytes"); - } +} if ( $bilan->b_type=='ods') - { - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Cache-Control: must-revalidate"); - header('Content-type: application/vnd.oasis.opendocument.spreadsheet'); - header('Content-Disposition: attachment;filename="'.$bilan->b_name.'.ods"',FALSE); - header("Accept-Ranges: bytes"); +{ + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Cache-Control: must-revalidate"); + header('Content-type: application/vnd.oasis.opendocument.spreadsheet'); + header('Content-Disposition: attachment;filename="'.$bilan->b_name.'.ods"',FALSE); + header("Accept-Ranges: bytes"); - } +} $bilan->generate(); ?> diff --git a/html/ca_bc_csv.php b/html/ca_bc_csv.php index 2cde2ea61..af34c1eab 100644 --- a/html/ca_bc_csv.php +++ b/html/ca_bc_csv.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief export the operation in pdf */ diff --git a/html/ca_bc_pdf.php b/html/ca_bc_pdf.php index 4c1411151..19a0e47bc 100644 --- a/html/ca_bc_pdf.php +++ b/html/ca_bc_pdf.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief export the operation in pdf */ diff --git a/html/ca_bs_csv.php b/html/ca_bs_csv.php index a0f10524c..a6d798909 100644 --- a/html/ca_bs_csv.php +++ b/html/ca_bs_csv.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief export the operation in pdf */ header('Pragma: public'); diff --git a/html/ca_list_csv.php b/html/ca_list_csv.php index b985cb3cc..a1bb0276c 100644 --- a/html/ca_list_csv.php +++ b/html/ca_list_csv.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief export the operation in pdf * */ diff --git a/html/ca_list_pdf.php b/html/ca_list_pdf.php index ad1dae46c..b8821f4c0 100644 --- a/html/ca_list_pdf.php +++ b/html/ca_list_pdf.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief this file is used to print the listing of CA operation * */ diff --git a/html/caisse.php b/html/caisse.php index 0d40b9667..130970b59 100644 --- a/html/caisse.php +++ b/html/caisse.php @@ -1,54 +1,69 @@ - -'; + + '; for ($i=0;$i<10;$i++) - { +{ echo 'montant '; echo ''; echo '
'; - } +} for ($i=0; $i < 5;$i++) - { +{ echo ''; - } +} ?> - - + + diff --git a/html/category_pdf.php b/html/category_pdf.php index 9b4ac700e..858ed09da 100644 --- a/html/category_pdf.php +++ b/html/category_pdf.php @@ -1,31 +1,31 @@ category, export in PDF the history of a category - * of card - */ +/*!\file + * \brief Called by impress->category, export in PDF the history of a category + * of card + */ - // Security we check if user does exist and his privilege +// Security we check if user does exist and his privilege require_once('class_user.php'); require_once('class_database.php'); require_once('class_pdf.php'); @@ -51,154 +51,184 @@ $pdf->Cell(0,8,$name,0,1,'C'); $pdf->SetTitle($name,1); $pdf->SetAuthor('Phpcompta'); /* balance */ -if ( $_GET['histo'] == 4 ) { - $fd=new Fiche_Def($cn,$_REQUEST['cat']); - if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false ) { - $pdf->Cell(0,10, "Cette catégorie n'ayant pas de poste comptable n'a pas de balance"); - //Save PDF to file - $fDate=date('dmy-Hi'); - $pdf->Output("category-$fDate.pdf", 'I');exit; - } - $aCard=$cn->get_array("select f_id from vw_fiche_attr where fd_id=$1 order by vw_name ",array($_REQUEST['cat'])); - - if ( empty($aCard)) { - $pdf->Cell(0,10, "Aucune fiche trouvée");//Save PDF to file - $fDate=date('dmy-Hi'); - $pdf->Output("category-$fDate.pdf", 'I'); - exit;} - $pdf->SetFont('DejaVuCond','',7); - $pdf->Cell(30,7,'Quick Code',0,0,'L',0); - $pdf->Cell(80,7,'Libellé',0,0,'L',0); - $pdf->Cell(20,7,'Débit',0,0,'R',0); - $pdf->Cell(20,7,'Crédit',0,0,'R',0); - $pdf->Cell(20,7,'Solde',0,0,'R',0); - $pdf->Cell(20,7,'D/C',0,0,'C',0); - $pdf->Ln(); - $idx=0; - for ($i=0;$i < count($aCard);$i++) { - if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null ) exit; - $filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ". - " and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) "; - $oCard=new Fiche($cn,$aCard[$i]['f_id']); - $solde=$oCard->get_solde_detail($filter); - if ( $solde['debit'] == 0 && $solde['credit']==0) continue; - - if ( $idx % 2 == 0 ) { - $pdf->SetFillColor(220,221,255); - $fill=1; - } else { - $pdf->SetFillColor(0,0,0); - $fill=0; - } - $idx++; - - $pdf->Cell(30,7,$oCard->strAttribut(ATTR_DEF_QUICKCODE),0,0,'L',$fill); - $pdf->Cell(80,7,$oCard->strAttribut(ATTR_DEF_NAME),0,0,'L',$fill); - $pdf->Cell(20,7,sprintf('%.02f',$solde['debit']),0,0,'R',$fill); - $pdf->Cell(20,7,sprintf('%.02f',$solde['credit']),0,0,'R',$fill); - $pdf->Cell(20,7,sprintf('%.02f',abs($solde['solde'])),0,0,'R',$fill); - $pdf->Cell(20,7,(($solde['solde']<0)?'CRED':'DEB'),0,0,'C',$fill); - $pdf->Ln(); - } -} else { - $array=Fiche::get_fiche_def($cn,$_GET['cat'],'name_asc'); - /* - * You show now the result - */ - if ($array == null ) { - exit(); - } - $tab=array(13,25,55,20,20,12,20); - $align=array('L','L','L','R','R','R','R'); - - foreach($array as $row) { - $letter=new Lettering_Card($cn); - $letter->set_parameter('quick_code',$row->strAttribut(ATTR_DEF_QUICKCODE)); - $letter->set_parameter('start',$_GET['start']); - $letter->set_parameter('end',$_GET['end']); - // all - if ( $_GET['histo'] == 0 ) { - $letter->get_all(); +if ( $_GET['histo'] == 4 ) +{ + $fd=new Fiche_Def($cn,$_REQUEST['cat']); + if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false ) + { + $pdf->Cell(0,10, "Cette catégorie n'ayant pas de poste comptable n'a pas de balance"); + //Save PDF to file + $fDate=date('dmy-Hi'); + $pdf->Output("category-$fDate.pdf", 'I'); + exit; } + $aCard=$cn->get_array("select f_id from vw_fiche_attr where fd_id=$1 order by vw_name ",array($_REQUEST['cat'])); - // lettered - if ( $_GET['histo'] == 1 ) { - $letter->get_letter(); + if ( empty($aCard)) + { + $pdf->Cell(0,10, "Aucune fiche trouvée");//Save PDF to file + $fDate=date('dmy-Hi'); + $pdf->Output("category-$fDate.pdf", 'I'); + exit; } - // unlettered - if ( $_GET['histo'] == 2 ) { - $letter->get_unletter(); - } - /* skip if nothing to display */ - if (count($letter->content) == 0 ) continue; - $pdf->SetFont('DejaVuCond','',10); - - $pdf->Cell(0,7,$row->strAttribut(ATTR_DEF_NAME),1,1,'C'); - $pdf->SetFont('DejaVuCond','',7); - - $pdf->Cell($tab[0],7,'Date'); - $pdf->Cell($tab[1],7,'ref'); - $pdf->Cell($tab[1],7,'Int.'); - $pdf->Cell($tab[2],7,'Comm'); - $pdf->Cell(40,7,'Montant',0,0,'C'); - $pdf->Cell($tab[5],7,'Let.',0,0,'R'); - $pdf->Cell($tab[6],7,'Som. Let.',0,0,'R'); - $pdf->ln(); - - $amount_deb=0;$amount_cred=0; - for ($i=0;$icontent);$i++){ - if ( $i % 2 == 0 ) { - $pdf->SetFillColor(220,221,255); - $fill=1; - } else { - $pdf->SetFillColor(0,0,0); - $fill=0; - } - $pdf->SetFont('DejaVuCond','',7); - $row=$letter->content[$i]; - $str_date=shrink_date($row['j_date_fmt']); - - $pdf->Cell($tab[0],4,$str_date,0,0,$align[0],$fill); - $pdf->Cell($tab[1],4,$row['jr_pj_number'],0,0,$align[1],$fill); - $pdf->Cell($tab[1],4,$row['jr_internal'],0,0,$align[1],$fill); - $pdf->Cell($tab[2],4,$row['jr_comment'],0,0,$align[2],$fill); - if ( $row['j_debit'] == 't') { - $pdf->Cell($tab[3],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill); - $amount_deb+=$row['j_montant']; - $pdf->Cell($tab[4],4,"",0,0,'C',$fill); - } else { - $pdf->Cell($tab[3],4,"",0,0,'C',$fill); - $pdf->Cell($tab[4],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill); - $amount_cred+=$row['j_montant']; - } - if ($row['letter'] != -1 ) { - $pdf->Cell($tab[5],4,$row['letter'],0,0,$align[5],$fill); - // get sum for this lettering - $sql="select sum(j_montant) from jrnx where j_debit=$1 and j_id in ". - " (select j_id from jnt_letter join letter_deb using (jl_id) where jl_id=$2 union ". - " select j_id from jnt_letter join letter_cred using (jl_id) where jl_id=$3)"; - $sum=$cn->get_value($sql,array($row['j_debit'],$row['letter'],$row['letter'])); - $pdf->Cell($tab[6],4,sprintf('%.2f',$sum),'0','0','R',$fill); - } - else - $pdf->Cell($tab[5],4,"",0,0,'R',$fill); - $pdf->Ln(); - } - $pdf->SetFillColor(0,0,0); - $pdf->SetFont('DejaVuCond','B',8); - $debit =sprintf('Debit : % 12.2f',$amount_deb); - $credit=sprintf('Credit : % 12.2f',$amount_cred); - if ( $amount_deb>$amount_cred) $s='solde débiteur'; else $s='solde crediteur'; - $solde =sprintf('%s : % 12.2f',$s,(abs(round($amount_cred-$amount_deb,2)))); - - $pdf->Cell(0,6,$debit,0,0,'R');$pdf->ln(4); - $pdf->Cell(0,6,$credit,0,0,'R');$pdf->ln(4); - $pdf->Cell(0,6,$solde,0,0,'R');$pdf->ln(4); - + $pdf->Cell(30,7,'Quick Code',0,0,'L',0); + $pdf->Cell(80,7,'Libellé',0,0,'L',0); + $pdf->Cell(20,7,'Débit',0,0,'R',0); + $pdf->Cell(20,7,'Crédit',0,0,'R',0); + $pdf->Cell(20,7,'Solde',0,0,'R',0); + $pdf->Cell(20,7,'D/C',0,0,'C',0); $pdf->Ln(); - } + $idx=0; + for ($i=0;$i < count($aCard);$i++) + { + if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null ) exit; + $filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ". + " and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) "; + $oCard=new Fiche($cn,$aCard[$i]['f_id']); + $solde=$oCard->get_solde_detail($filter); + if ( $solde['debit'] == 0 && $solde['credit']==0) continue; + + if ( $idx % 2 == 0 ) + { + $pdf->SetFillColor(220,221,255); + $fill=1; + } + else + { + $pdf->SetFillColor(0,0,0); + $fill=0; + } + $idx++; + + $pdf->Cell(30,7,$oCard->strAttribut(ATTR_DEF_QUICKCODE),0,0,'L',$fill); + $pdf->Cell(80,7,$oCard->strAttribut(ATTR_DEF_NAME),0,0,'L',$fill); + $pdf->Cell(20,7,sprintf('%.02f',$solde['debit']),0,0,'R',$fill); + $pdf->Cell(20,7,sprintf('%.02f',$solde['credit']),0,0,'R',$fill); + $pdf->Cell(20,7,sprintf('%.02f',abs($solde['solde'])),0,0,'R',$fill); + $pdf->Cell(20,7,(($solde['solde']<0)?'CRED':'DEB'),0,0,'C',$fill); + $pdf->Ln(); + } +} +else +{ + $array=Fiche::get_fiche_def($cn,$_GET['cat'],'name_asc'); + /* + * You show now the result + */ + if ($array == null ) + { + exit(); + } + $tab=array(13,25,55,20,20,12,20); + $align=array('L','L','L','R','R','R','R'); + + foreach($array as $row) + { + $letter=new Lettering_Card($cn); + $letter->set_parameter('quick_code',$row->strAttribut(ATTR_DEF_QUICKCODE)); + $letter->set_parameter('start',$_GET['start']); + $letter->set_parameter('end',$_GET['end']); + // all + if ( $_GET['histo'] == 0 ) + { + $letter->get_all(); + } + + // lettered + if ( $_GET['histo'] == 1 ) + { + $letter->get_letter(); + } + // unlettered + if ( $_GET['histo'] == 2 ) + { + $letter->get_unletter(); + } + /* skip if nothing to display */ + if (count($letter->content) == 0 ) continue; + $pdf->SetFont('DejaVuCond','',10); + + $pdf->Cell(0,7,$row->strAttribut(ATTR_DEF_NAME),1,1,'C'); + + $pdf->SetFont('DejaVuCond','',7); + + $pdf->Cell($tab[0],7,'Date'); + $pdf->Cell($tab[1],7,'ref'); + $pdf->Cell($tab[1],7,'Int.'); + $pdf->Cell($tab[2],7,'Comm'); + $pdf->Cell(40,7,'Montant',0,0,'C'); + $pdf->Cell($tab[5],7,'Let.',0,0,'R'); + $pdf->Cell($tab[6],7,'Som. Let.',0,0,'R'); + $pdf->ln(); + + $amount_deb=0; + $amount_cred=0; + for ($i=0;$icontent);$i++) + { + if ( $i % 2 == 0 ) + { + $pdf->SetFillColor(220,221,255); + $fill=1; + } + else + { + $pdf->SetFillColor(0,0,0); + $fill=0; + } + $pdf->SetFont('DejaVuCond','',7); + $row=$letter->content[$i]; + $str_date=shrink_date($row['j_date_fmt']); + + $pdf->Cell($tab[0],4,$str_date,0,0,$align[0],$fill); + $pdf->Cell($tab[1],4,$row['jr_pj_number'],0,0,$align[1],$fill); + $pdf->Cell($tab[1],4,$row['jr_internal'],0,0,$align[1],$fill); + $pdf->Cell($tab[2],4,$row['jr_comment'],0,0,$align[2],$fill); + if ( $row['j_debit'] == 't') + { + $pdf->Cell($tab[3],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill); + $amount_deb+=$row['j_montant']; + $pdf->Cell($tab[4],4,"",0,0,'C',$fill); + } + else + { + $pdf->Cell($tab[3],4,"",0,0,'C',$fill); + $pdf->Cell($tab[4],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill); + $amount_cred+=$row['j_montant']; + } + if ($row['letter'] != -1 ) + { + $pdf->Cell($tab[5],4,$row['letter'],0,0,$align[5],$fill); + // get sum for this lettering + $sql="select sum(j_montant) from jrnx where j_debit=$1 and j_id in ". + " (select j_id from jnt_letter join letter_deb using (jl_id) where jl_id=$2 union ". + " select j_id from jnt_letter join letter_cred using (jl_id) where jl_id=$3)"; + $sum=$cn->get_value($sql,array($row['j_debit'],$row['letter'],$row['letter'])); + $pdf->Cell($tab[6],4,sprintf('%.2f',$sum),'0','0','R',$fill); + } + else + $pdf->Cell($tab[5],4,"",0,0,'R',$fill); + $pdf->Ln(); + } + $pdf->SetFillColor(0,0,0); + $pdf->SetFont('DejaVuCond','B',8); + $debit =sprintf('Debit : % 12.2f',$amount_deb); + $credit=sprintf('Credit : % 12.2f',$amount_cred); + if ( $amount_deb>$amount_cred) $s='solde débiteur'; + else $s='solde crediteur'; + $solde =sprintf('%s : % 12.2f',$s,(abs(round($amount_cred-$amount_deb,2)))); + + $pdf->Cell(0,6,$debit,0,0,'R'); + $pdf->ln(4); + $pdf->Cell(0,6,$credit,0,0,'R'); + $pdf->ln(4); + $pdf->Cell(0,6,$solde,0,0,'R'); + $pdf->ln(4); + + $pdf->Ln(); + } } //Save PDF to file $fDate=date('dmy-Hi'); -$pdf->Output("category-$fDate.pdf", 'I');exit; +$pdf->Output("category-$fDate.pdf", 'I'); +exit; diff --git a/html/commercial.php b/html/commercial.php index 932fa55c5..51af7a554 100644 --- a/html/commercial.php +++ b/html/commercial.php @@ -43,32 +43,36 @@ $rep=new Database($gDossier); require_once ("class_user.php"); $User=new User($rep); $User->Check(); -if ($User->check_dossier($gDossier)=='P') { - redirect("extension.php?".dossier::get(),0); - exit(); +if ($User->check_dossier($gDossier)=='P') +{ + redirect("extension.php?".dossier::get(),0); + exit(); } //----------------------------------------------------- // update preference //----------------------------------------------------- -if ( isset ( $_POST['style_user']) ) { - $User->update_global_pref('THEME',$_POST['style_user']); - $_SESSION['g_theme']=$_POST['style_user']; +if ( isset ( $_POST['style_user']) ) +{ + $User->update_global_pref('THEME',$_POST['style_user']); + $_SESSION['g_theme']=$_POST['style_user']; } // Met a jour le pagesize -if ( isset ( $_POST['p_size']) ) { - $User->update_global_pref('PAGESIZE',$_POST['p_size']); - $_SESSION['g_pagesize']=$_POST['p_size']; +if ( isset ( $_POST['p_size']) ) +{ + $User->update_global_pref('PAGESIZE',$_POST['p_size']); + $_SESSION['g_pagesize']=$_POST['p_size']; } /// html_page_start($_SESSION['g_theme'],"",""); -if ( ! isset ( $gDossier ) ) { - echo _("Vous devez choisir un dossier "); - exit -2; +if ( ! isset ( $gDossier ) ) +{ + echo _("Vous devez choisir un dossier "); + exit -2; } include_once("user_menu.php"); $str_dossier=dossier::get(); @@ -79,52 +83,54 @@ echo menu_tool('commercial.php'); echo '
'; $def=0; -if ( isset($_REQUEST['p_action'])) { - switch($_REQUEST['p_action']) { - case'tdb': - $def=1; - break; - case'client': - $def=2; - break; - case'tdb': - $def=1; - break; - case'supplier': - $def=3; - break; - case'adm': - $def=4; - break; - case'stock': - $def=5; - break; - case'fiche': - $def=6; - break; - case'prev': - $def=7; - break; - case'suivi_courrier': - $def=8; - break; - case'impress': - $def=9; - break; +if ( isset($_REQUEST['p_action'])) +{ + switch($_REQUEST['p_action']) + { + case'tdb': + $def=1; + break; + case'client': + $def=2; + break; + case'tdb': + $def=1; + break; + case'supplier': + $def=3; + break; + case'adm': + $def=4; + break; + case'stock': + $def=5; + break; + case'fiche': + $def=6; + break; + case'prev': + $def=7; + break; + case'suivi_courrier': + $def=8; + break; + case'impress': + $def=9; + break; - } + } } echo ShowItem(array( - array('?p_action=client&'.$str_dossier,_('Client'),'',2), - array('?p_action=supplier&'.$str_dossier,_('Fournisseur'),'',3), - array('?p_action=adm&'.$str_dossier,_('Administration'),'',4), - array('?p_action=impress&'.$str_dossier,_('Impression'),'',9), - array('?p_action=stock&'.$str_dossier,_('Stock'),'',5), - array('?p_action=fiche&'.$str_dossier,_('Fiche'),'',6), - array('?p_action=prev&'.$str_dossier,_('Prevision'),'',7), - array('?p_action=suivi_courrier&my_action&'.$str_dossier,_('Suivi'),'',8), - ), - 'H',"mtitle","mtitle",$def,' style="width:100%"'); + array('?p_action=client&'.$str_dossier,_('Client'),'',2), + array('?p_action=supplier&'.$str_dossier,_('Fournisseur'),'',3), + array('?p_action=adm&'.$str_dossier,_('Administration'),'',4), + array('?p_action=impress&'.$str_dossier,_('Impression'),'',9), + array('?p_action=stock&'.$str_dossier,_('Stock'),'',5), + array('?p_action=fiche&'.$str_dossier,_('Fiche'),'',6), + array('?p_action=prev&'.$str_dossier,_('Prevision'),'',7), + array('?p_action=suivi_courrier&my_action&'.$str_dossier,_('Suivi'),'',8), + ), + 'H',"mtitle","mtitle",$def,' style="width:100%"'); echo '
'; echo '
'; @@ -139,14 +145,14 @@ echo JS_AJAX_FICHE; //----------------------------------------------------- if ( $p_action == "pref" ) { - require_once("pref.inc.php"); + require_once("pref.inc.php"); } //----------------------------------------------------- // p_action == impression //----------------------------------------------------- if ( $p_action == "impress" ) { - require_once("impress.inc.php"); + require_once("impress.inc.php"); } @@ -155,77 +161,81 @@ if ( $p_action == "impress" ) //----------------------------------------------------- if ( $p_action == "adm" ) { - $User->can_request(GEADM,1); - require_once("adm.inc.php"); + $User->can_request(GEADM,1); + require_once("adm.inc.php"); } //----------------------------------------------------- // p_action == client //----------------------------------------------------- if ( $p_action == "client" ) { - $User->can_request(GECUST,1); - require_once("client.inc.php"); + $User->can_request(GECUST,1); + require_once("client.inc.php"); } // $p_action == fournisseur //----------------------------------------------------- // Fournisseur if ( $p_action == 'supplier') { - $User->can_request(GESUPPL,1); - require_once("supplier.inc.php"); + $User->can_request(GESUPPL,1); + require_once("supplier.inc.php"); } //----------------------------------------------------- // action if ( $p_action == 'suivi_courrier') { - $User->can_request(GECOUR,1); - require_once("action.inc.php"); + $User->can_request(GECOUR,1); + require_once("action.inc.php"); } //----------------------------------------------------- // Contact if ( $p_action == 'fiche') { - require_once("fiche.inc.php"); + require_once("fiche.inc.php"); } //----------------------------------------------------- // Impression if ( $p_action == 'impress') { - if ( $User->check_action(IMPRAP)==1 || - $User->check_action(IMPJRN)==1 || - $User->check_action(IMPFIC)==1 || - $User->check_action(IMPPOSTE)==1 || - $User->check_action(IMPBIL)==1 ) - require_once("impress.inc.php"); - else - $User->can_request(9999,1); + if ( $User->check_action(IMPRAP)==1 || + $User->check_action(IMPJRN)==1 || + $User->check_action(IMPFIC)==1 || + $User->check_action(IMPPOSTE)==1 || + $User->check_action(IMPBIL)==1 ) + require_once("impress.inc.php"); + else + $User->can_request(9999,1); } -if ( $p_action == 'fiche') { - require_once('fiche.inc.php'); +if ( $p_action == 'fiche') +{ + require_once('fiche.inc.php'); } -if ( $p_action == 'stock') { - require_once('stock.inc.php'); +if ( $p_action == 'stock') +{ + require_once('stock.inc.php'); +} +if ( $p_action=='periode') +{ + if ( $User->check_action(PARPER)==1 || + $User->check_action(PARCLO)==1) + require_once ('periode.inc.php'); + else + $User->can_request(9999,1); } -if ( $p_action=='periode') { - if ( $User->check_action(PARPER)==1 || - $User->check_action(PARCLO)==1) - require_once ('periode.inc.php'); - else - $User->can_request(9999,1); - } //----------------------------------------------------- // Expense if ( $p_action == 'defreport') { - $User->can_request(PARPREDE,1); - require_once("report.inc.php"); + $User->can_request(PARPREDE,1); + require_once("report.inc.php"); } /*---------------------------------------------------------------------- * Prevision * *----------------------------------------------------------------------*/ -if ( $p_action=='prev') { - $User->can_request(PREVCON,1); - require_once ('forecast.inc.php'); +if ( $p_action=='prev') +{ + $User->can_request(PREVCON,1); + require_once ('forecast.inc.php'); } diff --git a/html/compta.php b/html/compta.php index 92eb3e530..3a336b2df 100644 --- a/html/compta.php +++ b/html/compta.php @@ -30,10 +30,11 @@ $gDossier=dossier::id(); include_once ("ac_common.php"); $action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:''; $use_html=1; -if ( ! isset ($_SESSION['g_theme'])) { - echo '

'._(' Vous êtes déconnecté').'

'; - redirect('index.php',1); - exit(); +if ( ! isset ($_SESSION['g_theme'])) +{ + echo '

'._(' Vous êtes déconnecté').'

'; + redirect('index.php',1); + exit(); } //---------------------------------------------------------------------- @@ -45,9 +46,10 @@ $cn=new Database($gDossier); require_once ('class_user.php'); $User=new User($cn); $User->Check(); -if ($User->check_dossier($gDossier)=='P') { - redirect("extension.php?".dossier::get(),0); - exit(); +if ($User->check_dossier($gDossier)=='P') +{ + redirect("extension.php?".dossier::get(),0); + exit(); } require_once ('function_javascript.php'); html_page_start($_SESSION['g_theme']); @@ -61,37 +63,46 @@ echo '
'; // Get action // call impress sub-menu -if ( $action == 'impress' ) { - require_once('impress.inc.php'); +if ( $action == 'impress' ) +{ + require_once('impress.inc.php'); } -if ( $action == 'fiche') { +if ( $action == 'fiche') +{ - require_once('fiche.inc.php'); + require_once('fiche.inc.php'); } -if ( $action == 'stock') { - require_once('stock.inc.php'); +if ( $action == 'stock') +{ + require_once('stock.inc.php'); +} +if ( $action=='quick_writing') +{ + require_once ('quick_writing.inc.php'); +} +if ( $action == 'gl' ) +{ + require_once ('user_action_gl.php'); } -if ( $action=='quick_writing') { - require_once ('quick_writing.inc.php'); - } -if ( $action == 'gl' ) { - require_once ('user_action_gl.php'); - } if ( $action == 'ven' || - $action == 'client') { - require_once ('compta_ven.inc.php'); - } + $action == 'client') +{ + require_once ('compta_ven.inc.php'); +} if ( $action == 'ach' || - $action == 'fournisseur') { - require_once ('compta_ach.inc.php'); - } -if ( $action == 'fin') { - require_once ('compta_fin.inc.php'); - } -if ($action == 'let') { - require_once('letter.inc.php'); + $action == 'fournisseur') +{ + require_once ('compta_ach.inc.php'); +} +if ( $action == 'fin') +{ + require_once ('compta_fin.inc.php'); +} +if ($action == 'let') +{ + require_once('letter.inc.php'); } html_page_stop(); ?> diff --git a/html/comptanalytic.php b/html/comptanalytic.php index 7ef807368..cda35d336 100644 --- a/html/comptanalytic.php +++ b/html/comptanalytic.php @@ -63,67 +63,67 @@ echo '
'; echo menu_tool('comptanalytic.php'); $def=-1; if ( isset ($_REQUEST['p_action'])) - { +{ switch ($_REQUEST['p_action']) - { - case 'ca_pa': - $def=0; - break; - case 'ca_od': - $def=1; - break; - case 'ca_imp': - $def=2; - break; - case 'ca_groupe': - $def=3; - break; - } - } + { + case 'ca_pa': + $def=0; + break; + case 'ca_od': + $def=1; + break; + case 'ca_imp': + $def=2; + break; + case 'ca_groupe': + $def=3; + break; + } +} echo '
'; echo ShowItem(array( - array('?p_action=ca_pa&'.$str_dossier,'Plan Analytique',"Plan Analytique",0), - array('?p_action=ca_od&'.$str_dossier,'Opérations Diverses',"Permet d'enregistrer des operations sur la compta analytique",1), - array('?p_action=ca_groupe&'.$str_dossier,'Groupe','Regroupe les postes analytiques',3), - array('?p_action=ca_imp&'.$str_dossier,'Impression',"impression de rapport",2) - ), - 'H',"mtitle","mtitle",$def,' style="width:75%;margin-left:12%"'); + array('?p_action=ca_pa&'.$str_dossier,'Plan Analytique',"Plan Analytique",0), + array('?p_action=ca_od&'.$str_dossier,'Opérations Diverses',"Permet d'enregistrer des operations sur la compta analytique",1), + array('?p_action=ca_groupe&'.$str_dossier,'Groupe','Regroupe les postes analytiques',3), + array('?p_action=ca_imp&'.$str_dossier,'Impression',"impression de rapport",2) + ), + 'H',"mtitle","mtitle",$def,' style="width:75%;margin-left:12%"'); echo '
'; echo '
'; echo ''; if ( isset ($_REQUEST['p_action'])) - { +{ switch ($_REQUEST['p_action']) - { - case 'ca_pa': - $User->can_request(CAPA,1); - $def=0; - break; - case 'ca_od': - $User->can_request(CAOD,1); - $def=1; - break; - case 'ca_imp': - $User->can_request(CAIMP,1); - $def=2; - break; - case 'ca_groupe': - $User->can_request(CAGA,1); - $def=3; - break; - } - } + { + case 'ca_pa': + $User->can_request(CAPA,1); + $def=0; + break; + case 'ca_od': + $User->can_request(CAOD,1); + $def=1; + break; + case 'ca_imp': + $User->can_request(CAIMP,1); + $def=2; + break; + case 'ca_groupe': + $User->can_request(CAGA,1); + $def=3; + break; + } +} if ( !isset($_REQUEST['p_action'])) - exit(); + exit(); //----------------------------------------------------- // p_action == pref //----------------------------------------------------- if ( $_REQUEST['p_action'] == "pref" ) { - require_once("pref.inc.php"); - exit(); + require_once("pref.inc.php"); + exit(); } //--------------------------------------------------------------------------- @@ -131,31 +131,31 @@ if ( $_REQUEST['p_action'] == "pref" ) //--------------------------------------------------------------------------- // Plan Analytique if ($_REQUEST['p_action'] == 'ca_pa' ) - { +{ require_once('anc_pa.inc.php'); exit(); - } +} // Operations Diverses if ($_REQUEST['p_action'] == 'ca_od' ) - { - require_once('anc_od.inc.php'); - exit(); - } +{ + require_once('anc_od.inc.php'); + exit(); +} // Impression if ($_REQUEST['p_action'] == 'ca_groupe' ) - { - require_once('anc_group.inc.php'); - exit(); - } +{ + require_once('anc_group.inc.php'); + exit(); +} // Impression if ($_REQUEST['p_action'] == 'ca_imp' ) - { +{ echo '
'; require_once('anc_imp.inc.php'); echo '
'; exit(); - } +} diff --git a/html/compute.php b/html/compute.php index 7b649609f..dfdd23f89 100644 --- a/html/compute.php +++ b/html/compute.php @@ -41,38 +41,49 @@ require_once ('class_user.php'); // Check if the needed field does exist extract ($_GET); -foreach (array('t','c','p','q','n','gDossier') as $a) { - if ( ! isset (${$a}) ) { echo "error $a is not set "; exit();} +foreach (array('t','c','p','q','n','gDossier') as $a) +{ + if ( ! isset (${$a}) ) + { + echo "error $a is not set "; + exit(); + } + } $cn=new Database(dossier::id()); $User=new User($cn); $User->Check(); // Retrieve the rate of vat, it $t == -1 it means no VAT -if ( $t != -1 && isNumber($t) == 1 ){ - $tva_rate=new Acc_Tva($cn); - $tva_rate->set_parameter('id',$t); - /** - *if the tva_rate->load failed we don't compute tva - */ - if ( $tva_rate->load() != 0 ) { - $tva_rate->set_parameter('rate',0); - } +if ( $t != -1 && isNumber($t) == 1 ) +{ + $tva_rate=new Acc_Tva($cn); + $tva_rate->set_parameter('id',$t); + /** + *if the tva_rate->load failed we don't compute tva + */ + if ( $tva_rate->load() != 0 ) + { + $tva_rate->set_parameter('rate',0); + } } $total=new Acc_Compute(); bcscale(4); $amount=round(bcmul($p,$q),2); $total->set_parameter('amount',$amount); -if ( $t != -1 && isNumber($t) == 1 ) { - $total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate')); - $total->compute_vat(); - $tvac=bcadd($total->get_parameter('amount_vat'),$amount); - header("Content-type: text/html; charset: utf8",true); - echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}'; -} else { -/* there is no vat to compute */ - header("Content-type: text/html; charset: utf8",true); - echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"NA","tvac":"'.$amount.'"}'; +if ( $t != -1 && isNumber($t) == 1 ) +{ + $total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate')); + $total->compute_vat(); + $tvac=bcadd($total->get_parameter('amount_vat'),$amount); + header("Content-type: text/html; charset: utf8",true); + echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}'; +} +else +{ + /* there is no vat to compute */ + header("Content-type: text/html; charset: utf8",true); + echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"NA","tvac":"'.$amount.'"}'; } ?> diff --git a/html/extension.php b/html/extension.php index 4d29c2b57..4896bd37c 100644 --- a/html/extension.php +++ b/html/extension.php @@ -48,40 +48,43 @@ echo JS_INFOBULLE; /* show button to return to access */ echo "

".dossier::name()."

"; -if ( $only_plugin != 'P' ) { - // user with only plugin cannot go back to the dashboard -/* return button */ -$msg=_('Retour au tableau de bord'); -$hidden=dossier::hidden(); -echo ' -
-
'. - $hidden; - -echo HtmlInput::button_anchor(_('Préférence'),'user_pref.php'); -echo ' - -
-
-'; - - -} else { - $msg=_('Retour accueil'); -?> +if ( $only_plugin != 'P' ) +{ + // user with only plugin cannot go back to the dashboard + /* return button */ + $msg=_('Retour au tableau de bord'); + $hidden=dossier::hidden(); + echo '
-
-'. + $hidden; - - ?> + echo HtmlInput::button_anchor(_('Préférence'),'user_pref.php'); + echo ' +
- +
+
+ +
+
+ value=Extension::make_array($cn); $a->selected=(isset($_REQUEST['plugin_code']))?strtoupper($_REQUEST['plugin_code']):''; /* no plugin available */ -if ( count($a->value) == 0 ) {alert(j(_("Aucune extension disponible")));exit;} +if ( count($a->value) == 0 ) +{ + alert(j(_("Aucune extension disponible"))); + exit; +} /* only one plugin available then we don't propose a choice*/ -if ( count($a->value)==1 ) { - $_REQUEST['plugin_code']=$a->value[0]['value']; -} else { - echo '
'; - echo $hidden; - echo _('Extension').$a->input().HtmlInput::submit('go',_("Choix de l'extension")); - echo '
'; - echo '
'; +if ( count($a->value)==1 ) +{ + $_REQUEST['plugin_code']=$a->value[0]['value']; +} +else +{ + echo '
'; + echo $hidden; + echo _('Extension').$a->input().HtmlInput::submit('go',_("Choix de l'extension")); + echo '
'; + echo '
'; } require_once('ext_inc.php'); diff --git a/html/fiche_csv.php b/html/fiche_csv.php index 93409bac4..c6bd04205 100644 --- a/html/fiche_csv.php +++ b/html/fiche_csv.php @@ -40,40 +40,50 @@ $User->check_dossier($gDossier); $User->can_request(IMPFIC,0); -if ( isset ($_GET['fd_id'])) { - $fiche_def=new Fiche_Def($cn,$_GET ['fd_id']); - $fiche=new Fiche($cn); - $e=$fiche_def->GetByType(); - $o=0; - // Heading - $fiche_def->GetAttribut(); - foreach ($fiche_def->attribut as $attribut) { - if ( $o == 0 ) { - printf("%s",$attribut->ad_text); - $o=1; - }else { - printf(";%s",$attribut->ad_text); - } +if ( isset ($_GET['fd_id'])) +{ + $fiche_def=new Fiche_Def($cn,$_GET ['fd_id']); + $fiche=new Fiche($cn); + $e=$fiche_def->GetByType(); + $o=0; + // Heading + $fiche_def->GetAttribut(); + foreach ($fiche_def->attribut as $attribut) + { + if ( $o == 0 ) + { + printf("%s",$attribut->ad_text); + $o=1; + } + else + { + printf(";%s",$attribut->ad_text); + } } - printf("\n"); - $o=0; - // Details - usort($e,'fiche::cmp_name'); - foreach ($e as $detail) { - foreach ( $detail->attribut as $dattribut ) { - if ( $o == 0 ) { - printf("%s",$dattribut->av_text); - $o=1; - } else { - printf (";%s",$dattribut->av_text); - - } - } printf("\n"); $o=0; + // Details + usort($e,'fiche::cmp_name'); + foreach ($e as $detail) + { + foreach ( $detail->attribut as $dattribut ) + { + if ( $o == 0 ) + { + printf("%s",$dattribut->av_text); + $o=1; + } + else + { + printf (";%s",$dattribut->av_text); + + } + } + printf("\n"); + $o=0; } - } - exit; +} +exit; ?> diff --git a/html/fid.php b/html/fid.php index 9feb250e0..5ecd2bf3b 100644 --- a/html/fid.php +++ b/html/fid.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/*!\file * \brief Fid for the ajax request for cards * \see fiche_search.php * Valid parameter GET are @@ -56,82 +56,91 @@ $fPrice_purchase=(isset($_REQUEST['b']))?$_REQUEST['b']:'none'; if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) -{ - $jrn=FormatString($_GET['j']); - $d=FormatString($_GET['d']); +{ + $jrn=FormatString($_GET['j']); + $d=FormatString($_GET['d']); - if ( $jrn == -1 ) - $d='all'; - if ( strpos($d,'sql') == false ) { + if ( $jrn == -1 ) + $d='all'; + if ( strpos($d,'sql') == false ) + { - switch ($d) { - case 'cred': - $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn)); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - - break; - case 'deb': - $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn)); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - break; - case 'all': - $filter_card=""; - break; - case 'filter': - $get_cred='jrn_def_fiche_cred'; - $get_deb='jrn_def_fiche_deb'; - $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$1",array($jrn)); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + switch ($d) + { + case 'cred': + $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn)); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - break; - case 'all': - $filter_card=''; - break; + break; + case 'deb': + $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn)); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + break; + case 'all': + $filter_card=""; + break; + case 'filter': + $get_cred='jrn_def_fiche_cred'; + $get_deb='jrn_def_fiche_deb'; + $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$1",array($jrn)); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - default: - $filter_card="and fd_id in ($d)"; + break; + case 'all': + $filter_card=''; + break; + + default: + $filter_card="and fd_id in ($d)"; + } } - } else { - $filter_card=$d; - $filter_card=str_replace('[sql]','',$d); - } - $sql="select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id - from vw_fiche_attr - where quick_code=upper($1)". $filter_card; + else + { + $filter_card=$d; + $filter_card=str_replace('[sql]','',$d); + } + $sql="select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id + from vw_fiche_attr + where quick_code=upper($1)". $filter_card; - $array=$cn->get_array($sql, array($_REQUEST['FID'])); + $array=$cn->get_array($sql, array($_REQUEST['FID'])); - if ( empty($array)) { echo '{"answer":"nok","flabel":"'.$fLabel.'"}'; exit;} + if ( empty($array)) + { + echo '{"answer":"nok","flabel":"'.$fLabel.'"}'; + exit; + } - $name=$array[0]['vw_name']; - $sell=$array[0]['vw_sell'] ; - $buy=$array[0]['vw_buy']; - $tva_id=$array[0]['tva_id']; + $name=$array[0]['vw_name']; + $sell=$array[0]['vw_sell'] ; + $buy=$array[0]['vw_buy']; + $tva_id=$array[0]['tva_id']; - // Check null - $name=($name==null)?" ":str_replace('"','',$name); - $sell=($sell==null)?" ":str_replace('"','',$sell); - $buy=($buy==null)?" ":str_replace('"','',$buy); - $tva_id=($tva_id==null)?" ":str_replace('"','',$tva_id); - /* store the answer in an array and transform it later into a JSON object */ - $tmp=array(); - $tmp[]=array('flabel',$fLabel); - $tmp[]=array('name',h($name)); - $tmp[]=array('ftva_id',$fTva_id); - $tmp[]=array('tva_id',$tva_id); - $tmp[]=array('fPrice_sale',$fPrice_sale); - $tmp[]=array('sell',$sell); - $tmp[]=array('fPrice_purchase',$fPrice_purchase); - $tmp[]=array('buy',$buy); - $a='{"answer":"ok"'; - for ($o=0;$o < count($tmp);$o++) { - $a.=sprintf(',"%s":"%s"',$tmp[$o][0],$tmp[$o][1]); - } - $a.='}'; + // Check null + $name=($name==null)?" ":str_replace('"','',$name); + $sell=($sell==null)?" ":str_replace('"','',$sell); + $buy=($buy==null)?" ":str_replace('"','',$buy); + $tva_id=($tva_id==null)?" ":str_replace('"','',$tva_id); + /* store the answer in an array and transform it later into a JSON object */ + $tmp=array(); + $tmp[]=array('flabel',$fLabel); + $tmp[]=array('name',h($name)); + $tmp[]=array('ftva_id',$fTva_id); + $tmp[]=array('tva_id',$tva_id); + $tmp[]=array('fPrice_sale',$fPrice_sale); + $tmp[]=array('sell',$sell); + $tmp[]=array('fPrice_purchase',$fPrice_purchase); + $tmp[]=array('buy',$buy); + $a='{"answer":"ok"'; + for ($o=0;$o < count($tmp);$o++) + { + $a.=sprintf(',"%s":"%s"',$tmp[$o][0],$tmp[$o][1]); + } + $a.='}'; } - else - $a='{"answer":"unauthorized"}'; +else + $a='{"answer":"unauthorized"}'; header("Content-type: text/html; charset: utf8",true); print $a; ?> diff --git a/html/fid_card.php b/html/fid_card.php index 7db093634..2e17067c5 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -8,7 +8,7 @@ * (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. @@ -54,46 +54,53 @@ $user=new User($cn); $user->check(); $user->check_dossier(dossier::id()); -switch ($d) { - case 'all': - $filter_card=''; - break; - - default: - $filter_card="and fd_id in ($d)"; +switch ($d) +{ +case 'all': + $filter_card=''; + break; + +default: + $filter_card="and fd_id in ($d)"; } -if ( $jrn != -1 ) { - switch ($d) { +if ( $jrn != -1 ) +{ + switch ($d) + { case 'cred': - $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn)); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - break; + $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn)); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + break; case 'deb': - $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn)); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - break; + $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn)); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + break; case 'filter': - $get_cred='jrn_def_fiche_cred'; - $get_deb='jrn_def_fiche_deb'; - $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$1",array($jrn)); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + $get_cred='jrn_def_fiche_cred'; + $get_deb='jrn_def_fiche_deb'; + $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$1",array($jrn)); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; - break; - - } -} else { - if (isset($_REQUEST['type'])) { - if ($_REQUEST['type']=='gl' || $_REQUEST['type']=='') $filter_card=''; - else { - $get_cred='jrn_def_fiche_cred'; - $get_deb='jrn_def_fiche_deb'; - - $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_type=$1",array($_REQUEST['type'])); - $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + break; } - } +} +else +{ + if (isset($_REQUEST['type'])) + { + if ($_REQUEST['type']=='gl' || $_REQUEST['type']=='') $filter_card=''; + else + { + $get_cred='jrn_def_fiche_cred'; + $get_deb='jrn_def_fiche_deb'; + + $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_type=$1",array($_REQUEST['type'])); + $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false '; + + } + } } @@ -108,39 +115,46 @@ $sql_str="select distinct f_id from fiche join jnt_fic_att_value using (f_id) jo $sql=$cn->get_array($sql_str ,array($_REQUEST['FID'])); -if (sizeof($sql) != 0 ) { - echo "
    "; - $sql_get=$cn->prepare('get_name',"select av_text from jnt_fic_att_value join attr_value using (jft_id) where f_id = $1 and ad_id=$2"); +if (sizeof($sql) != 0 ) +{ + echo "
      "; + $sql_get=$cn->prepare('get_name',"select av_text from jnt_fic_att_value join attr_value using (jft_id) where f_id = $1 and ad_id=$2"); - for ($i =0;$i<12 && $i < count($sql) ;$i++) { - $name='';$quick_code='';$desc=''; + for ($i =0;$i<12 && $i < count($sql) ;$i++) + { + $name=''; + $quick_code=''; + $desc=''; - $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],1)); - if ( Database::num_row($sql_name) == 1) $name=Database::fetch_result($sql_name,0,0); + $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],1)); + if ( Database::num_row($sql_name) == 1) $name=Database::fetch_result($sql_name,0,0); - $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],9)); - if ( Database::num_row($sql_name) == 1) $desc=Database::fetch_result($sql_name,0,0); + $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],9)); + if ( Database::num_row($sql_name) == 1) $desc=Database::fetch_result($sql_name,0,0); - $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23)); - if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0); + $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23)); + if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0); - /* Highlight the found pattern with bold format */ - $name=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($name)); - $qcode=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($quick_code)); - $desc=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($desc)); - printf('
    • %s %s %s
    • ', - $quick_code, - $quick_code, - $name, - $desc - ); - } - echo '
    '; - if (count($sql) > 12) { - printf ('...Résultat limité à 12 ...'); - } -} else { - echo "
    • Non trouvé
    "; + /* Highlight the found pattern with bold format */ + $name=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($name)); + $qcode=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($quick_code)); + $desc=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($desc)); + printf('
  • %s %s %s
  • ', + $quick_code, + $quick_code, + $name, + $desc + ); + } + echo '
'; + if (count($sql) > 12) + { + printf ('...Résultat limité à 12 ...'); + } +} +else +{ + echo "
  • Non trouvé
"; } ?> diff --git a/html/form_csv.php b/html/form_csv.php index dab8698ec..1729a04e9 100644 --- a/html/form_csv.php +++ b/html/form_csv.php @@ -45,63 +45,64 @@ $Form->get_name(); // Step ? //-- if ( $_GET['p_step'] == 0 ) - { - if ( $_GET ['type_periode'] == 0 ) - $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']); - else - $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']); +{ + if ( $_GET ['type_periode'] == 0 ) + $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']); + else + $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']); - if ( count($Form->row ) == 0 ) - exit; - + if ( count($Form->row ) == 0 ) + exit; + echo "\"Description\";". - "\"Montant\"\n"; + "\"Montant\"\n"; - foreach ( $Form->row as $op ) { - echo '"'.$op['desc'].'"'.";". - nb($op['montant']). - "\n"; - + foreach ( $Form->row as $op ) + { + echo '"'.$op['desc'].'"'.";". + nb($op['montant']). + "\n"; + } - } - else - { - // Gather all the data - //--- - for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step']) - { - $periode=getPeriodeName($cn,$e); - if ( $periode == null ) continue; - $array[]=$Form->get_row($e,$e); - $periode_name[]=$periode; - } - // Display column heading - //-- - $x=""; - printf ("Mois;"); - foreach ($array[0] as $e) - { - printf("%s%s",$x,$e['desc']); - $x=";"; +} +else +{ + // Gather all the data + //--- + for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step']) + { + $periode=getPeriodeName($cn,$e); + if ( $periode == null ) continue; + $array[]=$Form->get_row($e,$e); + $periode_name[]=$periode; + } + // Display column heading + //-- + $x=""; + printf ("Mois;"); + foreach ($array[0] as $e) + { + printf("%s%s",$x,$e['desc']); + $x=";"; - } - printf("\n"); - // Display value for each line - //-- - $a=0; - foreach ($array as $e ) - { - print $periode_name[$a]; - $a++; - foreach ($e as $elt) - { - printf(";%s",nb($elt['montant'])); - } - printf("\n"); - } - } - exit; + } + printf("\n"); + // Display value for each line + //-- + $a=0; + foreach ($array as $e ) + { + print $periode_name[$a]; + $a++; + foreach ($e as $elt) + { + printf(";%s",nb($elt['montant'])); + } + printf("\n"); + } +} +exit; ?> diff --git a/html/form_pdf.php b/html/form_pdf.php index 133d95f44..a9e0666dd 100644 --- a/html/form_pdf.php +++ b/html/form_pdf.php @@ -51,67 +51,77 @@ $pdf->AddPage(); // Step ?? //-- -if ( $_GET['p_step'] == 0 ) - { +if ( $_GET['p_step'] == 0 ) +{ // No step asked //-- - if ( $_GET ['type_periode'] == 0 ) - $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']); - else - $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']); + if ( $_GET ['type_periode'] == 0 ) + $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']); + else + $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']); - } - else - { - // yes with step - //-- - for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step']) - { - $periode=getPeriodeName($cn,$e); - if ( $periode == null ) continue; - $array[]=$Form->get_row($e,$e,'periode'); - $periode_name[]=$periode; - } +} +else +{ + // yes with step + //-- + for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step']) + { + $periode=getPeriodeName($cn,$e); + if ( $periode == null ) continue; + $array[]=$Form->get_row($e,$e,'periode'); + $periode_name[]=$periode; + } + +} - } - $pdf->SetFont('DejaVuCond','',8); -// without step -if ( $_GET['p_step'] == 0 ) - { - if ( $_GET['type_periode'] == 0 ) { - $q=getPeriodeName($cn,$from_periode); - if ( $from_periode != $to_periode){ - $periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode)); - } else { - $periode=sprintf("Période %s",$q); - } - } else { - $periode=sprintf("Date %s jusque %s",$_GET['from_date'],$_GET['to_date']); - } - $pdf->Cell(0,7,$periode,'B');$pdf->Ln(); - for ($i=0;$iCell(160,6,$array[$i]['desc']); - $pdf->Cell(30,6,sprintf('% 12.2f',$array[$i]['montant']),0,0,'R'); - $pdf->Ln(); - } - } - else - { // With Step - $a=0; - foreach ($array as $e) - { - $pdf->Cell(0,7,$periode_name[$a],'B');$pdf->Ln(); - $a++; - for ($i=0;$iCell(160,6,$e[$i]['desc']); - $pdf->Cell(30,6,sprintf('% 12.2f',$e[$i]['montant']),0,0,'R'); - $pdf->Ln(); - } - } - } +// without step +if ( $_GET['p_step'] == 0 ) +{ + if ( $_GET['type_periode'] == 0 ) + { + $q=getPeriodeName($cn,$from_periode); + if ( $from_periode != $to_periode) + { + $periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode)); + } + else + { + $periode=sprintf("Période %s",$q); + } + } + else + { + $periode=sprintf("Date %s jusque %s",$_GET['from_date'],$_GET['to_date']); + } + $pdf->Cell(0,7,$periode,'B'); + $pdf->Ln(); + for ($i=0;$iCell(160,6,$array[$i]['desc']); + $pdf->Cell(30,6,sprintf('% 12.2f',$array[$i]['montant']),0,0,'R'); + $pdf->Ln(); + } +} +else +{ // With Step + $a=0; + foreach ($array as $e) + { + $pdf->Cell(0,7,$periode_name[$a],'B'); + $pdf->Ln(); + $a++; + for ($i=0;$iCell(160,6,$e[$i]['desc']); + $pdf->Cell(30,6,sprintf('% 12.2f',$e[$i]['montant']),0,0,'R'); + $pdf->Ln(); + } + } +} $fDate=date('dmy-Hi'); $pdf->Output('rapport-'.$fDate.'.pdf','I'); diff --git a/html/get_pj.php b/html/get_pj.php index 4662b822b..d6528f603 100644 --- a/html/get_pj.php +++ b/html/get_pj.php @@ -26,7 +26,7 @@ * - l for ledger * - gDossier * Must return at least tva, htva and tvac - + */ require_once ('constant.php'); @@ -37,10 +37,19 @@ require_once ('class_user.php'); // Check if the needed field does exist extract ($_GET); -foreach (array('l','gDossier') as $a) { - if ( ! isset (${$a}) ) { echo "error $a is not set "; exit();} +foreach (array('l','gDossier') as $a) +{ + if ( ! isset (${$a}) ) + { + echo "error $a is not set "; + exit(); + } + +} +if ( myereg('^[0-9]+$',$l) == false ) +{ + exit(); } -if ( myereg('^[0-9]+$',$l) == false ) {exit();} $cn=new Database(dossier::id()); $User=new User($cn); $User->Check(); diff --git a/html/get_predef.php b/html/get_predef.php index c2e5e8f1a..7388e6fe3 100644 --- a/html/get_predef.php +++ b/html/get_predef.php @@ -34,8 +34,14 @@ require_once('class_dossier.php'); require_once('class_pre_operation.php'); // Check if the needed field does exist extract ($_GET); -foreach (array('l','t','d','gDossier') as $a) { - if ( ! isset (${$a}) ) { echo "error $a is not set "; exit();} +foreach (array('l','t','d','gDossier') as $a) +{ + if ( ! isset (${$a}) ) + { + echo "error $a is not set "; + exit(); + } + } $cn=new Database(dossier::id()); $op=new Pre_operation_detail($cn); @@ -46,11 +52,12 @@ $array=$op->get_operation(); $string='{"count":"'.count($array).'"'; $idx=0; if (! empty($array)) - foreach ($array as $a) { + foreach ($array as $a) +{ $string.=',"value'.$idx.'":"'.$a['value'].'",'; $string.='"label'.$idx.'":"'.$a['label'].'"'; $idx++; - } +} $string.="}"; header("Content-type: text/json; charset: utf8",true); diff --git a/html/get_saldo.php b/html/get_saldo.php index b27430664..552c47158 100644 --- a/html/get_saldo.php +++ b/html/get_saldo.php @@ -31,11 +31,13 @@ require_once('class_dossier.php'); require_once('class_fiche.php'); extract($_GET); /* check the parameters */ -foreach ( array('j','ctl') as $a ) { - if ( ! isset(${$a}) ) { - echo "missing $a"; - return; - } +foreach ( array('j','ctl') as $a ) +{ + if ( ! isset(${$a}) ) + { + echo "missing $a"; + return; + } } $cn=new Database(dossier::id()); @@ -45,13 +47,13 @@ if ( $user->check_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}'; /* make a filter on the exercice */ $filter_year=" j_tech_per in (select p_id from parm_periode ". - "where p_exercice='".$user->get_exercice()."')"; + "where p_exercice='".$user->get_exercice()."')"; $acc=new Fiche($cn); $acc->get_by_qcode($_GET['ctl'],false); if ( $acc->belong_ledger($_GET['j']) == -1 ) - return '{"saldo":"0"}'; + return '{"saldo":"0"}'; $res=$acc->get_solde_detail($filter_year); diff --git a/html/gl_comptes_csv.php b/html/gl_comptes_csv.php index 769e2d79a..d68e91ff3 100644 --- a/html/gl_comptes_csv.php +++ b/html/gl_comptes_csv.php @@ -49,48 +49,58 @@ $User->can_request(IMPBIL,0); extract($_GET); -if ( isset($poste_id) && strlen(trim($poste_id)) != 0 && isNumber($poste_id) ) { - if ( isset ($poste_fille) ) { - $parent=$poste_id; - $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '$parent%' order by pcm_val::text"); - } elseif ( $cn->count_sql('select * from tmp_pcmn where pcm_val='.FormatString($poste_id)) != 0 ) { - $a_poste=array('pcm_val' => $poste_id); +if ( isset($poste_id) && strlen(trim($poste_id)) != 0 && isNumber($poste_id) ) +{ + if ( isset ($poste_fille) ) + { + $parent=$poste_id; + $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '$parent%' order by pcm_val::text"); } -} else { - $a_poste=$cn->get_array("select pcm_val from tmp_pcmn order by pcm_val::text"); + elseif ( $cn->count_sql('select * from tmp_pcmn where pcm_val='.FormatString($poste_id)) != 0 ) + { + $a_poste=array('pcm_val' => $poste_id); + } +} +else +{ + $a_poste=$cn->get_array("select pcm_val from tmp_pcmn order by pcm_val::text"); } -if ( count($a_poste) == 0 ) { - echo 'Rien à rapporter.'; - printf("\n"); - exit; +if ( count($a_poste) == 0 ) +{ + echo 'Rien à rapporter.'; + printf("\n"); + exit; } // Header $header = array( "Date", "Référence", "Libellé", "Pièce", "Débit", "Crédit", "Solde" ); -foreach ($a_poste as $poste) { +foreach ($a_poste as $poste) +{ $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']); list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode); // don't print empty account - if ( count($array) == 0 ) { - continue; + if ( count($array) == 0 ) + { + continue; } echo sprintf("%s - %s ",$Poste->id,$Poste->get_name()); printf("\n"); for($i=0;$irow as $detail) { + foreach ($Poste->row as $detail) + { /* [0] => 1 [jr_id] => 1 @@ -105,37 +115,39 @@ foreach ($a_poste as $poste) { [9] => ODS1 [jr_pj_number] => ODS1 ) 1 */ - if ($detail['cred_montant'] > 0) { + if ($detail['cred_montant'] > 0) + { $solde += $detail['cred_montant']; $solde_c += $detail['cred_montant']; - } - if ($detail['deb_montant'] > 0) { + } + if ($detail['deb_montant'] > 0) + { $solde -= $detail['deb_montant']; $solde_d += $detail['deb_montant']; - } - - echo $detail['j_date_fmt'].";"; - echo $detail['jr_internal'].";"; - echo $detail['description'].";"; - echo $detail['jr_pj_number'].";"; - echo ($detail['deb_montant'] > 0 ? sprintf("%.2f", $detail['deb_montant']) : '').";"; - echo ($detail['cred_montant'] > 0 ? sprintf("%.2f", $detail['cred_montant']) : '').";"; - echo sprintf("%.2f", $solde).";"; - printf("\n"); - } + echo $detail['j_date_fmt'].";"; + echo $detail['jr_internal'].";"; + echo $detail['description'].";"; + echo $detail['jr_pj_number'].";"; + echo ($detail['deb_montant'] > 0 ? sprintf("%.2f", $detail['deb_montant']) : '').";"; + echo ($detail['cred_montant'] > 0 ? sprintf("%.2f", $detail['cred_montant']) : '').";"; + echo sprintf("%.2f", $solde).";"; + printf("\n"); - echo ";"; - echo ";"; - echo ";"; - echo 'Total du compte '.$Poste->id.";"; - echo ($solde_d > 0 ? sprintf("%.2f", $solde_d) : '').";"; - echo ($solde_c > 0 ? sprintf("%.2f", $solde_c) : '').";"; - echo sprintf("%.2f", abs($solde_c-$solde_d)).";"; - echo ($solde_c > $solde_d ? 'C' : 'D').";"; - printf("\n"); - printf("\n"); + } + + + echo ";"; + echo ";"; + echo ";"; + echo 'Total du compte '.$Poste->id.";"; + echo ($solde_d > 0 ? sprintf("%.2f", $solde_d) : '').";"; + echo ($solde_c > 0 ? sprintf("%.2f", $solde_c) : '').";"; + echo sprintf("%.2f", abs($solde_c-$solde_d)).";"; + echo ($solde_c > $solde_d ? 'C' : 'D').";"; + printf("\n"); + printf("\n"); } exit; diff --git a/html/gl_comptes_pdf.php b/html/gl_comptes_pdf.php index dfac4a273..ebaa01189 100644 --- a/html/gl_comptes_pdf.php +++ b/html/gl_comptes_pdf.php @@ -51,9 +51,10 @@ $pdf->AliasNbPages(); $pdf->AddPage(); $a_poste=$cn->get_array("select pcm_val from tmp_pcmn order by pcm_val::text"); -if ( count($a_poste) == 0 ) { - $pdf->Output(); - return; +if ( count($a_poste) == 0 ) +{ + $pdf->Output(); + return; } // Header @@ -63,14 +64,16 @@ $lor = array( "L" , "L" , "L" , "L" , "R", "R" , "R" // Column widths (in mm) $width = array( 13 , 20 , 60 , 15 , 12 , 20 , 20 , 20 ); -foreach ($a_poste as $poste) { +foreach ($a_poste as $poste) +{ $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']); list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode); // don't print empty account - if ( count($array) == 0 ) { - continue; + if ( count($array) == 0 ) + { + continue; } $pdf->SetFont('DejaVuCond','',10); @@ -79,7 +82,7 @@ foreach ($a_poste as $poste) { $pdf->SetFont('DejaVuCond','',6); for($i=0;$iCell($width[$i], 4, $header[$i], 0, 0, $lor[$i]); + $pdf->Cell($width[$i], 4, $header[$i], 0, 0, $lor[$i]); $pdf->Ln(); $pdf->SetFont('DejaVuCond','',7); @@ -89,7 +92,8 @@ foreach ($a_poste as $poste) { $solde_d = 0.0; $solde_c = 0.0; - foreach ($Poste->row as $detail) { + foreach ($Poste->row as $detail) + { /* [0] => 1 [jr_id] => 1 @@ -104,48 +108,67 @@ foreach ($a_poste as $poste) { [9] => ODS1 [jr_pj_number] => ODS1 ) 1 */ - if ($detail['cred_montant'] > 0) { + if ($detail['cred_montant'] > 0) + { $solde += $detail['cred_montant']; $solde_c += $detail['cred_montant']; - } - if ($detail['deb_montant'] > 0) { + } + if ($detail['deb_montant'] > 0) + { $solde -= $detail['deb_montant']; $solde_d += $detail['deb_montant']; - } - - $i = 0; - - $pdf->Cell($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, $detail['jr_internal'], 0, 0, $lor[$i]); $i++; - /* limit set to 20 for the substring */ - $pdf->Cell($width[$i], 6, substr($detail['description'],0,42), 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, ($detail['letter']!=-1)?$detail['letter']:'', 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, ($detail['deb_montant'] > 0 ? sprintf("%.2f", $detail['deb_montant']) : ''), 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, ($detail['cred_montant'] > 0 ? sprintf("%.2f", $detail['cred_montant']) : ''), 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, sprintf("%.2f", $solde), 0, 0, $lor[$i]); $i++; - $pdf->Ln(); - } - - $pdf->SetFont('DejaVuCond','B',8); - $i = 0; - $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, 'Total du compte '.$Poste->id, 0, 0, 'R'); $i++; - $pdf->Cell($width[$i], 6, ($solde_d > 0 ? sprintf("%.2f", $solde_d) : ''), 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, ($solde_c > 0 ? sprintf("%.2f", $solde_c) : ''), 0, 0, $lor[$i]); $i++; - $pdf->Cell($width[$i], 6, sprintf("%.2f", abs($solde_c-$solde_d)), 0, 0, $lor[$i]); $i++; - $pdf->Cell(5, 6, ($solde_c > $solde_d ? 'C' : 'D'), 0, 0, 'L'); + $pdf->Cell($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, $detail['jr_internal'], 0, 0, $lor[$i]); + $i++; + /* limit set to 20 for the substring */ + $pdf->Cell($width[$i], 6, substr($detail['description'],0,42), 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, ($detail['letter']!=-1)?$detail['letter']:'', 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, ($detail['deb_montant'] > 0 ? sprintf("%.2f", $detail['deb_montant']) : ''), 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, ($detail['cred_montant'] > 0 ? sprintf("%.2f", $detail['cred_montant']) : ''), 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, sprintf("%.2f", $solde), 0, 0, $lor[$i]); + $i++; $pdf->Ln(); - $pdf->Ln(); + + } + + + $pdf->SetFont('DejaVuCond','B',8); + + $i = 0; + $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, '', 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, 'Total du compte '.$Poste->id, 0, 0, 'R'); + $i++; + $pdf->Cell($width[$i], 6, ($solde_d > 0 ? sprintf("%.2f", $solde_d) : ''), 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, ($solde_c > 0 ? sprintf("%.2f", $solde_c) : ''), 0, 0, $lor[$i]); + $i++; + $pdf->Cell($width[$i], 6, sprintf("%.2f", abs($solde_c-$solde_d)), 0, 0, $lor[$i]); + $i++; + $pdf->Cell(5, 6, ($solde_c > $solde_d ? 'C' : 'D'), 0, 0, 'L'); + + $pdf->Ln(); + $pdf->Ln(); } //Save PDF to file -$pdf->Output("gl_comptes.pdf", 'I');exit; +$pdf->Output("gl_comptes.pdf", 'I'); +exit; ?> diff --git a/html/import.php b/html/import.php index 9765da161..8e0d0e6db 100644 --- a/html/import.php +++ b/html/import.php @@ -1,27 +1,27 @@ '; // if action is set proceed to it -if ( isset ($_GET["action"]) ) { - $action=$_GET["action"]; - // menu = import cvs - if ($action == "import" ) { - if(isset($_FILES['fupload'])) { - // load the table with the cvs' content - echo '
'; - ImportCSV($cn,$_FILES['fupload']['tmp_name'],$_POST['import_bq'],$_POST['format_csv'],$_POST['import_jrn']); - echo "
"; - } else { - echo '
'; - ShowFormTransfert($cn); - echo "
"; +if ( isset ($_GET["action"]) ) +{ + $action=$_GET["action"]; + // menu = import cvs + if ($action == "import" ) + { + if(isset($_FILES['fupload'])) + { + // load the table with the cvs' content + echo '
'; + ImportCSV($cn,$_FILES['fupload']['tmp_name'],$_POST['import_bq'],$_POST['format_csv'],$_POST['import_jrn']); + echo "
"; + } + else + { + echo '
'; + ShowFormTransfert($cn); + echo "
"; + } + } + if ($action == "verif" ) + { + echo '
'; + VerifImport($cn); + echo "
"; } - } - if ($action == "verif" ) { - echo '
'; - VerifImport($cn); - echo "
"; - } - if ($action == "transfer" ) { + if ($action == "transfer" ) + { - echo '
'; - /* show the possible period */ - $default_period=$User->get_periode(); - $ip=new IPeriod('period'); - $ip->filter_year=true; - $ip->user=$User; - $ip->value=(isset($_GET['period']))?$_GET['period']:$default_period; - $ip->cn=$cn; - $ip->type=OPEN; - $ip->javascript="onchange=submit(this)"; - echo '
'; - echo dossier::hidden(); - echo HtmlInput::hidden('action','transfer'); - echo _('Choississez la période à transfèrer'); - echo $ip->input(); - echo '
'; - // TransferCSV($cn, - ConfirmTransfert($cn,$ip->value); - echo "
"; - } -} + echo '
'; + /* show the possible period */ + $default_period=$User->get_periode(); + $ip=new IPeriod('period'); + $ip->filter_year=true; + $ip->user=$User; + $ip->value=(isset($_GET['period']))?$_GET['period']:$default_period; + $ip->cn=$cn; + $ip->type=OPEN; + $ip->javascript="onchange=submit(this)"; + echo '
'; + echo dossier::hidden(); + echo HtmlInput::hidden('action','transfer'); + echo _('Choississez la période à transfèrer'); + echo $ip->input(); + echo '
'; + // TransferCSV($cn, + ConfirmTransfert($cn,$ip->value); + echo "
"; + } +} /*----------------------------------------------- * transfert or remove the wrong record * *-----------------------------------------------*/ -if ( isset ($_POST['action'])) { - $action=$_POST['action']; - if ($action == "transfer" ) { - echo '
'; - TransferCSV($cn, $User->get_periode()); - echo "
"; - } +if ( isset ($_POST['action'])) +{ + $action=$_POST['action']; + if ($action == "transfer" ) + { + echo '
'; + TransferCSV($cn, $User->get_periode()); + echo "
"; + } - if ($action == "remove" ) { - echo '
'; - RemoveCSV($cn); - ConfirmTransfert($cn,$User->get_periode()); - echo "
"; - } + if ($action == "remove" ) + { + echo '
'; + RemoveCSV($cn); + ConfirmTransfert($cn,$User->get_periode()); + echo "
"; + } } -if ( isset($_REQUEST['action']) && $_REQUEST['action']=='purge') { - if ( isset($_POST['ok'])) { - echo '
'; - echo h2info('Toutes les données CSV sont effacées'); - $cn->exec_sql('truncate import_tmp'); - echo '
'; +if ( isset($_REQUEST['action']) && $_REQUEST['action']=='purge') +{ + if ( isset($_POST['ok'])) + { + echo '
'; + echo h2info('Toutes les données CSV sont effacées'); + $cn->exec_sql('truncate import_tmp'); + echo '
'; - } else { - echo '
'; - echo '

En purgeant la table, vous effacez toutes les données des fichiers CSV que vous avez importés, -cela n\' affecte pas les opérations déjà transfèrées dans la comptabilité

'; - echo '
'; - echo HtmlInput::hidden('action','purge'); - echo HtmlInput::submit('ok','Purger'); - echo '
'; - echo '
'; + } + else + { + echo '
'; + echo '

En purgeant la table, vous effacez toutes les données des fichiers CSV que vous avez importés, + cela n\' affecte pas les opérations déjà transfèrées dans la comptabilité

'; + echo '
'; + echo HtmlInput::hidden('action','purge'); + echo HtmlInput::submit('ok','Purger'); + echo '
'; + echo '
'; } } html_page_stop(); diff --git a/html/index.php b/html/index.php index 5722a4abe..89c379001 100644 --- a/html/index.php +++ b/html/index.php @@ -107,10 +107,11 @@ * */ -if ( ! file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php')) { - $p_string='admin/setup.php'; - echo ' Connecting... '; - exit(0); +if ( ! file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php')) +{ + $p_string='admin/setup.php'; + echo ' Connecting... '; + exit(0); } echo ' @@ -120,66 +121,67 @@ echo ' PhpCompta '; $my_domain=""; require ('config.inc.php'); -if ( strlen(domaine) > 0 ) { - $my_domain="Domaine : ".domaine; +if ( strlen(domaine) > 0 ) +{ + $my_domain="Domaine : ".domaine; } echo ' @@ -191,7 +193,7 @@ version 5.2.SVNINFO - '.$my_domain.'

- Logo +Logo


@@ -214,7 +216,7 @@ version 5.2.SVNINFO - '.$my_domain.' - +
Pour une meilleure expérience web, nous vous conseillons firefox diff --git a/html/jrn_csv.php b/html/jrn_csv.php index 72ea45fa8..dea2b6b9e 100644 --- a/html/jrn_csv.php +++ b/html/jrn_csv.php @@ -42,8 +42,11 @@ $User->Check(); $User->can_request(IMPJRN,0); $User->check_dossier($gDossier); -if ($_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) =='X') { - NoAccess(); exit();} +if ($_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) =='X') +{ + NoAccess(); + exit(); +} $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); @@ -52,135 +55,140 @@ $jrn_type=$Jrn->get_type(); // Detailled printing //--- -if ( $_GET['p_simple'] == 0 ) - { +if ( $_GET['p_simple'] == 0 ) +{ $Jrn->get_row( $_GET['from_periode'], - $_GET['to_periode'] - ); + $_GET['to_periode'] + ); - if ( count($Jrn->row) == 0) - exit; - foreach ( $Jrn->row as $op ) { - // should clean description : remove tag and '; char - $desc=$op['description']; - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace("","",$desc); - $desc=str_replace('"',"'",$desc); - $desc=str_replace(";",",",$desc); + if ( count($Jrn->row) == 0) + exit; + foreach ( $Jrn->row as $op ) + { + // should clean description : remove tag and '; char + $desc=$op['description']; + $desc=str_replace("","",$desc); + $desc=str_replace("","",$desc); + $desc=str_replace("","",$desc); + $desc=str_replace("","",$desc); + $desc=str_replace('"',"'",$desc); + $desc=str_replace(";",",",$desc); + + printf("\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";%s;%s\n", + $op['j_id'], + $op['internal'], + $op['j_date'], + $op['poste'], + $desc, + nb($op['deb_montant']), + nb($op['cred_montant']) + ); - printf("\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";%s;%s\n", - $op['j_id'], - $op['internal'], - $op['j_date'], - $op['poste'], - $desc, - nb($op['deb_montant']), - nb($op['cred_montant']) - ); - } exit; - } - else - { - $Row=$Jrn->get_rowSimple($_GET['from_periode'], - $_GET['to_periode'], - 0); +} +else +{ + $Row=$Jrn->get_rowSimple($_GET['from_periode'], + $_GET['to_periode'], + 0); //----------------------------------------------------- - if ( $jrn_type == 'ODS' || $jrn_type == 'FIN' || $jrn_type=='GL') - { - printf ('" operation";'. - '"Date";'. - '"commentaire";'. - '"internal";'. - '"montant";'. - "\r\n"); - // set a filter for the FIN - $a_parm_code=$cn->get_array("select p_value from parm_code where p_code in ('BANQUE','COMPTE_COURANT','CAISSE')"); - $sql_fin="("; - $or=""; - foreach ($a_parm_code as $code) { - $sql_fin.="$or j_poste::text like '".$code['p_value']."%'"; - $or=" or "; - } - $sql_fin.=")"; + if ( $jrn_type == 'ODS' || $jrn_type == 'FIN' || $jrn_type=='GL') + { + printf ('" operation";'. + '"Date";'. + '"commentaire";'. + '"internal";'. + '"montant";'. + "\r\n"); + // set a filter for the FIN + $a_parm_code=$cn->get_array("select p_value from parm_code where p_code in ('BANQUE','COMPTE_COURANT','CAISSE')"); + $sql_fin="("; + $or=""; + foreach ($a_parm_code as $code) + { + $sql_fin.="$or j_poste::text like '".$code['p_value']."%'"; + $or=" or "; + } + $sql_fin.=")"; - foreach ($Row as $line) - { - - echo $line['num'].";"; - echo $line['date'].";"; - echo $line['comment'].";"; - echo $line['jr_internal'].";"; - // echo "".$line['pj'].";"; - // If the ledger is financial : - // the credit must be negative and written in red - // Get the jrn type - if ( $line['jrn_def_type'] == 'FIN' ) { - $positive = $cn->get_value("select qf_amount from quant_fin ". - " where jr_id=".$line['jr_id']); - - echo nb($positive); - echo ";"; - } - else - { - echo nb($line['montant']).";"; - } - - printf("\r\n"); - } - } + foreach ($Row as $line) + { + + echo $line['num'].";"; + echo $line['date'].";"; + echo $line['comment'].";"; + echo $line['jr_internal'].";"; + // echo "".$line['pj'].";"; + // If the ledger is financial : + // the credit must be negative and written in red + // Get the jrn type + if ( $line['jrn_def_type'] == 'FIN' ) + { + $positive = $cn->get_value("select qf_amount from quant_fin ". + " where jr_id=".$line['jr_id']); + + echo nb($positive); + echo ";"; + } + else + { + echo nb($line['montant']).";"; + } + + printf("\r\n"); + } + } //----------------------------------------------------- - if ( $jrn_type=='ACH' || $jrn_type=='VEN') - { - $own=new Own($cn); - $col_tva=""; + if ( $jrn_type=='ACH' || $jrn_type=='VEN') + { + $own=new Own($cn); + $col_tva=""; - if ( $own->MY_TVA_USE=='Y') { - $a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate"); - foreach($a_Tva as $line_tva) - { - $col_tva.='"Tva '.$line_tva['tva_label'].'";'; - } - } - echo '"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";'.$col_tva.'"TVAC"'."\n\r"; - foreach ($Row as $line) - { - printf('"%s";"%s";"%s";"%s";"%s";%s;', - $line['date'], - $line['num'], - $line['client'], - $line['comment'], - $line['jr_internal'], - nb($line['HTVA'])); - $a_tva_amount=array(); - foreach ($line['TVA'] as $lineTVA) - { - foreach ($a_Tva as $idx=>$line_tva) - { - - if ($line_tva['tva_id'] == $lineTVA[1][0]) - { - $a=$line_tva['tva_id']; - $a_tva_amount[$a]=$lineTVA[1][2]; - } - } - } - if ($own->MY_TVA_USE == 'Y' ) { - foreach ($a_Tva as $line_tva) - { - $a=$line_tva['tva_id']; - if ( isset($a_tva_amount[$a])) - echo nb($a_tva_amount[$a]); - else - printf("0;"); - } - } - echo nb ($line['TVAC']); - } - } - } + if ( $own->MY_TVA_USE=='Y') + { + $a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate"); + foreach($a_Tva as $line_tva) + { + $col_tva.='"Tva '.$line_tva['tva_label'].'";'; + } + } + echo '"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";'.$col_tva.'"TVAC"'."\n\r"; + foreach ($Row as $line) + { + printf('"%s";"%s";"%s";"%s";"%s";%s;', + $line['date'], + $line['num'], + $line['client'], + $line['comment'], + $line['jr_internal'], + nb($line['HTVA'])); + $a_tva_amount=array(); + foreach ($line['TVA'] as $lineTVA) + { + foreach ($a_Tva as $idx=>$line_tva) + { + + if ($line_tva['tva_id'] == $lineTVA[1][0]) + { + $a=$line_tva['tva_id']; + $a_tva_amount[$a]=$lineTVA[1][2]; + } + } + } + if ($own->MY_TVA_USE == 'Y' ) + { + foreach ($a_Tva as $line_tva) + { + $a=$line_tva['tva_id']; + if ( isset($a_tva_amount[$a])) + echo nb($a_tva_amount[$a]); + else + printf("0;"); + } + } + echo nb ($line['TVAC']); + } + } +} ?> diff --git a/html/jrn_pdf.php b/html/jrn_pdf.php index 1fe200f28..fd8252815 100644 --- a/html/jrn_pdf.php +++ b/html/jrn_pdf.php @@ -1,30 +1,30 @@ check_dossier($gDossier); $User->can_request(IMPJRN,0); // Security -if ( $_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) == 'X' ){ - /* Cannot Access */ - NoAccess(); +if ( $_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) == 'X' ) +{ + /* Cannot Access */ + NoAccess(); } $ret=""; @@ -72,8 +73,8 @@ $jrn_type=$Jrn->get_type(); //---------------------------------------------------------------------- // Detailled Printing //--------------------------------------------------------------------- -if ( $_REQUEST['p_simple']== 0 ) - { +if ( $_REQUEST['p_simple']== 0 ) +{ $pdf=new Print_Ledger_Detail($cn); $pdf->setDossierInfo($Jrn->name); $pdf->AliasNbPages(); @@ -85,77 +86,81 @@ if ( $_REQUEST['p_simple']== 0 ) $pdf->Output('journal-'.$fDate.'.pdf','I'); exit(0); - } // impression detaillé +} // impression detaillé //---------------------------------------------------------------------- // Simple Printing Purchase Ledger //--------------------------------------------------------------------- -if ( $_REQUEST['p_simple']== 1 ) - { +if ( $_REQUEST['p_simple']== 1 ) +{ if ( $jrn_type=='ACH' || $jrn_type=='VEN') - { - if ( $jrn_type=='ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0 ) { - $pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn); - $pdf->setDossierInfo($Jrn->name); - $pdf->AliasNbPages(); - $pdf->AddPage(); - $pdf->Cell(0,6,'Ce journal ne peut être imprimé en mode simple'); - $pdf->output('erreur.pdf','I'); - exit(); - } - if ( $jrn_type=='VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0 ) { - $pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn); - $pdf->setDossierInfo($Jrn->name); - $pdf->AliasNbPages(); - $pdf->AddPage(); - $pdf->Cell(0,6,'Ce journal ne peut être imprimé en mode simple'); - $pdf->output('erreur.pdf','I'); - exit(); - } + { + if ( $jrn_type=='ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0 ) + { + $pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn); + $pdf->setDossierInfo($Jrn->name); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->Cell(0,6,'Ce journal ne peut être imprimé en mode simple'); + $pdf->output('erreur.pdf','I'); + exit(); + } + if ( $jrn_type=='VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0 ) + { + $pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn); + $pdf->setDossierInfo($Jrn->name); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->Cell(0,6,'Ce journal ne peut être imprimé en mode simple'); + $pdf->output('erreur.pdf','I'); + exit(); + } - if ( $own->MY_TVA_USE=='Y') - { - $pdf= new Print_Ledger_Simple($cn,$Jrn); - $pdf->setDossierInfo($Jrn->name); - $pdf->AliasNbPages(); - $pdf->AddPage(); - $pdf->export(); - $fDate=date('dmy-Hi'); - $pdf->Output('journal-'.$fDate.'.pdf','I'); - exit(0); - } - if ( $own->MY_TVA_USE=='N') - { - $pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn); - $pdf->setDossierInfo($Jrn->name); - $pdf->AliasNbPages(); - $pdf->AddPage(); - $pdf->export($Jrn); - $fDate=date('dmy-Hi'); - $pdf->Output('journal-'.$fDate.'.pdf','I'); - exit(0); - } + if ( $own->MY_TVA_USE=='Y') + { + $pdf= new Print_Ledger_Simple($cn,$Jrn); + $pdf->setDossierInfo($Jrn->name); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->export(); + $fDate=date('dmy-Hi'); + $pdf->Output('journal-'.$fDate.'.pdf','I'); + exit(0); + } + if ( $own->MY_TVA_USE=='N') + { + $pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn); + $pdf->setDossierInfo($Jrn->name); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->export($Jrn); + $fDate=date('dmy-Hi'); + $pdf->Output('journal-'.$fDate.'.pdf','I'); + exit(0); + } - } - - if ($jrn_type=='FIN') { - $pdf= new Print_Ledger_Financial($cn,$Jrn); - $pdf->setDossierInfo($Jrn->name); - $pdf->AliasNbPages(); - $pdf->AddPage(); - $pdf->export(); - $fDate=date('dmy-Hi'); - $pdf->Output('journal-'.$fDate.'.pdf','I'); - exit(0); } - if ( $jrn_type=='ODS' || $Jrn->id==0) { - $pdf= new Print_Ledger_Misc($cn,$Jrn); - $pdf->setDossierInfo($Jrn->name); - $pdf->AliasNbPages(); - $pdf->AddPage(); - $pdf->export(); - $fDate=date('dmy-Hi'); - $pdf->Output('journal-'.$fDate.'.pdf','I'); - exit(0); + + if ($jrn_type=='FIN') + { + $pdf= new Print_Ledger_Financial($cn,$Jrn); + $pdf->setDossierInfo($Jrn->name); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->export(); + $fDate=date('dmy-Hi'); + $pdf->Output('journal-'.$fDate.'.pdf','I'); + exit(0); } - } + if ( $jrn_type=='ODS' || $Jrn->id==0) + { + $pdf= new Print_Ledger_Misc($cn,$Jrn); + $pdf->setDossierInfo($Jrn->name); + $pdf->AliasNbPages(); + $pdf->AddPage(); + $pdf->export(); + $fDate=date('dmy-Hi'); + $pdf->Output('journal-'.$fDate.'.pdf','I'); + exit(0); + } +} ?> diff --git a/html/jrn_search.php b/html/jrn_search.php index 99552f5db..c1df05064 100644 --- a/html/jrn_search.php +++ b/html/jrn_search.php @@ -40,9 +40,10 @@ $gDossier=dossier::id(); // Javascript echo JS_LEDGER; -if ( isset( $p_jrn )) { - $p_jrn=$p_jrn; - $_SESSION[ "p_jrn"]=$p_jrn; +if ( isset( $p_jrn )) +{ + $p_jrn=$p_jrn; + $_SESSION[ "p_jrn"]=$p_jrn; } if (isset ($_GET['p_ctl'])) $p_ctl=$_GET['p_ctl']; @@ -62,64 +63,76 @@ $condition=""; $part=" where "; $cn=new Database($gDossier); // if search then build the condition -if ( isset ($_GET["search"]) ) { - $c1=0; - foreach( $_GET as $key=>$element){ - ${"$key"}=$element; - } - $c_comment=""; - if ( isset ($p_comment) && strlen(trim($p_comment)) != 0 ) { - $c_comment=" $part upper(jr_comment) like upper('%$p_comment%')"; - $part=" and "; - } - $c_montant=""; - if ( isset ($p_montant) && strlen($p_montant) != 0 && isNumber($p_montant) ) - { - $p_montant=abs($p_montant); - $opt_montant.='
'; }// if $_POST [search] ?> diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index c82220e76..662d5cd54 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -28,140 +28,160 @@ var layer=1; /** * @brief update the list of available predefined operation when we change the ledger. */ -function update_predef(p_type,p_direct) { +function update_predef(p_type,p_direct) +{ var jrn=g("p_jrn").value; var dossier=g("gDossier").value; var querystring='?&gDossier='+dossier+'&l='+jrn+'&t='+p_type+'&d='+p_direct; g("p_jrn_predef").value=jrn; - var action=new Ajax.Request( - "get_predef.php", - { - method:'get', - parameters:querystring, - onFailure:error_get_predef, - onSuccess:success_get_predef - } - ); + var action=new Ajax.Request( + "get_predef.php", + { + method:'get', + parameters:querystring, + onFailure:error_get_predef, + onSuccess:success_get_predef + } + ); } /** * @brief update the field predef */ -function success_get_predef(request,json) { +function success_get_predef(request,json) +{ var i=0; - var answer=request.responseText.evalJSON(true); + var answer=request.responseText.evalJSON(true); obj=g("pre_def"); obj.innerHTML=''; if ( answer.count == 0 ) return; - for ( i = 0 ; i < answer.count;i++) { - value=answer['value'+i]; - label=answer['label'+i]; - obj.options[obj.options.length]=new Option(label,value); + for ( i = 0 ; i < answer.count;i++) + { + value=answer['value'+i]; + label=answer['label'+i]; + obj.options[obj.options.length]=new Option(label,value); } } /** * @brief update the field predef */ -function error_get_predef(request,json) { +function error_get_predef(request,json) +{ alert ("Erreur mise à jour champs non possible"); } /** * @brief update the list of available predefined operation when we change the ledger. */ -function update_pj() { +function update_pj() +{ var jrn=g("p_jrn").value; var dossier=g("gDossier").value; var querystring='?&gDossier='+dossier+'&l='+jrn; - var action=new Ajax.Request( - "get_pj.php", - { - method:'get', - parameters:querystring, - onFailure:error_get_pj, - onSuccess:success_get_pj - } - ); + var action=new Ajax.Request( + "get_pj.php", + { + method:'get', + parameters:querystring, + onFailure:error_get_pj, + onSuccess:success_get_pj + } + ); } -/** +/** *ask the name, quick_code of the bank for the ledger */ -function update_bank() { +function update_bank() +{ var jrn=g('p_jrn').value; var dossier=g('gDossier').value; var qs='?&gDossier='+dossier+'&op=bkname&p_jrn='+jrn; - var action=new Ajax.Request( - "ajax_misc.php", - { - method:'get', - parameters:qs, - onFailure:error_get_pj, - onSuccess:success_update_bank - } - ); - + var action=new Ajax.Request( + "ajax_misc.php", + { + method:'get', + parameters:qs, + onFailure:error_get_pj, + onSuccess:success_update_bank + } + ); + } /** * Put into the span, the name of the bank, the bank account * and the quick_code */ -function success_update_bank(req) +function success_update_bank(req) { - try{ - var answer=req.responseXML; - var a=answer.getElementsByTagName('code'); - var html=answer.getElementsByTagName('value'); - if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);} - var name_ctl=a[0].firstChild.nodeValue; - var code_html=getNodeText(html[0]); - code_html=unescape_xml(code_html); - $(name_ctl).innerHTML=code_html; + try + { + var answer=req.responseXML; + var a=answer.getElementsByTagName('code'); + var html=answer.getElementsByTagName('value'); + if ( a.length == 0 ) + { + var rec=req.responseText; + alert ('erreur :'+rec); + } + var name_ctl=a[0].firstChild.nodeValue; + var code_html=getNodeText(html[0]); + code_html=unescape_xml(code_html); + $(name_ctl).innerHTML=code_html; } - catch (e) { - alert("success_update_bank".e.message); + catch (e) + { + alert("success_update_bank".e.message); } } /** * call ajax, ask what is the last date for the current ledger */ -function get_last_date() { +function get_last_date() +{ var jrn=g('p_jrn').value; var dossier=g('gDossier').value; var qs='?&gDossier='+dossier+'&op=lastdate&p_jrn='+jrn; var action=new Ajax.Request( - "ajax_misc.php", - { - method:'get', - parameters:qs, - onFailure:error_get_pj, - onSuccess:success_get_last_date - } - ); + "ajax_misc.php", + { + method:'get', + parameters:qs, + onFailure:error_get_pj, + onSuccess:success_get_last_date + } + ); } /** * callback ajax, set the ctl with the last date from the ledger */ -function success_get_last_date(req) +function success_get_last_date(req) { - try{ - var answer=req.responseXML; - var a=answer.getElementsByTagName('code'); - var html=answer.getElementsByTagName('value'); - if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);} - var name_ctl=a[0].firstChild.nodeValue; - var code_html=getNodeText(html[0]); - code_html=unescape_xml(code_html); - $(name_ctl).value=code_html; + try + { + var answer=req.responseXML; + var a=answer.getElementsByTagName('code'); + var html=answer.getElementsByTagName('value'); + if ( a.length == 0 ) + { + var rec=req.responseText; + alert ('erreur :'+rec); + } + var name_ctl=a[0].firstChild.nodeValue; + var code_html=getNodeText(html[0]); + code_html=unescape_xml(code_html); + $(name_ctl).value=code_html; } - catch (e) { - alert(e.message); + catch (e) + { + alert(e.message); } } /** * @brief update the field predef */ -function success_get_pj(request,json) { +function success_get_pj(request,json) +{ var answer=request.responseText.evalJSON(true); obj=g("e_pj"); @@ -173,14 +193,16 @@ function success_get_pj(request,json) { /** * @brief update the field predef */ -function error_get_pj(request,json) { - alert("Ajax a echoue"); +function error_get_pj(request,json) +{ + alert("Ajax a echoue"); } /** * @brief add a line in the form for the ledger fin */ -function ledger_fin_add_row(){ +function ledger_fin_add_row() +{ var style='class="input_text"'; var mytable=g("fin_item").tBodies[0]; var line=mytable.rows.length; @@ -188,17 +210,18 @@ function ledger_fin_add_row(){ var nb=g("nb_item"); var rowToCopy=mytable.rows[1]; var nNumberCell=rowToCopy.cells.length; - for ( var e=0;e < nNumberCell;e++) { - var newCell=row.insertCell(e); - var tt=rowToCopy.cells[e].innerHTML; - var new_tt=tt.replace(/e_other0/g,"e_other"+nb.value); - new_tt=new_tt.replace(/e_other0_comment/g,"e_other"+nb.value+'_comment'); - new_tt=new_tt.replace(/e_other0_amount/g,"e_other"+nb.value+'_amount'); - new_tt=new_tt.replace(/e_concerned0/g,"e_concerned"+nb.value); - new_tt=new_tt.replace(/e_other0_label/g,"e_other"+nb.value+'_label'); - newCell.innerHTML=new_tt; - new_tt.evalScripts(); - } + for ( var e=0;e < nNumberCell;e++) + { + var newCell=row.insertCell(e); + var tt=rowToCopy.cells[e].innerHTML; + var new_tt=tt.replace(/e_other0/g,"e_other"+nb.value); + new_tt=new_tt.replace(/e_other0_comment/g,"e_other"+nb.value+'_comment'); + new_tt=new_tt.replace(/e_other0_amount/g,"e_other"+nb.value+'_amount'); + new_tt=new_tt.replace(/e_concerned0/g,"e_concerned"+nb.value); + new_tt=new_tt.replace(/e_other0_label/g,"e_other"+nb.value+'_label'); + newCell.innerHTML=new_tt; + new_tt.evalScripts(); + } g("e_other"+nb.value).value=""; g("e_other"+nb.value+'_amount').value="0"; g("e_other"+nb.value+'_comment').value=""; @@ -207,34 +230,36 @@ function ledger_fin_add_row(){ /** * @brief add a line in the form for the purchase ledger */ -function ledger_add_row(){ - style='class="input_text"'; - var mytable=g("sold_item").tBodies[0]; - var ofirstRow=mytable.rows[1]; - var line=mytable.rows.length; - var nCell=9; - var row=mytable.insertRow(line); - var nb=g("nb_item"); - for (var e=0;e'; + var row=table.insertRow(line); + // left cell + var cellPos = row.insertCell(0); + cellPos.innerHTML=''; - // right cell - var cellName = row.insertCell(1); - cellName.innerHTML=''; + // right cell + var cellName = row.insertCell(1); + cellName.innerHTML=''; - // button + formula + // button + formula var cellbutton = row.insertCell(2); var but_html=table.rows[1].cells[2].innerHTML; but_html=but_html.replace(/form0/g,"form"+line); @@ -55,27 +56,29 @@ function rapport_add_row(p_dossier){ * @brief create a file to export a report * @param p_dossier the dossier id */ -function report_export(p_dossier,p_fr_id) { - var queryString="?&gDossier="+p_dossier+"&f="+p_fr_id; - var action=new Ajax.Request( - "ajax_report.php", - { - method:'get', - parameters:queryString, - onSuccess:report_export_success - } - ); - +function report_export(p_dossier,p_fr_id) +{ + var queryString="?&gDossier="+p_dossier+"&f="+p_fr_id; + var action=new Ajax.Request( + "ajax_report.php", + { + method:'get', + parameters:queryString, + onSuccess:report_export_success + } + ); + } /** * @brief callback function for exporting a report * @param request object request * @param json json answer */ -function report_export_success(request,json) { - var answer = request.responseText.evalJSON(true); - var ok=answer.answer; - var link=answer.link; - $('export').hide(); - $('export_link').innerHTML=' Cliquez ici pour télécharger le rapport'; +function report_export_success(request,json) +{ + var answer = request.responseText.evalJSON(true); + var ok=answer.answer; + var link=answer.link; + $('export').hide(); + $('export_link').innerHTML=' Cliquez ici pour télécharger le rapport'; } \ No newline at end of file diff --git a/html/js/accounting_item.js b/html/js/accounting_item.js index 42747f22e..4fb2902fb 100644 --- a/html/js/accounting_item.js +++ b/html/js/accounting_item.js @@ -24,17 +24,20 @@ * containing the javascript for opening a windows to search an account (poste comptable) */ -function set_poste_parent(p_ctl,p_value) { - var f=g(p_ctl); - f.value+='['+p_value+']'; +function set_poste_parent(p_ctl,p_value) +{ + var f=g(p_ctl); + f.value+='['+p_value+']'; } -function set_jrn_parent(p_ctl,p_value) { - var f=g(p_ctl); - if ( f ) { - if ( trim(f.value)!="") f.value+=' '; - f.value+=p_value; - } +function set_jrn_parent(p_ctl,p_value) +{ + var f=g(p_ctl); + if ( f ) + { + if ( trim(f.value)!="") f.value+=' '; + f.value+=p_value; + } } @@ -60,43 +63,76 @@ function PcmnUpdate(p_value,p_lib,p_parent,p_type,p_dossier) * - acc_query for the initial query *\see ajax_poste.php */ -function search_poste(obj) { +function search_poste(obj) +{ showIPopup(obj.ipopup); var dossier=$('gDossier').value; var queryString="?gDossier="+dossier; queryString+="&op=sf"; - try { - if ( obj.jrn) { queryString+="&j="+obj.jrn;} - if ( obj.account) { queryString+="&c="+obj.account;} - if ( obj.label) { queryString+="&l="+obj.label;} - if ( obj.bracket) { queryString+="&b="+obj.bracket;} - if( obj.noquery) {queryString+="&nq";} - if( obj.no_overwrite) {queryString+="&nover";} - if( obj.bracket) {queryString+="&bracket";} - if ( ! obj.noquery) { - if( obj.acc_query) {queryString+="&q="+obj.acc_query;} - else { - if ($(obj).account) { - var e=$(obj).account; - var str_account=$(e).value; - queryString+="&q="+str_account; - } - } - } + try + { + if ( obj.jrn) + { + queryString+="&j="+obj.jrn; + } + if ( obj.account) + { + queryString+="&c="+obj.account; + } + if ( obj.label) + { + queryString+="&l="+obj.label; + } + if ( obj.bracket) + { + queryString+="&b="+obj.bracket; + } + if( obj.noquery) + { + queryString+="&nq"; + } + if( obj.no_overwrite) + { + queryString+="&nover"; + } + if( obj.bracket) + { + queryString+="&bracket"; + } + if ( ! obj.noquery) + { + if( obj.acc_query) + { + queryString+="&q="+obj.acc_query; + } + else + { + if ($(obj).account) + { + var e=$(obj).account; + var str_account=$(e).value; + queryString+="&q="+str_account; + } + } + } - queryString+="&ctl="+obj.ipopup; - queryString=encodeURI(queryString); - var action=new Ajax.Request ( 'ajax_poste.php', - { - method:'get', - parameters:queryString, - onFailure:errorPoste, - onSuccess:result_poste_search - } - ); - } catch (e) { alert(e.getMessage());} + queryString+="&ctl="+obj.ipopup; + queryString=encodeURI(queryString); + var action=new Ajax.Request ( 'ajax_poste.php', + { + method:'get', + parameters:queryString, + onFailure:errorPoste, + onSuccess:result_poste_search + } + ); + } + catch (e) + { + alert(e.getMessage()); + } } /** *@brief when you submit the form for searching a accounting item @@ -104,60 +140,98 @@ function search_poste(obj) { *@note the same as search_poste, except it answer to a FORM and not * to a click event */ -function search_get_poste(obj) { +function search_get_poste(obj) +{ var dossier=$('gDossier').value; var queryString="?gDossier="+dossier; queryString+="&op=sf"; - if ( obj.elements['jrn'] ) { queryString+="&j="+$F('jrn');} - if ( obj.elements['account']) { queryString+="&c="+$F('account');} - if ( obj.elements['label']) { queryString+="&l="+$F('label');} - if( obj.elements['acc_query']) {queryString+="&q="+$F('acc_query');} - if (obj.ctl ) {queryString+="&ctl="+obj.ctl;} - if( obj.elements['nosearch']) {queryString+="&nq";} - if( obj.elements['nover']) {queryString+="&nover";} - if( obj.elements['bracket']) {queryString+="&bracket";} + if ( obj.elements['jrn'] ) + { + queryString+="&j="+$F('jrn'); + } + if ( obj.elements['account']) + { + queryString+="&c="+$F('account'); + } + if ( obj.elements['label']) + { + queryString+="&l="+$F('label'); + } + if( obj.elements['acc_query']) + { + queryString+="&q="+$F('acc_query'); + } + if (obj.ctl ) + { + queryString+="&ctl="+obj.ctl; + } + if( obj.elements['nosearch']) + { + queryString+="&nq"; + } + if( obj.elements['nover']) + { + queryString+="&nover"; + } + if( obj.elements['bracket']) + { + queryString+="&bracket"; + } $('asearch').innerHTML=loading(); var action=new Ajax.Request ( 'ajax_poste.php', - { - method:'get', - parameters:queryString, - onFailure:errorPoste, - onSuccess:result_poste_search - } - ); + { + method:'get', + parameters:queryString, + onFailure:errorPoste, + onSuccess:result_poste_search + } + ); } /** *@brief show the answer of ajax request *@param answer in XML */ -function result_poste_search(req) { - try{ - var answer=req.responseXML; - var a=answer.getElementsByTagName('ctl'); - if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);} - var html=answer.getElementsByTagName('code'); +function result_poste_search(req) +{ + try + { + var answer=req.responseXML; + var a=answer.getElementsByTagName('ctl'); + if ( a.length == 0 ) + { + var rec=req.responseText; + alert ('erreur :'+rec); + } + var html=answer.getElementsByTagName('code'); - var name_ctl=a[0].firstChild.nodeValue; - var nodeXml=html[0]; - var code_html=getNodeText(nodeXml); - code_html=unescape_xml(code_html); - $(name_ctl).innerHTML=code_html; - } - catch (e) { - alert(e.message);} - try{ - code_html.evalScripts();} - catch(e){ - alert("Impossible executer script de la reponse\n"+e.message);} + var name_ctl=a[0].firstChild.nodeValue; + var nodeXml=html[0]; + var code_html=getNodeText(nodeXml); + code_html=unescape_xml(code_html); + $(name_ctl).innerHTML=code_html; + } + catch (e) + { + alert(e.message); + } + try + { + code_html.evalScripts(); + } + catch(e) + { + alert("Impossible executer script de la reponse\n"+e.message); + } } /** *@brief error for ajax */ -function errorPoste() { - alert('Ajax failed'); +function errorPoste() +{ + alert('Ajax failed'); } diff --git a/html/js/anc_script.js b/html/js/anc_script.js index 4df07830b..d8d44ed35 100644 --- a/html/js/anc_script.js +++ b/html/js/anc_script.js @@ -26,72 +26,89 @@ * \param p_table_id * \param p_amount amount to reach */ -function add_row(p_table,p_seq) { - var mytable=g(p_table).tBodies[0]; +function add_row(p_table,p_seq) +{ + var mytable=g(p_table).tBodies[0]; - if ( ! mytable ) {return;} + if ( ! mytable ) + { + return; + } var new_value=mytable.rows.length+1; - if ( mytable.rows.length > 5 ) { - alert("Maximum 5 lignes "); - return; - } - // For the detail view (modify_op) there is several form and then several time the - // element - var rowToCopy=mytable.rows[1]; - var row=mytable.insertRow(mytable.rows.length); + if ( mytable.rows.length > 5 ) + { + alert("Maximum 5 lignes "); + return; + } + // For the detail view (modify_op) there is several form and then several time the + // element + var rowToCopy=mytable.rows[1]; + var row=mytable.insertRow(mytable.rows.length); - for ( var i=0;i< rowToCopy.cells.length;i++) { - var cell=row.insertCell(i); - var txt=rowToCopy.cells[i].innerHTML; + for ( var i=0;i< rowToCopy.cells.length;i++) + { + var cell=row.insertCell(i); + var txt=rowToCopy.cells[i].innerHTML; // txt=txt.replace(/row_1/g,"row_"+new_value); - cell.innerHTML=txt; - } + cell.innerHTML=txt; + } } -/*! +/*! * \brief Check the amount of the CA * \param p_style : error or ok, if ok show a ok box if the amount are equal * * * \return true if the amounts are equal */ -function verify_ca(div) { - var idx=0;var amount_error=0; +function verify_ca(div) +{ + var idx=0; + var amount_error=0; // put a maximum - while (idx < 50 ) { - var table=div+'t'+idx; - if ( g(table) ) { - var total_amount=0; - // table is found compute the different val[] - var array_value=document.getElementsByName('val['+idx+'][]'); - - for (var i=0;i < array_value.length;i++ ) { - if ( isNaN(array_value[i].value)) { - array_value[i].value=0; - } + while (idx < 50 ) + { + var table=div+'t'+idx; + if ( g(table) ) + { + var total_amount=0; + // table is found compute the different val[] + var array_value=document.getElementsByName('val['+idx+'][]'); - total_amount+=parseFloat(array_value[i].value); - } - var amount=parseFloat(g('amount_t'+idx).value); - var diff=amount-total_amount; + for (var i=0;i < array_value.length;i++ ) + { + if ( isNaN(array_value[i].value)) + { + array_value[i].value=0; + } - if ( Math.round(diff,2)!= 0.0) { - g(table).style.backgroundColor='red'; - amount_error++; - } else { - g(table).style.backgroundColor='lightgreen'; + total_amount+=parseFloat(array_value[i].value); + } + var amount=parseFloat(g('amount_t'+idx).value); + var diff=amount-total_amount; - } - idx++; - } else break; + if ( Math.round(diff,2)!= 0.0) + { + g(table).style.backgroundColor='red'; + amount_error++; + } + else + { + g(table).style.backgroundColor='lightgreen'; + + } + idx++; + } + else break; } - if ( amount_error != 0 ) { - alert('Désolé, les montants pour la comptabilité analytique sont incorrects'); - return false; + if ( amount_error != 0 ) + { + alert('Désolé, les montants pour la comptabilité analytique sont incorrects'); + return false; } return true; } -/*! +/*! * \brief open a window for searching a CA account, * \param p_dossier dossier id * \param p_target ctrl to update @@ -102,57 +119,72 @@ function verify_ca(div) { */ function search_ca (p_dossier,p_target,p_source) { - var pa_id=g(p_source).value; - var url="?gDossier="+p_dossier+"&c1="+p_target+"&c2="+pa_id; - var a=window.open("search_ca.php"+url,"CA recherche",'statusbar=no,scrollbars=yes,toolbar=no'); - a.focus(); + var pa_id=g(p_source).value; + var url="?gDossier="+p_dossier+"&c1="+p_target+"&c2="+pa_id; + var a=window.open("search_ca.php"+url,"CA recherche",'statusbar=no,scrollbars=yes,toolbar=no'); + a.focus(); } -function caod_checkTotal() { - var ie4=false; - if ( document.all ) { - ie4=true; - }// Ajouter getElementById par document.all[str] - var total_deb=0.0; - var total_cred=0.0; - var nb_item=g('nbrow').value; +function caod_checkTotal() +{ + var ie4=false; + if ( document.all ) + { + ie4=true; + }// Ajouter getElementById par document.all[str] + var total_deb=0.0; + var total_cred=0.0; + var nb_item=g('nbrow').value; - for (var i=0;i '+p_variable; - p_history+="="+result.toString(); - var str_sub="
Total :"+p_variable+" = "+result.toString()+""; + p_variable=this.document.getElementById('inp').value; + if (p_variable.search(/^\s*$/) !=-1) + { + return; + } + try + { + Compute(); + sub=eval(p_variable); + var result=parseFloat(sub); + result=Math.round(result*100)/100; + } + catch(exception) + { + alert("Mauvaise formule\n"+p_variable); + return false; + } + p_history=p_history+'
'+p_variable; + p_history+="="+result.toString(); + var str_sub="
Total :"+p_variable+" = "+result.toString()+""; this.document.getElementById("sub_total").innerHTML=str_sub; this.document.getElementById("listing").innerHTML=p_history; this.document.getElementById('inp').value=""; } -// Clean -// -function Clean() +// Clean +// +function Clean() { - this.document.getElementById('listing').innerHTML=""; - this.document.getElementById('result').innerHTML=""; - this.document.getElementById('sub_total').innerHTML=""; - this.document.getElementById('inp').value=""; - this.document.getElementById('inp').focus(); + this.document.getElementById('listing').innerHTML=""; + this.document.getElementById('result').innerHTML=""; + this.document.getElementById('sub_total').innerHTML=""; + this.document.getElementById('inp').value=""; + this.document.getElementById('inp').focus(); } @@ -66,7 +70,7 @@ function Compute() { var tot=0; var ret=""; - + this.document.getElementById('inp').value=""; this.document.getElementById('inp').focus(); } diff --git a/html/js/card.js b/html/js/card.js index 0ec07ff6c..10ebb7e77 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -19,7 +19,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*! \file +/*! \file * \brief javascript for searching a card */ @@ -34,37 +34,42 @@ * - label field to update with the name * - ctl the id to fill with the HTML answer (ending with _content) */ -function search_card(obj) { - try{ - var gDossier=$('gDossier').value; - var inp=obj.inp; - var string_to_search=$(inp).value; - var label=obj.label; - var typecard=obj.typecard; - var price=obj.price; - var tvaid=obj.tvaid; - var jrn=obj.jrn; - if ( jrn==undefined) { - if ( g('p_jrn')) jrn=$('p_jrn').value; - else jrn=-1; - } - var query=encodeJSON({'gDossier':gDossier, - 'inp':inp,'label':label,'price':price,'tvaid':tvaid, - 'ctl':obj.popup,'op':'fs','jrn':jrn, - 'typecard':typecard,'query':string_to_search - }); - showIPopup(obj.popup); +function search_card(obj) +{ + try + { + var gDossier=$('gDossier').value; + var inp=obj.inp; + var string_to_search=$(inp).value; + var label=obj.label; + var typecard=obj.typecard; + var price=obj.price; + var tvaid=obj.tvaid; + var jrn=obj.jrn; + if ( jrn==undefined) + { + if ( g('p_jrn')) jrn=$('p_jrn').value; + else jrn=-1; + } +var query=encodeJSON({'gDossier':gDossier, + 'inp':inp,'label':label,'price':price,'tvaid':tvaid, + 'ctl':obj.popup,'op':'fs','jrn':jrn, + 'typecard':typecard,'query':string_to_search + }); + showIPopup(obj.popup); - var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:query, - onFailure:errorFid, - onSuccess:result_card_search - } - ); - }catch(e) { - alert('search_card failed'+e.message); + var action=new Ajax.Request ( 'ajax_card.php', + { + method:'get', + parameters:query, + onFailure:errorFid, + onSuccess:result_card_search + } + ); + } + catch(e) + { + alert('search_card failed'+e.message); } } /** @@ -73,53 +78,90 @@ function search_card(obj) { *@note the same as search_card, except it answer to a FORM and not * to a click event */ -function search_get_card(obj) { +function search_get_card(obj) +{ var dossier=$('gDossier').value; var queryString="?gDossier="+dossier; queryString+="&op=fs"; - - if ( obj.elements['inp'] ) { queryString+="&inp="+$F('inp');} - if ( obj.elements['typecard'] ) { queryString+="&typecard="+$F('typecard');} - if ( obj.elements['jrn'] ) { queryString+="&jrn="+$F('jrn');} - if ( obj.elements['label']) { queryString+="&label="+$F('label');} - if ( obj.elements['price']) { queryString+="&price="+$F('price');} - if ( obj.elements['tvaid']) { queryString+="&tvaid="+$F('tvaid');} - if( obj.elements['query']) {queryString+="&query="+$F('query');} - if (obj.ctl ) {queryString+="&ctl="+obj.ctl;} + + if ( obj.elements['inp'] ) + { + queryString+="&inp="+$F('inp'); + } + if ( obj.elements['typecard'] ) + { + queryString+="&typecard="+$F('typecard'); + } + if ( obj.elements['jrn'] ) + { + queryString+="&jrn="+$F('jrn'); + } + if ( obj.elements['label']) + { + queryString+="&label="+$F('label'); + } + if ( obj.elements['price']) + { + queryString+="&price="+$F('price'); + } + if ( obj.elements['tvaid']) + { + queryString+="&tvaid="+$F('tvaid'); + } + if( obj.elements['query']) + { + queryString+="&query="+$F('query'); + } + if (obj.ctl ) + { + queryString+="&ctl="+obj.ctl; + } $('asearch').innerHTML=loading(); var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:queryString, - onFailure:errorFid, - onSuccess:result_card_search - } - ); + { + method:'get', + parameters:queryString, + onFailure:errorFid, + onSuccess:result_card_search + } + ); } /** *@brief show the answer of ajax request *@param answer in XML */ -function result_card_search(req) { - try{ - var answer=req.responseXML; - var a=answer.getElementsByTagName('ctl'); - if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);} - var html=answer.getElementsByTagName('code'); +function result_card_search(req) +{ + try + { + var answer=req.responseXML; + var a=answer.getElementsByTagName('ctl'); + if ( a.length == 0 ) + { + var rec=req.responseText; + alert ('erreur :'+rec); + } + var html=answer.getElementsByTagName('code'); - var name_ctl=a[0].firstChild.nodeValue; - var nodeXml=html[0]; - var code_html=getNodeText(nodeXml); - code_html=unescape_xml(code_html); - $(name_ctl).innerHTML=code_html; - } - catch (e) { - alert(e.message);} - try{ - code_html.evalScripts();} - catch(e){ - alert("Impossible executer script de la reponse\n"+e.message);} + var name_ctl=a[0].firstChild.nodeValue; + var nodeXml=html[0]; + var code_html=getNodeText(nodeXml); + code_html=unescape_xml(code_html); + $(name_ctl).innerHTML=code_html; + } + catch (e) + { + alert(e.message); + } + try + { + code_html.evalScripts(); + } + catch(e) + { + alert("Impossible executer script de la reponse\n"+e.message); + } } @@ -135,11 +177,18 @@ function result_card_search(req) { *\param p_ctrlname the name of the input field with the label *\param p_label the label of the quickcode */ -function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label){ - var ctrl=g(p_ctrl); - if ( ctrl ) { ctrl.value=p_quickcode; } - var ctrl_name=g(p_ctrlname); - if ( ctrl_name ) { ctrl_name.value=p_label; } +function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label) +{ + var ctrl=g(p_ctrl); + if ( ctrl ) + { + ctrl.value=p_quickcode; + } + var ctrl_name=g(p_ctrlname); + if ( ctrl_name ) + { + ctrl_name.value=p_label; + } } @@ -149,27 +198,38 @@ function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label){ */ function clean_Fid(p_ctl) { - nSell=p_ctl+"_price"; - nBuy=p_ctl+"_price"; - nTva_id=p_ctl+"_tva_id"; - if ( $(nSell) ) { $(nSell).value=""; } - if ( $(nBuy) ) { $(nBuy).value="";} - if ( $(nTva_id) ) { $(nTva_id).value="-1"; } - + nSell=p_ctl+"_price"; + nBuy=p_ctl+"_price"; + nTva_id=p_ctl+"_tva_id"; + if ( $(nSell) ) + { + $(nSell).value=""; + } + if ( $(nBuy) ) + { + $(nBuy).value=""; + } + if ( $(nTva_id) ) + { + $(nTva_id).value="-1"; + } + } -function errorFid(request,json) { - alert('erreur : ajax fiche'); +function errorFid(request,json) +{ + alert('erreur : ajax fiche'); } -function update_value(text,li) { - +function update_value(text,li) +{ } /** *@brief is called when something change in ICard *@param the input field *@see ICard */ -function fill_data_onchange(ctl) { - ajaxFid(ctl); +function fill_data_onchange(ctl) +{ + ajaxFid(ctl); } /** @@ -177,8 +237,9 @@ function fill_data_onchange(ctl) { *@param the input field *@see ICard */ -function fill_data(text,li) { - ajaxFid(text); +function fill_data(text,li) +{ + ajaxFid(text); } /** @@ -186,18 +247,20 @@ function fill_data(text,li) { *@param the input field *@see ICard */ -function fill_fin_data_onchange(ctl) { - ajaxFid(ctl); -ajax_saldo(ctl.id); +function fill_fin_data_onchange(ctl) +{ + ajaxFid(ctl); + ajax_saldo(ctl.id); } /** *@brief is called when something change in ICard *@param the input field *@see ICard */ -function fill_fin_data(text,li) { - ajaxFid(text); -ajax_saldo($(text.id)); +function fill_fin_data(text,li) +{ + ajaxFid(text); + ajax_saldo($(text.id)); } /** *@brief show the ipopup window and display the details of a card, @@ -207,17 +270,25 @@ ajax_saldo($(text.id)); * *@see ajax_card.php */ -function fill_ipopcard(obj) { - if ( ! $(obj).ipopup) { alert('Erreur pas d\' attribut ipopup '+obj.id);return;}; +function fill_ipopcard(obj) +{ + if ( ! $(obj).ipopup) + { + alert('Erreur pas d\' attribut ipopup '+obj.id); + return; + }; var content=$(obj).ipopup+'_content'; $(content).innerHTML=loading(); showIPopup($(obj).ipopup); var dossier=$('gDossier').value; var qcode=''; - if ( $(obj).qcode != undefined ) { - qcode=obj.qcode; - } else { - qcode=$(obj).value; + if ( $(obj).qcode != undefined ) + { + qcode=obj.qcode; + } + else + { + qcode=$(obj).value; } // ctl=$(obj).id; var queryString='?gDossier='+dossier; @@ -226,13 +297,17 @@ function fill_ipopcard(obj) { queryString+='&op=dc'; // dc for detail card var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:queryString, - onFailure:errorFid, - onSuccess:successFill_ipopcard - } - ); + { + method:'get' + , + parameters: + queryString, + onFailure: + errorFid, + onSuccess: + successFill_ipopcard + } + ); } /** *@brief @@ -241,19 +316,37 @@ function fill_ipopcard(obj) { \code \endcode */ -function successFill_ipopcard(req,json){ - try{ - var answer=req.responseXML; - var a=answer.getElementsByTagName('ctl'); - var html=answer.getElementsByTagName('code'); +function successFill_ipopcard(req,json) +{ + try + { + var answer=req.responseXML; + var a=answer.getElementsByTagName('ctl'); + var html=answer.getElementsByTagName('code'); - if ( a.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);} - var name_ctl=a[0].firstChild.nodeValue; - var code_html=getNodeText(html[0]); - code_html=unescape_xml(code_html); + if ( a.length == 0 ) + { + var rec=req.responseText; + alert ('erreur :'+rec); + } + var name_ctl=a[0].firstChild.nodeValue; + var code_html=getNodeText(html[0]); + code_html=unescape_xml(code_html); - $(name_ctl).innerHTML=code_html;} catch (e) {alert(e.message);} - try{code_html.evalScripts();}catch(e){alert("Impossible executer script de la reponse\n"+e.message);} + $(name_ctl).innerHTML=code_html; + } + catch (e) + { + alert(e.message); + } + try + { + code_html.evalScripts(); + } + catch(e) + { + alert("Impossible executer script de la reponse\n"+e.message); + } } /** *@brief show the ipopup for selecting a card type, it is a needed step before adding @@ -265,8 +358,13 @@ function successFill_ipopcard(req,json){ * - type type of card (supplier, customer...) *@see ajax_card.php */ -function select_card_type(obj) { - if ( ! $(obj).ipopup) { alert('Erreur pas d\' attribut ipopup '+obj.id);return;}; +function select_card_type(obj) +{ + if ( ! $(obj).ipopup) + { + alert('Erreur pas d\' attribut ipopup '+obj.id); + return; + }; var content=$(obj).ipopup+'_content'; $(content).innerHTML=loading(); showIPopup($(obj).ipopup); @@ -274,30 +372,46 @@ function select_card_type(obj) { // give a filter, -1 if not var filter=$(obj).filter; - if ( filter==undefined) {filter=-1;} + if ( filter==undefined) + { + filter=-1; + } var queryString='?gDossier='+dossier; queryString+='&ctl='+content; queryString+='&op=st'; // st for selecting type - if ( $(obj).win_refresh!=undefined) { queryString+='&ref';} + if ( $(obj).win_refresh!=undefined) + { + queryString+='&ref'; + } queryString+='&fil='+filter; // filter on the ledger, -1 if not var oledger=$(obj).jrn; - if (oledger==undefined) {ledger=-1;} else {ledger=$(obj).jrn;} + if (oledger==undefined) + { + ledger=-1; + } + else + { + ledger=$(obj).jrn; + } queryString+='&ledger='+ledger; - if ( obj.type_cat) { queryString+='&cat='+obj.type_cat;} + if ( obj.type_cat) + { + queryString+='&cat='+obj.type_cat; + } var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:queryString, - onFailure:errorFid, - onSuccess:successFill_ipopcard - } - ); + { + method:'get', + parameters:queryString, + onFailure:errorFid, + onSuccess:successFill_ipopcard + } + ); } /** *@brief Show a blank card @@ -307,13 +421,19 @@ function select_card_type(obj) { * - ref : reload the window after adding card *@see ajax_card.php */ -function dis_blank_card(obj) { - if ( ! $(obj).ipopup) { alert('Erreur pas d\' attribut ipopup '+obj.id);return;}; +function dis_blank_card(obj) +{ + if ( ! $(obj).ipopup) + { + alert('Erreur pas d\' attribut ipopup '+obj.id); + return; + }; // first we have to take the form elt we need var fd_id=$F('fd_id'); var ref=""; - if ( obj.elements['ref'] ) { - ref='&ref'; + if ( obj.elements['ref'] ) + { + ref='&ref'; } var content=$(obj).ipopup+'_content'; $(content).innerHTML=loading(); @@ -327,13 +447,13 @@ function dis_blank_card(obj) { queryString+='&op=bc'; // bc for blank card var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:queryString, - onFailure:errorFid, - onSuccess:successFill_ipopcard - } - ); + { + method:'get', + parameters:queryString, + onFailure:errorFid, + onSuccess:successFill_ipopcard + } + ); } /** *@brief save the data contained into the form 'save_card' @@ -341,8 +461,13 @@ function dis_blank_card(obj) { * possible attribute : *@see ajax_card.php */ -function save_card(obj) { - if ( ! $(obj).ipopup) { alert('Erreur pas d\' attribut ipopup '+obj.id);return;}; +function save_card(obj) +{ + if ( ! $(obj).ipopup) + { + alert('Erreur pas d\' attribut ipopup '+obj.id); + return; + }; var content=$(obj).ipopup+'_content'; // Data must be taken here data=$('save_card').serialize(false); @@ -355,13 +480,13 @@ function save_card(obj) { queryString+='&op=sc'; // sc for save card var action=new Ajax.Request ( 'ajax_card.php', - { - method:'post', - parameters:queryString, - onFailure:errorFid, - onSuccess:successFill_ipopcard - } - ); + { + method:'post', + parameters:queryString, + onFailure:errorFid, + onSuccess:successFill_ipopcard + } + ); } /** *@brief add a category of card, @@ -369,30 +494,39 @@ function save_card(obj) { * - ipopup the ipopup to show * - type_cat the category of card we want to add */ -function add_category(obj){ +function add_category(obj) +{ // show ipopup showIPopup(obj.ipopup); var dossier=$('gDossier').value; var queryString='?gDossier='+dossier; queryString+='&op=ac'; queryString+='&ctl='+obj.ipopup+'_content'; - if ( obj.type_cat) { queryString+='&cat='+obj.type_cat;} + if ( obj.type_cat) + { + queryString+='&cat='+obj.type_cat; + } var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:queryString, - onFailure:errorFid, - onSuccess:successFill_ipopcard - } - ); + { + method:'get', + parameters:queryString, + onFailure:errorFid, + onSuccess:successFill_ipopcard + } + ); } /** * @brief save the form and add a new category of card * @param obj if the form object */ -function save_card_category(obj) { - if ( ! $(obj).ipopup) { alert('Erreur pas d\' attribut ipopup '+obj.id);return;}; +function save_card_category(obj) +{ + if ( ! $(obj).ipopup) + { + alert('Erreur pas d\' attribut ipopup '+obj.id); + return; + }; var content=$(obj).ipopup+'_content'; // Data must be taken here data=$('newcat').serialize(false); @@ -405,13 +539,13 @@ function save_card_category(obj) { queryString+='&op=scc'; // sc for save card var action=new Ajax.Request ( 'ajax_card.php', - { - method:'post', - parameters:queryString, - onFailure:errorFid, - onSuccess:successFill_ipopcard - } - ); + { + method:'post', + parameters:queryString, + onFailure:errorFid, + onSuccess:successFill_ipopcard + } + ); } /** *@brief Remove a definition of an attribut @@ -421,19 +555,20 @@ function save_card_category(obj) { *@param special this pointer of the row */ -function removeCardAttribut(ad_id,gDossier,table_id,row) { +function removeCardAttribut(ad_id,gDossier,table_id,row) +{ var queryString='?gDossier='+gDossier; queryString+='&op=rmfa'; queryString+='&ctl=debug'; // debug id queryString+='&ad_id='+ad_id; var action=new Ajax.Request ( 'ajax_card.php', - { - method:'get', - parameters:queryString, - onFailure:null, - onSuccess:null - } - ); + { + method:'get', + parameters:queryString, + onFailure:null, + onSuccess:null + } + ); deleteRowRec(table_id,row); diff --git a/html/js/compute.js b/html/js/compute.js index 487026852..11a506ef3 100644 --- a/html/js/compute.js +++ b/html/js/compute.js @@ -18,63 +18,82 @@ /*!\file *\brief common function for accountancy module */ -function checkTotal() { - var ie4=false; - if ( document.all ) { - ie4=true; - }// Ajouter getElementById par document.all[str] - var total_deb=0.0; - var total_cred=0.0; +function checkTotal() +{ + var ie4=false; + if ( document.all ) + { + ie4=true; + }// Ajouter getElementById par document.all[str] + var total_deb=0.0; + var total_cred=0.0; - var nb_item_id=document.getElementById('nb_item'); - if ( ! nb_item_id ) - {return; } - var nb_item=nb_item_id.value; - - for (var i=0;i