diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 6fb34ea10..79878c184 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -44,6 +44,13 @@ function update_predef(p_type,p_direct) } ); } +/** + *@brief update ctl id =jrn_name with the value of p_jrn + */ +function update_name() +{ + $('jrn_name').innerHTML=$('p_jrn').options[$('p_jrn').selectedIndex].innerHTML; +} /** * @brief update the field predef */ diff --git a/html/style-color.css b/html/style-color.css index d44a07c6b..ff4a85464 100644 --- a/html/style-color.css +++ b/html/style-color.css @@ -921,3 +921,27 @@ table.result td padding-left:5px; padding-right:5px; } +table.info_op +{ + margin-left: 30%; + margin-right: 30%; + width:20%; + +} +table.info_op tr +{ +font-size:14; +background:white; +width:5% +} +h2#jrn_name +{ + margin-left:30%; + +} +tr.footer{ + font-size:14; + font-style: italic; + font-weight: bold; + +} \ No newline at end of file diff --git a/html/style-light.css b/html/style-light.css index dbda26eff..6ed0daa19 100644 --- a/html/style-light.css +++ b/html/style-light.css @@ -184,10 +184,11 @@ div.u_redcontent{ div.content{ float:left; padding-top:7px; - width:100%; + width:96%; font-family:helvetica,arial,sans-serif; clear:both; - + margin-left:2%; + } div.content30{ @@ -955,3 +956,30 @@ table.result td padding-left:5px; padding-right:5px; } +table.info_op +{ + margin-left: 30%; + margin-right: 30%; + width:20%; + +} +table.info_op tr +{ +font-size:14; +background:white; +width:5% +} +h2#jrn_name +{ + margin-right:50%; + float:right; + font-size:18; + display: inline; + color:#15158e; +} +tr.footer{ + font-size:14; + font-style: italic; + font-weight: bold; + +} \ No newline at end of file diff --git a/html/style.css b/html/style.css index 6586f257d..19b5db5ec 100644 --- a/html/style.css +++ b/html/style.css @@ -951,3 +951,27 @@ table.result td padding-left:5px; padding-right:5px; } +table.info_op +{ + font-size:18; + margin-right:30%; + width:20%; + +} +table.info_op tr +{ +font-size:14; +background:white; +} +h2#jrn_name +{ + margin-left:30%; + float: right; + +} +tr.footer{ + font-size:14; + font-style: italic; + font-weight: bold; + +} \ No newline at end of file diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index ce2102133..0fbf91172 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -1207,7 +1207,7 @@ class Acc_Ledger * \param $p_array array from the form * \return string */ - function show_summary($p_array) + function confirm($p_array,$p_readonly=false) { $this->id=$p_array['p_jrn']; if ( empty($p_array)) return 'Aucun résultat'; @@ -1223,22 +1223,25 @@ class Acc_Ledger $lPeriode->find_periode($e_date); } $owner=new own($this->db); + $total=0; + bcscale(2); $ret=""; - $ret.=""; + $ret.="
"; $ret.=""; /* display periode */ $date_limit=$lPeriode->get_date_limit(); - $ret.=''; + $ret.=' '.td(_('Période Comptable')).td($date_limit['p_start'].'-'.$date_limit['p_end']).''; $ret.=""; $ret.=""; $ret.='
"._('Date')." : $e_date
'._('Période Comptable').' '.$date_limit['p_start'].'-'.$date_limit['p_end'].'
"._('Libellé')." ".h($desc)."
"._('PJ Num')." ".h($e_pj)."
'; - $ret.=""; + $ret.="
"; $ret.=""; - $ret.=""; - $ret.=""; - $ret.=""; + $ret.=""; + $ret.=""; + $ret.=""; /* if we use the AC */ if ($owner->MY_ANALYTIC!='nu') { @@ -1246,7 +1249,7 @@ class Acc_Ledger $a_anc=$anc->get_list(); $x=count($a_anc); /* set the width of the col */ - $ret.=''; + $ret.=''; /* add hidden variables pa[] to hold the value of pa_id */ $ret.=Anc_Plan::hidden($a_anc); @@ -1273,6 +1276,12 @@ class Acc_Ledger $count=0; for ($i=0;$i<$nb_item;$i++) { + if ( $p_readonly == true ) + { + if ( ! isset (${'qc_'.$i})) ${'qc_'.$i}=''; + if ( ! isset (${'poste'.$i})) ${'poste'.$i}=''; + if ( ! isset (${'amount'.$i})) ${'amount'.$i}=''; + } $ret.=""; if ( trim(${'qc_'.$i})!="") { @@ -1298,9 +1307,12 @@ class Acc_Ledger if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) == "") continue; $ret.=""; - $ret.=""; + if ( isset(${"ck$i"})) + $ret.="".td(""); + else + $ret.=td("").""; + $total=bcadd($total,${"amount".$i}); $ret.=""; // CA @@ -1316,8 +1328,9 @@ class Acc_Ledger /* op is the operation it contains either a sequence or a jrnx.j_id */ $ret.=HtmlInput::hidden('op[]=',$i); - $ret.=''; $count++; } @@ -1329,8 +1342,10 @@ class Acc_Ledger $ret.=""; } + $ret.=tr(td('').td(_('Totaux')).td($total,'class="num"').td($total,'class="num"'),'class="footer"'); $ret.="
"._('Quick Code ou'); + $ret.=""._('Quick Code ou '); $ret.=_("Poste")." "._("Montant")." "._("Débit")." "._("Libellé")." "._("Débit").""._("Crédit")."'._('Compt. Analytique').''._('Compt. Analytique').'
".h(${"ld".$i}).HtmlInput::hidden('ld'.$i,${'ld'.$i})."".${"amount".$i}.HtmlInput::hidden('amount'.$i,${'amount'.$i})."".${"amount".$i}.HtmlInput::hidden('amount'.$i,${'amount'.$i})."".${"amount".$i}.HtmlInput::hidden('amount'.$i,${'amount'.$i}).""; - $ret.=(isset(${"ck$i"}))?"D":"C"; $ret.=(isset(${"ck$i"}))?HtmlInput::hidden('ck'.$i,${'ck'.$i}):""; $ret.="'; - $ret.=$op->display_form_plan($p_array,$null,1,$count,round(${'amount'.$i},2)); + $ret.=''; + $read=($p_readonly==true)?0:1; + $ret.=$op->display_form_plan($p_array,$null,$read,$count,round(${'amount'.$i},2)); $ret.='
"; - if ( $owner->MY_ANALYTIC!='nu' ) $ret.=''; + if ( $owner->MY_ANALYTIC!='nu' && $p_readonly==false) + $ret.=''; return $ret; } @@ -1341,7 +1356,7 @@ class Acc_Ledger * * \return a string containing the form */ - function show_form($p_array=null,$p_readonly=0) + function input($p_array=null,$p_readonly=0) { $user = new User($this->db); $owner=new Own($this->db); @@ -1351,6 +1366,12 @@ class Acc_Ledger if ( $p_array != null ) extract($p_array); + $add_js=""; + if ( $owner->MY_PJ_SUGGEST=='Y') + { + $add_js="update_pj();"; + } + $add_js.='get_last_date();'; $ret=""; /* Add button */ @@ -1359,7 +1380,15 @@ class Acc_Ledger $f_add_button->set_attribute('ipopup','ipop_newcard'); $f_add_button->set_attribute('jrn',$this->id); $f_add_button->javascript=" this.jrn=\$('p_jrn').value;select_card_type(this);"; - $ret.=$f_add_button->input(); + $f_add_button->input(); + + $wLedger=$this->select_ledger('ODS',2); + if ($wLedger == null) exit (_('Pas de journal disponible')); + $wLedger->javascript="onChange='update_name();update_predef(\"ods\",\"t\");$add_js'"; + $label=" Journal ".HtmlInput::infobulle(2) ; + + $ret.=$label.$wLedger->input(); + // Load the javascript // @@ -1435,12 +1464,12 @@ class Acc_Ledger $ret.=HtmlInput::hidden('nb_item',$nb_row); $ret.=dossier::hidden(); - $ret.=HtmlInput::hidden('p_jrn',$this->id); $ret.=dossier::hidden(); $ret.=HtmlInput::hidden('jrn_type',$this->get_type()); $info= HtmlInput::infobulle(0); $info_poste=HtmlInput::infobulle(9); + $ret.=$f_add_button->input(); $ret.=''; $ret.=''. ''. @@ -2893,4 +2922,6 @@ class Acc_Ledger $first_name=$this->db->get_value('select ad_value from fiche_detail where ad_id=32 and f_id=$1',array($tiers)); return $name.' '.$first_name; } + + } diff --git a/include/compta_ods.inc.php b/include/compta_ods.inc.php index 5f0fdf049..9323d3246 100644 --- a/include/compta_ods.inc.php +++ b/include/compta_ods.inc.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -/*!\file +/* !\file * * * \brief to write directly into the ledgers,the stock and the tables @@ -35,118 +35,81 @@ require_once('class_periode.php'); require_once('function_javascript.php'); require_once('class_ipopup.php'); +global $g_user; + +$cn = new Database(dossier::id()); + +$id = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : -1; +$ledger = new Acc_Ledger($cn, $id); +$first_ledger = $ledger->get_first('ODS'); +$ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id; + +/* !\brief show a form for quick_writing */ +$id = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : -1; +$def = -1; +$ledger->with_concerned = true; -$cn=new Database(dossier::id()); -$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1; -/*!\brief show a form for quick_writing */ -function show_qw_menu($def=0) + + +if ($g_user->check_jrn($id) == 'X') { - echo ''; + NoAccess(); + exit - 1; } -/*!\brief show a form for quick_writing */ -function show_direct_form($cn,$ledger,$p_array) +if (!isset($_POST['summary']) && !isset($_POST['save'])) { - echo '
'; - - $id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1; - - // Show the predef operation - // Don't forget the p_jrn - echo '
'; - echo HtmlInput::hidden('p_action',$_REQUEST['p_action']); - echo dossier::hidden(); - echo HtmlInput::hidden('p_jrn',$_REQUEST['p_jrn']); - $op=new Pre_operation($cn); - $op->p_jrn=$_REQUEST['p_jrn']; - $op->od_direct='t'; - if ( $op->count() > 0 ) - { - echo _("Utilisez une operation "); - echo $op->show_button(); - echo HtmlInput::submit('use_opd',_('Utilisez une operation')); - } - echo ''; - - - - echo '
'; - echo dossier::hidden(); - echo HtmlInput::hidden('p_action',$_REQUEST['p_action']); - - echo $ledger->show_form($p_array); - - - echo HtmlInput::button('add',_('Ajout d\'une ligne'),'onClick="quick_writing_add_row()"'); - - echo HtmlInput::submit('summary',_('Sauvez')); - echo '
'. - _('Débit').' = '. - _('Crédit').' = '. - _('Difference').' =
'; - - - echo ''; - - echo ""; - - echo create_script(" get_last_date()"); - - echo '
'; - + require('operation_ods_new.inc.php'); + exit(); } - -$ledger=new Acc_Ledger($cn,$id); - -$ledger->with_concerned=true; -// no ledger selected, propose one -// Only ODS -if ($id == -1 ) +elseif (isset($_POST['summary'])) { - echo '
'; - - // Vide - echo '
'; - echo dossier::hidden(); - echo HtmlInput::hidden('p_action',$_REQUEST['p_action']); - echo $ledger->select_ledger('ODS',3)->input(); - echo HtmlInput::submit('show_form',_('Choix du journal')); - echo ''; - echo '
'; - exit(); + require_once 'operation_ods_confirm.inc.php'; + exit(); } -if ( $User->check_jrn($id) == 'X' ) +elseif (isset($_POST['save'])) +{ + $array = $_POST; + + try + { + $ledger->save($array); + $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal)); + + echo '

Opération enregistrée Piece ' . h($ledger->pj) . '

'; + if (strcmp($ledger->pj, $_POST['e_pj']) != 0) + { + echo '

' . _('Attention numéro pièce existante, elle a du être adaptée') . '

'; + } + printf('%s
', $jr_id, dossier::id(), $ledger->internal); + + // show feedback + echo $ledger->confirm($_POST, true); + } + catch (Exception $e) + { + require('operation_ods_new.inc.php'); + alert($e->getMessage()); + } + exit(); +} +exit(); + + + +if ( $g_user->check_jrn($id) == 'X' ) { alert(_("L'acces a ce journal est interdit, \n contactez votre responsable")); exit(); } -echo '
'; -echo '
'; -echo '

'._('Journal').' : '.$ledger->get_name().'

'; -echo '
'; -$sa=( isset ($_REQUEST['sa']))?$_REQUEST['sa']:''; + //====================================================================== // See the ledger listing if ($sa == 'l' && $id != -1) { // Check privilege - if ( $User->check_jrn($id) == 'X') + if ( $g_user->check_jrn($id) == 'X') { NoAccess(); exit -1; @@ -154,19 +117,19 @@ if ($sa == 'l' && $id != -1) show_qw_menu(1); echo '
'; $Ledger=new Acc_Ledger($cn,$id); - + $type=$Ledger->get_type(); $href=basename($_SERVER['PHP_SELF']); echo '
'; echo HtmlInput::hidden("sa","l"); echo HtmlInput::hidden("p_jrn",$id); - echo HtmlInput::hidden("p_action","quick_writing"); + echo HtmlInput::hidden("ac",$_REQUEST['sa']); echo dossier::hidden(); echo $Ledger->search_form($type,0); echo HtmlInput::submit("qwlist",_("Recherche")); echo ''; - + $array=$_GET; list($sql,$where)=$Ledger->build_search_sql($array); @@ -185,7 +148,7 @@ if ($sa == 'l' && $id != -1) /* * Export to csv */ - $r=HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max','qcode','accounting','unpaid','gDossier','ledger_type','p_action')); + $r=HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max','qcode','accounting','unpaid','gDossier','ledger_type','ac')); if (isset($_GET['r_jrn'])) { foreach ($_GET['r_jrn'] as $k=>$v) $r.=HtmlInput::hidden('r_jrn['.$k.']',$v); @@ -205,27 +168,20 @@ if ($sa == 'l' && $id != -1) // User can write ? // Write into the ledger -if ( $User->check_jrn($id) == 'X' ) +if ( $g_user->check_jrn($id) == 'X' ) { alert(_("Vous ne pouvez pas accèder à ce journal, contactez votre responsable")); exit -1; } -if ( $User->check_jrn($id)=='W' ) +if ( $g_user->check_jrn($id)=='W' ) { - if ( isset($_GET['show_form']) || isset($_POST['correct_it']) ) + if ( ($sa=='n' || isset($_POST['correct_it'])) && ! isset($_POST['summary'])) { $array=$_POST; - $default_periode=$User->get_periode(); + $default_periode=$g_user->get_periode(); /* check if the ledger is closed */ - if ( $ledger->is_closed($default_periode)==1) - { - echo '

'._('Désolé mais cette periode est fermee pour ce journal').'

'; - exit(); - } - $periode=new Periode($cn); - list($date,$devnull)=$periode->first_day($default_periode); - $array['date']=$date; + show_qw_menu(); show_direct_form($cn,$ledger,$array); exit(); @@ -250,42 +206,7 @@ if ( $User->check_jrn($id)=='W' ) exit(); } - if ( isset($_POST['summary'])) - { - try - { - $ledger->verify($_POST ); - } - catch (Exception $e) - { - alert($e->getMessage()); - show_qw_menu(); - show_direct_form($cn,$ledger,$_POST); - exit(); - } - echo '
'; - echo $ledger->show_form($_POST,1); - echo dossier::hidden(); - echo HtmlInput::hidden('p_action',$_REQUEST['p_action']); - - echo '
'; - $chk=new ICheckBox(); - $chk->selected=false; - echo $chk->input('opd_save'); - echo "Sauvez cette opération comme modèle d'opération ?"; - echo '
'; - $opd_name=new IText('opd_name'); - echo "Nom du modèle ".$opd_name->input(); - - echo '
'; - echo HtmlInput::submit('save_it',"Sauver",'onClick="return verify_ca();"'); - echo HtmlInput::submit('correct_it','Corriger'); - - echo ''; - exit(); - - } if ( isset($_POST['save_it' ])) { $array=$_POST;
Quickcode'.$info.'