Check(); include_once ("check_priv.php"); include_once ("user_menu.php"); echo '
'; echo ShowMenuCompta("user_advanced.php?".dossier::get()); echo '
'; // \todo add a check for permission echo ShowMenuAdvanced(8); $User->AccessRequest($cn,EXP_IMP_ECR); echo ''; echo '
'; //----------------------------------------------------- //EXPORT //////////////////////////////////////////// if ( isset ($_GET['export'])) { // if the year is not set, ask it // ask the exercice and do the export $periode=make_array($cn,"select distinct p_exercice,p_exercice from parm_periode order by p_exercice"); echo '
'; $w=new widget('select'); $w->table=0; $w->label='Periode'; $w->readonly=false; $w->value=$periode; $w->name="p_periode"; echo 'Période : '.$w->IOValue(); echo $w->Submit('export','Export'); echo "
"; exit(0); } //----------------------------------------------------- IMPORT //////////////////////////////////////////// if ( isset ($_GET['import'])) { // show a form to upload the file // that form will parse the file, create an ods operation // and ask you to validate it // if no file is given if ( ! isset ($_REQUEST['p_submit']) ) { ?>
name='p_jrn'; $x->value=$ods; echo "Choississez votre journal ".$x->IOValue(); $w=new widget("file"); $w->name='import_file'; $w->label='p_file'; echo $w->IOValue(); echo $w->Submit('p_submit','Charger le fichier'); ?>
'; $end=true; continue; } if ( $end ) { echo $line."
"; continue; } // check if the first line contains the signature if ( $valid ) { // skip blank line if (strlen (trim($line)) == 0 ) continue; // put the line into several array with the same index echo_debug('ecrit_ouv',__LINE__," line $line"); list($sign,$poste,$label,$amount)=explode(";",$line); $asign[$idx]=$sign; $aposte[$idx]=$poste;$aamount[$idx]=$amount; $alabel[$idx]=$label; $idx++; } else { $valid = strpos($line, "OUVERTURE") !== false; } } // read the file // if valid is still false then there is nothing to do if ( ! $valid) { echo 'Aucun enregistrement valide'; return ;} // compose the array for the function FormODS $array_ods['e_comm']='Ecriture d\'ouverture'; for ($i=0;$i<$idx;$i++) { $n="e_account$i"; $array_ods[$n]=$aposte[$i]; $n="e_account".$i."_type"; $array_ods[$n]=$asign[$i]; $n="e_account".$i."_amount"; $array_ods[$n]=$aamount[$i]; } // Check if all the poste exist // otherwise create it for ($i=0;$i<$idx;$i++) { $p=new Poste($cn,$aposte[$i]); // if the poste exists then check the next one if ( $p->get() == true ) continue; echo 'Attention creation de '.$p->id.' '.$alabel[$i].'
'; $sql=sprintf("select account_add(%d,'%s')", $p->id,$alabel[$i]); ExecSql($cn,$sql); } // submit button in the form $submit=' '; $r=FormODS($cn,$_POST['p_jrn'],$User->GetPeriode(),$submit, $array_ods,false,$idx,$p_saved=false); echo $r; echo "

On-line calculator

".JS_CALC_LINE."
"; } } } // else -> a file is given }// if import // IF import and export are not set then the choice is proposed echo '
'; html_page_stop(); ?>