';
//-----------------------------------------------------
//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 '";
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']) ) {
?>
';
$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 '