32 if (isset($_POST[
'jr_id']))
34 if (empty($_POST[
'jr_id']))
36 return "Erreur : aucune opération n'est sélectionnée";
40 return "Erreur : aucune opération n'est sélectionnée";
58 echo
" <p class=\"error\">$msg</p>";
return;
60 $source=
$cn->get_value(
'select pcm_val from tmp_pcmn where pcm_val=$1',array($_POST[
'sposte']));
61 $target=
$cn->get_value(
'select pcm_val from tmp_pcmn where pcm_val=$1',array($_POST[
'tposte']));
64 echo
'<p class="error"> Il manque soit le poste comptable source soit le poste comptable destination ou l\'un des deux postes n\'existe pas</p>';
67 $cn->prepare(
'update_account',
'update jrnx set j_poste = $1 where j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$2) and j_poste=$3
69 $cn->prepare(
'retrieve',
'select jr_date,jr_comment,jr_montant,jr_internal from jrn where jr_id=$1');
70 echo h2info(
'Opération changée');
71 echo
'compte : '.$_REQUEST[
'sposte'].
' vers '.
$_REQUEST[
'tposte'];
73 echo
'<table class="result">';
74 foreach ($_POST[
'jr_id'] as
$id)
76 $update=
$cn->execute(
'update_account',array(trim($_POST[
'tposte']),$id,trim($_POST[
'sposte'])));
77 if ( Database::num_row($update) ==0 )
continue;
78 $feedback=
$cn->execute(
'retrieve',array($id));
79 if ( Database::num_row($feedback) != 0)
82 $row=Database::fetch_array($feedback,0);
84 echo td(format_date(
$row[
'jr_date']));
85 echo td(HtmlInput::detail_op($id,
$row[
'jr_internal']));
86 echo td(
$row[
'jr_comment']);
87 echo td(nbm(
$row[
'jr_montant'],2,
' class="num"'));
92 echo
'<p> Nombre d\'opérations changées :'.$count.
'</p>';
107 echo
" <p class=\"error\">$msg</p>";
return;
109 $source=
$cn->get_value(
'select pcm_val from tmp_pcmn where pcm_val=$1',array($_POST[
'csource1']));
110 $target=
$cn->get_value(
'select f_id from fiche_detail where ad_id=23 and ad_value=trim(upper($1))',array($_POST[
'ctarget1']));
114 echo
'<p class="error"> Il manque soit le poste comptable source soit la fiche destination ou l\'un des deux n\'existe pas</p>';
119 $target_account=
$cn->get_value(
'select pcm_val from tmp_pcmn where pcm_val in (select ad_value from fiche_detail where ad_id=5 and f_id=$1)',array(
$target));
120 if ($target_account ==
'') {
121 echo
'<p class="error"> Le poste comptable de la fiche n\'existe pas</span>';
124 $cn->prepare(
'update_account',
'update jrnx set j_poste = $1,j_qcode=upper($2),f_id=$3 where j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$4) and j_poste=$5
126 $cn->prepare(
'retrieve',
'select jr_date,jr_comment,jr_montant,jr_internal from jrn where jr_id=$1');
127 echo h2info(
'Opération changée');
128 echo
'compte : '.$_REQUEST[
'sposte'].
' vers '.
$_REQUEST[
'tposte'];
130 echo
'<table class="result">';
131 foreach ($_POST[
'jr_id'] as
$id)
133 $update=
$cn->execute(
'update_account',array(trim($target_account),trim($_POST[
'ctarget1']),
$target,$id,trim($_POST[
'csource1'])));
134 if ( Database::num_row($update) ==0 )
continue;
135 $feedback=
$cn->execute(
'retrieve',array($id));
136 if ( Database::num_row($feedback) != 0)
139 $row=Database::fetch_array($feedback,0);
141 echo td(format_date(
$row[
'jr_date']));
142 echo td(HtmlInput::detail_op($id,
$row[
'jr_internal']));
143 echo td(
$row[
'jr_comment']);
144 echo td(nbm(
$row[
'jr_montant'],2,
' class="num"'));
149 echo
'<p> Nombre d\'opérations changées :'.$count.
'</p>';
165 echo
" <p class=\"error\">$msg</p>";
return;
167 $source=
$cn->get_value(
'select f_id from fiche_detail where ad_id=23 and ad_value=trim(upper($1))',array($_POST[
'csource']));
168 $target=
$cn->get_value(
'select f_id from fiche_detail where ad_id=23 and ad_value=trim(upper($1))',array($_POST[
'ctarget']));
172 echo
'<p class="error"> Il manque soit la fiche source soit le fiche destination ou l\'une des deux fiches n\'existe pas</p>';
178 $source_account=
$cn->get_value(
'select ad_value from fiche_detail where ad_id=5 and f_id=$1',array(
$source));
179 $target_account=
$cn->get_value(
'select ad_value from fiche_detail where ad_id=5 and f_id=$1',array(
$target));
184 if ( $source_account ==
'' || $target_account ==
'')
186 echo
'<p class="error"> L\'une des deux fiche n\'a pas de poste comptable</p>';
193 $cn->prepare(
'update_account',
'update jrnx set f_id = $1, j_poste=$2, j_qcode=trim(upper($3 ))
194 where j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$4) and j_qcode=upper(trim($5)) RETURNING j_id');
198 $cn->prepare(
'update_sold_mer',
'update quant_sold set qs_fiche=$1 where
199 j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$2) and qs_fiche=$3');
201 $cn->prepare(
'update_sold_cust',
'update quant_sold set qs_client=$1 where
202 j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$2) and qs_client=$3');
207 $cn->prepare(
'update_pur_mer',
'update quant_purchase set qp_fiche=$1 where
208 j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$2) and qp_fiche=$3');
210 $cn->prepare(
'update_pur_cust',
'update quant_purchase set qp_supplier=$1 where
211 j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$2) and qp_supplier=$3');
215 $cn->prepare(
'update_fin_bk',
'update quant_fin set qf_bank=$1 where
216 jr_id=$2 and qf_bank=$3');
218 $cn->prepare(
'update_fin_oth',
'update quant_fin set qf_other=$1 where
219 jr_id=$2 and qf_other=$3');
223 $cn->prepare(
'retrieve',
'select jr_date,jr_comment,jr_montant,jr_internal,jrn_def_type from jrn join jrn_def on (jr_def_id=jrn_def_id) where jr_id=$1');
224 echo h2info(
'Opération changée');
225 echo
'Fiche : '.$_REQUEST[
'csource'].
' vers '.
$_REQUEST[
'ctarget'];
227 echo
'<table class="result">';
230 foreach ($_POST[
'jr_id'] as
$id)
232 $feedback=
$cn->execute(
'retrieve',array($id));
233 $change_row=Database::num_row($feedback);
234 if ($change_row != 0)
236 $row=Database::fetch_array($feedback,0);
237 switch (
$row[
'jrn_def_type'])
255 $update=
$cn->execute(
'update_account',array(
$target,$target_account,$_POST[
'ctarget'],$id,$_POST[
'csource']));
257 if ( Database::num_row($update) ==0 )
continue;
259 if ( $change_row != 0)
264 echo td(format_date(
$row[
'jr_date']));
265 echo td(HtmlInput::detail_op($id,
$row[
'jr_internal']));
266 echo td(
$row[
'jr_comment']);
267 echo td(nbm(
$row[
'jr_montant']),2,
' class="num"');
274 echo
'<p> Nombre d\'opérations changée :'.$count.
'</p>';
289 echo
" <p class=\"error\">$msg</p>";
return;
294 $type_source=
$cn->get_value(
'select jrn_def_type from jrn_def where jrn_def_id=$1',array($_POST[
'sledger']));
295 $type_target=
$cn->get_value(
'select jrn_def_type from jrn_def where jrn_def_id=$1',array($_POST[
'tledger']));
297 if ( $type_target != $type_source)
299 echo
" <p class=\"error\">Les journaux doivent être de même type</p>";
return;
301 $cn->prepare(
'update_ledger_x',
'update jrnx set j_jrn_def = $1 where j_id in (select j_id from jrnx join jrn on (jr_grpt_id=j_grpt) and jr_id=$2) and j_jrn_def=$3
303 $cn->prepare(
'update_ledger',
'update jrn set jr_def_id = $1 where jr_id = $2 and jr_def_id=$3
306 $cn->prepare(
'retrieve',
'select jr_date,jr_comment,jr_montant,jr_internal from jrn where jr_id=$1');
307 echo h2info(
'Opération changée');
308 $source_name=
$cn->get_value(
"select '('||jrn_def_type||') '||jrn_def_name from jrn_def where
309 jrn_def_id=$1",array($_POST[
'sledger']));
311 $target_name=
$cn->get_value(
"select '('||jrn_def_type||') '||jrn_def_name from jrn_def where
312 jrn_def_id=$1",array($_POST[
'tledger']));
315 echo
'compte : '.$source_name.
' vers '.$target_name;
317 echo
'<table class="result">';
319 foreach ($_POST[
'jr_id'] as
$id)
321 $update=
$cn->execute(
'update_ledger_x',array(trim($_POST[
'tledger']),$id,trim($_POST[
'sledger'])));
322 $cn->execute(
'update_ledger',array(trim($_POST[
'tledger']),$id,trim($_POST[
'sledger'])));
324 if ( Database::num_row($update) ==0 )
continue;
325 $feedback=
$cn->execute(
'retrieve',array($id));
326 if ( Database::num_row($feedback) != 0)
329 $row=Database::fetch_array($feedback,0);
331 echo td(format_date(
$row[
'jr_date']));
332 echo td(HtmlInput::detail_op($id,
$row[
'jr_internal']));
333 echo td(
$row[
'jr_comment']);
334 echo td(nbm(
$row[
'jr_montant'],2,
' class="num"'));
341 echo
'<p> Nombre d\'opérations changée'.$count.
'</p>';
351 $idate_start=
new IDate(
'dstart');
352 $idate_start->value=HtmlInput::default_value(
'dstart',
'',$_GET);
353 $idate_end=
new IDate(
'dend');
354 $idate_end->value=HtmlInput::default_value(
'dend',
'',$_GET);
356 $sql=
"select jrn_def_id, '('||jrn_def_type||') '||jrn_def_name from jrn_def order by jrn_def_name asc";
358 $iledger=
new ISelect(
'ledger');
360 $iledger->selected=HtmlInput::default_value(
'ledger',
'',$_GET);
362 $hidden=HtmlInput::get_to_hidden(array(
'sa',
'plugin_code',
'gDossier'));
364 $submit=HtmlInput::submit(
'search',
'Rechercher');
365 $hide= HtmlInput::button(
'accounting_hide_bt',
'Annuler',
'onclick="$(\'div_receipt\').hide();"');
366 require_once(
'template/search_box.php');
375 $sql=
"select jr_id,jr_internal,to_char(jr_date,'DD.MM.YY') as str_date, jr_date,jr_montant,jr_comment,jr_pj_number
378 jr_def_id=$1 and jr_date >= to_date($2,'DD.MM.YYYY')
379 and jr_date <= to_date($3,'DD.MM.YYYY')
380 order by jr_date asc,substring(jr_pj_number,'[0-9]+$')::numeric asc
382 $ret=
$cn->exec_sql(
$sql,array($_GET[
'ledger'],$_GET[
'dstart'],$_GET[
'dend']));
386 require_once(
'template/result_receipt.php');
390 echo HtmlInput::submit(
'download_receipt',
'Télécharger',
' onclick="$(\'act\').value=\'download\'" ');
398 $prefix=
new IText(
'prefix');
399 $number=
new INum(
'number');
400 $submit=HtmlInput::submit(
'chg_receipt',
'Valider',
' onclick="$(\'act\').value=\'numbering\'" ');
401 $hidden=HtmlInput::get_to_hidden(array(
'ledger',
'dend',
'dstart'));
402 $with_step=
new ISelect(
'istep');
403 $with_step->value=array(
404 array(
'value'=>1,
'label'=>
'Non'),
405 array(
'value'=>2,
'label'=>
'Oui')
408 require_once(
'template/numbering.php');
419 echo
" <p class=\"error\">$msg</p>";
422 $cn->prepare(
'update_receipt',
'update jrn set jr_pj_number=$1 where jr_id =$2');
423 $start=$_POST[
'number'];
425 if (trim($start)==
""||$_POST[
'istep']==2)
429 foreach ($_POST[
'jr_id'] as
$id)
432 $pj=trim($_POST[
'prefix']).sprintf(
"%d", $start);
434 $pj=trim($_POST[
'prefix']);
438 $result_update=
$cn->execute(
'update_receipt', array($pj, $id));
451 $dirname=tempnam($_ENV[
'TMP'],
'receipt');
456 $jr_id = HtmlInput::default_value_post(
'jr_id',array());
457 if (empty ($jr_id ) ) {
458 echo
'<div class="notice">'._(
'Aucune opération sélectionnée').
'</div>';
462 foreach ( $_POST[
'jr_id'] as $value)
464 $a_invoice=$cn->get_array(
"select jr_pj_name,jr_pj from jrn where jr_id = $1", array($value));
465 $invoice=$a_invoice[0];
466 if ($invoice[
'jr_pj_name']!=
""&&$invoice[
'jr_pj']!=
"")
468 $file=$dirname.
'/'.$invoice[
'jr_pj_name'];
469 $cn->lo_export($invoice[
'jr_pj'],
$file);
470 $feedback[]=_(
'Ajout pièce ').$invoice[
'jr_pj_name'];
474 $date=date(
'ymd.Hi');
475 $zip_file=$_ENV[
'TMP'].
"/".
"receipt-".$date.
".zip";
478 $zip=
new Zip_Extended();
479 $res=$zip->open($zip_file, ZipArchive::CREATE);
482 die(
"Cannot create zip file");
484 $zip->add_recurse_folder($dirname.
"/");
487 $link=http_build_query(array(
'gDossier'=>
Dossier::id(),
'ac'=>
$_REQUEST[
'ac'],
'plugin_code'=>
$_REQUEST[
'plugin_code'],
'act'=>
'download_receipt',
'file'=>basename($zip_file)));
491 <?php echo _(
'Pièce'); ?>
494 <?php
foreach ($feedback as
$row): ?>
503 <a
class=
"button" style=
"display:inline;" href=
"extension.raw.php?<?php echo $link; ?>"> <?php echo _(
'Télécharger le fichier') ?></a>
for($i=0;$i< Database::num_row($ret);$i++) $row
if(isset($_POST['remove'])) $array