00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 if ( ! defined('ALLOWED')) define ('ALLOWED',1);
00038
00039 require_once '../include/constant.php';
00040 require_once('class_database.php');
00041 require_once ('class_fiche.php');
00042 require_once('class_iradio.php');
00043 require_once('function_javascript.php');
00044 require_once('ac_common.php');
00045 require_once ('class_user.php');
00046 mb_internal_encoding("UTF-8");
00047
00048 $var = array('gDossier', 'op');
00049 $cont = 0;
00050
00051 foreach ($var as $v)
00052 {
00053 if (!isset($_REQUEST [$v]))
00054 {
00055 echo "$v is not set ";
00056 $cont = 1;
00057 }
00058 }
00059 if ($cont != 0)
00060 exit();
00061 extract($_REQUEST);
00062 set_language();
00063 global $g_user, $cn, $g_parameter;
00064 $cn = new Database($gDossier);
00065 $g_user = new User($cn);
00066 $g_user->check(true);
00067 $g_user->check_dossier($gDossier, true);
00068 if ($gDossier<>0) {
00069 $g_parameter=new Own($cn);
00070 }
00071 $html = var_export($_REQUEST, true);
00072
00073 if ( LOGINPUT)
00074 {
00075 $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
00076 fwrite ($file_loginput,"<?php \n");
00077 fwrite ($file_loginput,'//@description:'.$op."\n");
00078 fwrite($file_loginput, '$_GET='.var_export($_GET,true));
00079 fwrite($file_loginput,";\n");
00080 fwrite($file_loginput, '$_POST='.var_export($_POST,true));
00081 fwrite($file_loginput,";\n");
00082 fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
00083 fwrite($file_loginput,"\n");
00084 fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
00085 fwrite($file_loginput,"\n");
00086 fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
00087 fwrite($file_loginput,"\n");
00088 fwrite($file_loginput,"include '".basename(__FILE__)."';\n");
00089 fclose($file_loginput);
00090 }
00091 switch ($op)
00092 {
00093 case "remove_anc":
00094 if ($g_user->check_module('ANCODS') == 0)
00095 exit();
00096 $cn->exec_sql("delete from operation_analytique where oa_group=$1", array($_GET['oa']));
00097 break;
00098 case "rm_stock":
00099 if ($g_user->check_module('STOCK') == 0)
00100 exit();
00101 require_once('constant.security.php');
00102 $cn->exec_sql('delete from stock_goods where sg_id=$1', array($s_id));
00103 $html = escape_xml($s_id);
00104 header('Content-type: text/xml; charset=UTF-8');
00105 printf('{"d_id":"%s"}', $s_id);
00106 exit();
00107 break;
00108
00109
00110 case 'lastdate':
00111 require_once('class_acc_ledger_fin.php');
00112 $ledger = new Acc_Ledger_Fin($cn, $_GET['p_jrn']);
00113 $html = $ledger->get_last_date();
00114 $html = escape_xml($html);
00115 header('Content-type: text/xml; charset=UTF-8');
00116 echo <<<EOF
00117 <?xml version="1.0" encoding="UTF-8"?>
00118 <data>
00119 <code>e_date</code>
00120 <value>$html</value>
00121 </data>
00122 EOF;
00123
00124 break;
00125 case 'bkname':
00126 require_once('class_acc_ledger_fin.php');
00127 $ledger = new Acc_Ledger_Fin($cn, $_GET['p_jrn']);
00128 $html = $ledger->get_bank_name();
00129 $html = escape_xml($html);
00130 header('Content-type: text/xml; charset=UTF-8');
00131 echo <<<EOF
00132 <?xml version="1.0" encoding="UTF-8"?>
00133 <data>
00134 <code>bkname</code>
00135 <value>$html</value>
00136 </data>
00137 EOF;
00138 break;
00139
00140 case 'cal':
00141 require_once('class_calendar.php');
00142
00143 $cal = new Calendar();
00144 $cal->set_periode($per);
00145
00146 $html = "";
00147 $html = $cal->display($_GET['t']);
00148 $html = escape_xml($html);
00149 header('Content-type: text/xml; charset=UTF-8');
00150 echo <<<EOF
00151 <?xml version="1.0" encoding="UTF-8"?>
00152 <data>
00153 <code>$html</code>
00154 </data>
00155 EOF;
00156 break;
00157
00158 case 'rem_cat_doc':
00159 require_once('class_document_type.php');
00160
00161 if ($g_user->check_action(PARCATDOC) == 0)
00162 {
00163 $html = "nok";
00164 header('Content-type: text/xml; charset=UTF-8');
00165 echo <<<EOF
00166 <?xml version="1.0" encoding="UTF-8"?>
00167 <data>
00168 <dtid>$html</dtid>
00169 </data>
00170 EOF;
00171 return;
00172 }
00173
00174 $count_md = $cn->get_value('select count(*) from document_modele where md_type=$1', array($dt_id));
00175 $count_a = $cn->get_value('select count(*) from action_gestion where ag_type=$1', array($dt_id));
00176
00177 if ($count_md != 0 || $count_a != 0)
00178 {
00179 $html = "nok";
00180 header('Content-type: text/xml; charset=UTF-8');
00181 echo <<<EOF
00182 <?xml version="1.0" encoding="UTF-8"?>
00183 <data>
00184 <dtid>$html</dtid>
00185 </data>
00186 EOF;
00187 exit;
00188 }
00189 $cn->exec_sql('delete from document_type where dt_id=$1', array($dt_id));
00190 $html = $dt_id;
00191 header('Content-type: text/xml; charset=UTF-8');
00192 echo <<<EOF
00193 <?xml version="1.0" encoding="UTF-8"?>
00194 <data>
00195 <dtid>$html</dtid>
00196 </data>
00197 EOF;
00198 return;
00199 break;
00200 case 'mod_cat_doc':
00201 require_once 'template/document_mod_change.php';
00202 break;
00203 case 'dsp_tva':
00204 $cn = new Database($gDossier);
00205 $Res = $cn->exec_sql("select * from tva_rate order by tva_rate desc");
00206 $Max = Database::num_row($Res);
00207 $r = "";
00208 $r = HtmlInput::anchor_close('tva_select');
00209 $r.=h2(_('Choisissez la TVA '),'class="title"');
00210 $r.='<div >';
00211 $r.= '<TABLE style="width:100%">';
00212 $r.=th('');
00213 $r.=th(_('code'));
00214 $r.=th(_('Taux'));
00215 $r.=th(_('Symbole'));
00216 $r.=th(_('Explication'));
00217
00218 for ($i = 0; $i < $Max; $i++)
00219 {
00220 $row = Database::fetch_array($Res, $i);
00221 if (!isset($compute))
00222 {
00223 if (!isset($code))
00224 {
00225 $script = "onclick=\"$('$ctl').value='" . $row['tva_id'] . "';removeDiv('tva_select');\"";
00226 }
00227 else
00228 {
00229 $script = "onclick=\"$('$ctl').value='" . $row['tva_id'] . "';set_value('$code','" . $row['tva_label'] . "');removeDiv('tva_select');\"";
00230 }
00231 }
00232 else
00233 {
00234 if (!isset($code))
00235 {
00236 $script = "onclick=\"$('$ctl').value='" . $row['tva_id'] . "';removeDiv('tva_select');clean_tva('$compute');compute_ledger('$compute');\"";
00237 }
00238 else
00239 {
00240 $script = "onclick=\"$('$ctl').value='" . $row['tva_id'] . "';set_value('$code','" . $row['tva_label'] . "');removeDiv('tva_select');clean_tva('$compute');compute_ledger('$compute');\"";
00241 }
00242 }
00243 $set = '<INPUT TYPE="BUTTON" class="button" Value="select" ' . $script . '>';
00244 $class=($i%2 == 0)?' class="odd" ':' class="even" ';
00245 $r.='<tr'.$class. '>';
00246 $r.=td($set);
00247 $r.=td($row['tva_id']);
00248 $r.=td($row['tva_rate']);
00249 $r.=td($row['tva_label']);
00250 $r.=td($row['tva_comment']);
00251 $r.='</tr>';
00252 }
00253 $r.='</TABLE>';
00254 $r.='</div>';
00255 $html = escape_xml($r);
00256
00257 header('Content-type: text/xml; charset=UTF-8');
00258 echo <<<EOF
00259 <?xml version="1.0" encoding="UTF-8"?>
00260 <data>
00261 <code>$html</code>
00262 <popup>$popup</popup>
00263 </data>
00264 EOF;
00265 break;
00266 case 'label_tva':
00267 $cn = new Database($gDossier);
00268 if (isNumber($id) == 0)
00269 $value = _('tva inconnue');
00270 else
00271 {
00272 $Res = $cn->get_array("select * from tva_rate where tva_id = $1", array($id));
00273 if (count($Res) == 0)
00274 $value = _('tva inconnue');
00275 else
00276 $value = $Res[0]['tva_label'];
00277 }
00278 header('Content-type: text/xml; charset=UTF-8');
00279 echo <<<EOF
00280 <?xml version="1.0" encoding="UTF-8"?>
00281 <data>
00282 <code>$code</code>
00283 <value>$value</value>
00284 </data>
00285 EOF;
00286
00287 break;
00288
00289
00290
00291 case 'dl':
00292 require_once('class_lettering.php');
00293 $exercice = $g_user->get_exercice();
00294 if ($g_user->check_module("LETCARD") == 0 && $g_user->check_module("LETACC") == 0)
00295 exit();
00296 $periode = new Periode($cn);
00297 list($first_per, $last_per) = $periode->get_limit($exercice);
00298
00299 $ret = new IButton('return');
00300 $ret->label = _('Retour');
00301 $ret->javascript = "$('detail').hide();$('list').show();$('search').show();";
00302
00303
00304 $sql = "select j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,J_POSTE,j_qcode,jr_id,
00305 jr_comment,j_montant, j_debit,jr_internal from jrnx join jrn on (j_grpt=jr_grpt_id)
00306 where j_id=$1";
00307 $arow = $cn->get_array($sql, array($j_id));
00308 $row = $arow[0];
00309 $r = '';
00310 $r.='<fieldset><legend>' . _('Lettrage') . '</legend>';
00311 $r.=_('Poste')." " . $row['j_poste'] . ' ' . $row['j_qcode'] . '<br>';
00312
00313 $detail = "<A class=\"detail\" style=\"display:inline\" HREF=\"javascript:modifyOperation('" . $row['jr_id'] . "'," . $gDossier . ")\" > " . $row['jr_internal'] . "</A>";
00314
00315 $r.=_('Date').' : ' . $row['j_date_fmt'] . ' ref :' . $detail . ' <br> ';
00316 $r.=h($row['jr_comment']) ." ". _("montant")." : " . ($row['j_montant']) . " " . (($row['j_debit'] == 't') ? 'D' : 'C');
00317 $r.='</fieldset>';
00318 $r.='<div id="filtre" style="float:left;display:block">';
00319 $r.='<form method="get" id="search_form" onsubmit="search_letter(this);return false">';
00320 $r.='<div style="float:left;">';
00321
00322 $r.=dossier::hidden();
00323 if (isset($_REQUEST['ac']))
00324 $r.=HtmlInput::hidden('ac', $_REQUEST['ac']);
00325 if (isset($_REQUEST['sa']))
00326 $r.=HtmlInput::hidden('sa', $_REQUEST['sa']);
00327 if (isset($_REQUEST['acc']))
00328 $r.=HtmlInput::hidden('acc', $_REQUEST['acc']);
00329 $r.=HtmlInput::hidden('j_id', $j_id);
00330 $r.=HtmlInput::hidden('op', $op);
00331 $r.=HtmlInput::hidden('ot', $ot);
00332
00333 $r.='<table>';
00334
00335 $line = td(_('Montant min. '));
00336 $min = new INum('min_amount');
00337 $min->value = (isset($min_amount)) ? $min_amount : $row['j_montant'];
00338 $min_amount = (isset($min_amount)) ? $min_amount : $row['j_montant'];
00339
00340 $line.=td($min->input());
00341
00342 $line.=td(_('Montant max. '));
00343 $max = new INum('max_amount');
00344 $max->value = (isset($max_amount)) ? $max_amount : $row['j_montant'];
00345 $max_amount = (isset($max_amount)) ? $max_amount : $row['j_montant'];
00346 $line.=td($max->input());
00347 $r.=tr($line);
00348
00349 $date_error="";
00350
00351 $start = new IDate('search_start');
00352
00353
00354 if (isset($search_start) && isDate($search_start) == null)
00355 {
00356 ob_start();
00357 alert(_('Date malformée'));
00358 $date_error = ob_get_contents();
00359 ob_end_clean();
00360 $search_start=$first_per->first_day();
00361 }
00362 $start->value = (isset($search_start)) ? $search_start : $first_per->first_day();
00363
00364 $line = td('Date Debut') . td($start->input());
00365
00366 $end = new IDate('search_end');
00367
00368 if (isset($search_end) && isDate($search_end) == null)
00369 {
00370 ob_start();
00371 alert(_('Date malformée'));
00372 $date_error = ob_get_contents();
00373 ob_end_clean();
00374 $search_end=$last_per->last_day();
00375 }
00376 $end->value = (isset($search_end)) ? $search_end : $last_per->last_day();
00377 $line.=td(_('Date Fin')) . td($end->input());
00378 $r.=tr($line);
00379
00380 $line = td(_('Debit / Credit'));
00381 $iside = new ISelect('side');
00382 $iside->value = array(
00383 array('label' => _('Debit'), 'value' => 0),
00384 array('label' => _('Credit'), 'value' => 1),
00385 array('label' => _('Les 2'), 'value' => 3)
00386 );
00387
00388
00389
00390
00391
00392
00393
00394 if (!isset($side))
00395 {
00396
00397 $jl_id = $cn->get_value('select comptaproc.get_letter_jnt($1)', array($j_id));
00398 if ($jl_id == null)
00399 {
00400
00401 $iside->selected = (isset($side)) ? $side : (($row['j_debit'] == 't') ? 1 : 0);
00402 $side = (isset($side)) ? $side : (($row['j_debit'] == 't') ? 1 : 0);
00403 }
00404 else
00405 {
00406
00407 $iside->selected = 3;
00408 $side = 3;
00409 }
00410 }
00411 else
00412 {
00413 $iside->selected = $side;
00414 }
00415
00416 $r.=tr($line . td($iside->input()));
00417 $r.='</table>';
00418 $r.='</div>';
00419 $r.='<div style="float:left;padding-left:100">';
00420 $r.=HtmlInput::submit('search', 'Rechercher');
00421 $r.='</div>';
00422 $r.='</form>';
00423 $r.='</div>';
00424
00425 $form = '<div id="result" style="float:top;clear:both">';
00426
00427 $form.='<FORM id="letter_form" METHOD="post">';
00428 $form.=dossier::hidden();
00429 if (isset($_REQUEST['p_action']))
00430 $form.=HtmlInput::hidden('p_action', $_REQUEST['p_action']);
00431 if (isset($_REQUEST['sa']))
00432 $form.=HtmlInput::hidden('sa', $_REQUEST['sa']);
00433 if (isset($_REQUEST['acc']))
00434 $form.=HtmlInput::hidden('acc', $_REQUEST['acc']);
00435 if (isset($_REQUEST['sc']))
00436 $form.=HtmlInput::hidden('sc', $_REQUEST['sc']);
00437 if (isset($_REQUEST['sb']))
00438 $form.=HtmlInput::hidden('sb', $_REQUEST['sb']);
00439 if (isset($_REQUEST['f_id']))
00440 $form.=HtmlInput::hidden('f_id', $_REQUEST['f_id']);
00441
00442
00443
00444 if ($ot == 'account')
00445 {
00446 $obj = new Lettering_Account($cn, $row['j_poste']);
00447 if (isset($search_start))
00448 $obj->start = $search_start;
00449 if (isset($search_end))
00450 $obj->end = $search_end;
00451 if (isset($max_amount))
00452 $obj->fil_amount_max = $max_amount;
00453 if (isset($min_amount))
00454 $obj->fil_amount_min = $min_amount;
00455 if (isset($side))
00456 $obj->fil_deb = $side;
00457
00458 $form.=$obj->show_letter($j_id);
00459 }
00460 else if ($ot == 'card')
00461 {
00462 $obj = new Lettering_Card($cn, $row['j_qcode']);
00463 if (isset($search_start))
00464 $obj->start = $search_start;
00465 if (isset($search_end))
00466 $obj->end = $search_end;
00467 if (isset($max_amount))
00468 $obj->fil_amount_max = $max_amount;
00469 if (isset($min_amount))
00470 $obj->fil_amount_min = $min_amount;
00471 if (isset($side))
00472 $obj->fil_deb = $side;
00473 $form.=$obj->show_letter($j_id);
00474 }
00475 else
00476 {
00477 $form.=_('Mauvais type objet');
00478 }
00479
00480 $form.=HtmlInput::submit('record', _('Sauver')) . $ret->input();
00481 $form.='</FORM>';
00482 $form.='</div>';
00483
00484 $html = $r . $form;
00485 $html.=$date_error;
00486
00487 $html = escape_xml($html);
00488
00489 header('Content-type: text/xml; charset=UTF-8');
00490 echo <<<EOF
00491 <?xml version="1.0" encoding="UTF-8"?>
00492 <data>
00493 <code>detail</code>
00494 <value>$html</value>
00495 </data>
00496 EOF;
00497 break;
00498 case 'mod_doc':
00499 require_once('ajax_mod_document.php');
00500 break;
00501 case 'input_per':
00502 require_once('ajax_mod_periode.php');
00503 break;
00504 case 'save_per':
00505 require_once('ajax_mod_periode.php');
00506 break;
00507 case 'mod_predf':
00508 require_once('ajax_mod_predf_op.php');
00509 break;
00510 case 'save_predf':
00511 require_once('ajax_save_predf_op.php');
00512 break;
00513 case 'search_op':
00514 require_once 'search.inc.php';
00515 break;
00516 case 'search_action':
00517 require_once 'ajax_search_action.php';
00518 break;
00519 case 'display_profile':
00520 require_once("ajax_get_profile.php");
00521 break;
00522 case 'det_menu':
00523 require_once("ajax_get_menu_detail.php");
00524 break;
00525 case 'add_menu':
00526 require_once 'ajax_add_menu.php';
00527 break;
00528 case 'cardsearch':
00529 require_once 'ajax_boxcard_search.php';
00530 break;
00531 case 'add_plugin':
00532 $me_code = new IText('me_code');
00533 $me_file = new IText('me_file');
00534 $me_menu = new IText('me_menu');
00535 $me_description = new IText("me_description");
00536 $me_parameter = new IText("me_parameter");
00537 $new = true;
00538 require_once 'ajax_plugin_detail.php';
00539 break;
00540 case 'mod_plugin':
00541 $m = $cn->get_array("select me_code,me_file,me_menu,me_description,me_parameter
00542 from menu_ref where me_code=$1", array($me_code));
00543 if (empty($m))
00544 {
00545 echo HtmlInput::title_box("Ce plugin n'existe pas ", $ctl);
00546 echo "<p>Il y a une erreur, ce plugin n'existe pas";
00547 exit;
00548 }
00549 $me_code = new IText('me_code', $m[0] ['me_code']);
00550 $me_file = new IText('me_file', $m[0] ['me_file']);
00551 $me_menu = new IText('me_menu', $m[0] ['me_menu']);
00552 $me_description = new IText("me_description", $m[0] ['me_description']);
00553 $me_parameter = new IText("me_parameter", $m[0] ['me_parameter']);
00554 $new = false;
00555 require_once 'ajax_plugin_detail.php';
00556 break;
00557 case 'saldo':
00558 require_once 'ajax_bank_saldo.php';
00559 break;
00560 case 'up_predef':
00561 require_once 'ajax_update_predef.php';
00562 break;
00563 case 'upd_receipt':
00564 require_once 'ajax_get_receipt.php';
00565 break;
00566 case 'up_pay_method':
00567 require_once 'ajax_update_payment.php';
00568 break;
00569 case 'openancsearch':
00570 case 'resultancsearch':
00571 require_once('ajax_anc_search.php');
00572 break;
00573 case 'autoanc':
00574 require_once 'ajax_auto_anc_card.php';
00575 break;
00576 case 'create_menu';
00577 require_once 'ajax_create_menu.php';
00578 break;
00579 case 'modify_menu';
00580 require_once 'ajax_mod_menu.php';
00581 break;
00582 case 'mod_stock_repo':
00583 require_once 'ajax_mod_stock_repo.php';
00584 break;
00585 case 'view_mod_stock':
00586 require_once 'ajax_view_mod_stock.php';
00587 break;
00588 case 'fddetail':
00589 require_once 'ajax_fiche_def_detail.php';
00590 break;
00591 case 'vw_action':
00592 require_once 'ajax_view_action.php';
00593 break;
00594 case 'minrow':
00595 require_once 'ajax_min_row.php';
00596 break;
00597 case 'navigator':
00598 require_once 'ajax_navigator.php';
00599 break;
00600 case 'preference':
00601 require_once 'ajax_preference.php';
00602 break;
00603 case 'bookmark':
00604 require_once 'ajax_bookmark.php';
00605 break;
00606 case 'tag_detail':
00607 require_once 'ajax_tag_detail.php';
00608 break;
00609 case 'tag_save':
00610 require_once 'ajax_tag_save.php';
00611 break;
00612 case 'tag_list':
00613 require_once 'ajax_tag_list.php';
00614 break;
00615 case 'tag_add':
00616 require_once 'ajax_tag_add_action.php';
00617 break;
00618 case 'tag_remove':
00619 require_once 'ajax_tag_remove_action.php';
00620 break;
00621 case 'tag_choose':
00622 require_once 'ajax_tag_choose.php';
00623 break;
00624 case 'tag_choose':
00625 require_once 'ajax_tag_choose.php';
00626 break;
00627 case 'search_display_tag':
00628 require_once 'ajax_search_display_tag.php';
00629 break;
00630 case 'search_add_tag':
00631 require_once 'ajax_search_add_tag.php';
00632 break;
00633 case 'search_clear_tag':
00634 require_once 'ajax_search_clear_tag.php';
00635 break;
00636 case 'calendar_zoom':
00637 require_once 'ajax_calendar_zoom.php';
00638 break;
00639 case 'ledger_show':
00640 require_once 'ajax_ledger_show.php';
00641 case 'ledger_description':
00642 $ajrn=$cn->get_array('select jrn_def_name,jrn_def_description from jrn_def where jrn_def_id=$1',array($l));
00643 if ( count($ajrn)==1)
00644 {
00645 echo '<div>';
00646 echo '<h2 id="info">'.$ajrn[0]['jrn_def_name'].'</h2>';
00647 if ( trim($ajrn[0]['jrn_def_description']) != "") {
00648 echo '<p style="border:1px solid;margin-top:0px">'.$ajrn[0]['jrn_def_description'].'</p>';
00649 }
00650 echo '</div>';
00651 }
00652 exit();
00653 break;
00654
00655 case 'anc_key_choice':
00656
00657
00658
00659 require_once 'ajax_anc_key_choice.php';
00660 break;
00661 case 'anc_key_compute':
00662
00663
00664
00665 require_once 'ajax_anc_key_compute.php';
00666 break;
00667 case 'account_update':
00668
00669
00670
00671 require_once 'ajax_account_update.php';
00672 break;
00673 default:
00674 var_dump($_GET);
00675 }