diff --git a/html/calendar-blue.css b/html/calendar-blue.css index c7bb87f08..b403b9f6b 100644 --- a/html/calendar-blue.css +++ b/html/calendar-blue.css @@ -19,8 +19,8 @@ div.calendar { position: relative; z-index:13; } border-radius: 0px; } -.calendar .nav { - background: #778 url(menuarrow.gif) no-repeat 100% 100%; +.calendar .nav1 { + #background: #778 url(menuarrow.gif) no-repeat 100% 100%; } .calendar thead .title { /* This holds the current "month, year" */ diff --git a/html/image/logo7300.png b/html/image/logo7400.png similarity index 55% rename from html/image/logo7300.png rename to html/image/logo7400.png index 975ac2b8a..14d2577fb 100644 Binary files a/html/image/logo7300.png and b/html/image/logo7400.png differ diff --git a/html/image/logo7400.xcf b/html/image/logo7400.xcf new file mode 100644 index 000000000..95e59ef13 Binary files /dev/null and b/html/image/logo7400.xcf differ diff --git a/html/index.php b/html/index.php index d78c61938..a0263f654 100644 --- a/html/index.php +++ b/html/index.php @@ -191,7 +191,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -NOALYSS +NOALYSS
'. '

Noalyss

'. $goto . diff --git a/html/install.php b/html/install.php index 4aceab536..1536f6650 100644 --- a/html/install.php +++ b/html/install.php @@ -79,7 +79,7 @@

- NOALYSS + NOALYSS

NOALYSS : comptabilité - accountancy

@@ -601,7 +601,7 @@ if ($account == 0 ) { if ( ! DEBUG) ob_end_clean(); echo '

'._('Important').'

'; echo '

'._('Utilisateur administrateur'),' ',NOALYSS_ADMINISTRATOR,'

'; -echo '

',_('Mot de passe'),' phpcompta','

'; +echo '

',_('Mot de passe')," ",NOALYSS_ADMIN_PASSWORD,'

'; }// end if // Add a french accountancy model //-- diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index cfc61d27b..efdf71e65 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -879,7 +879,6 @@ function reverseOperation(obj) { var qs = $(obj).serialize()+ "&op=ledger"; g('ext' + obj.divname).style.display = 'none'; - g('bext' + obj.divname).style.display = 'none'; waiting_box(); new Ajax.Request( "ajax_misc.php", @@ -1473,4 +1472,44 @@ function reset_filter(p_div) { // By default , unpaid is uncked $(p_div+"operation_filter").value="all"; +} + +/** + * propose to duplicate an operation + */ +function duplicate_operation(p_dossier,p_jr_id) { + waiting_box(); + var duplicate_div=create_div({id:"duplicate_operation_div",cssclass:"inner_box"}); + + new Ajax.Request("ajax_misc.php", { + parameters : { + "op":"ledger", + "gDossier":p_dossier, + "jr_id":p_jr_id, + "act":"duplicateop", + "div":"duplicate_operation_div" + }, + onSuccess:function(req) { + remove_waiting_box(); + console.debug("success"); + var xml=req.responseXML; + console.debug ("received"+xml); + if ( xml.getElementsByTagName("ctl").length==0) { + console.log("erreur"+req.responseText); + } + console.debug("ok we display"); + add_div(duplicate_div); + console.debug (getNodeText(xml.getElementsByTagName("code")[0])); + + console.debug("fill div"); + duplicate_div.setStyle({"position":"fixed","top":"15%","z-index":"999", + "min-width":"30rem", + "left":"30%", + "width":"40%"}); + duplicate_div.innerHTML=getNodeText(xml.getElementsByTagName("code")[0]); + duplicate_div.setStyle({display:"block"}); + } + } + + ); } \ No newline at end of file diff --git a/html/js/card.js b/html/js/card.js index 71d8d4a37..773c9a0a9 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -663,13 +663,16 @@ function dis_blank_card(obj) } else { var dossier=obj.gDossier; } - var queryString='gDossier='+dossier; queryString+='&ctl='+content; queryString+='&fd_id='+fd_id; queryString+=ref; queryString+='&op2=bc'; // bc for blank card queryString+='&op=card'; // bc for blank card + if (obj.after_save) { + queryString+='&after_save='+obj.after_save; + } + if ( obj.elementId) queryString+="&eltid="+obj.elementId; var action=new Ajax.Request ( 'ajax_misc.php', { @@ -748,16 +751,42 @@ function save_card(obj) parameters:queryString, onFailure:errorFid, onSuccess:function (req,json) { - var elt=req.responseXML.getElementsByTagName("eltid"); var status=req.responseXML.getElementsByTagName("status"); var status_value='OK'; + var after_savetag=req.responseXML.getElementsByTagName("after_save"); + var after_save=0; if ( status.length !=0) { status_value=getNodeText(status[0]); } - if ( status_value == 'OK') { + if ( after_savetag.length !=0 ) { + after_save=getNodeText(after_savetag[0]); + } + // if status == OK and after_save == 0 + // then update the box + if ( status_value == 'OK' && after_save == 0) { fill_box(req,json); } + + // if status == OK and after_save == 1 + // then add a row to the table + if ( status_value == 'OK' && after_save == 1) { + var table_card=$('fiche_tb_id'); + f_id=getNodeText(req.responseXML.getElementsByTagName("f_id")[0]); + var row=new Element('tr'); + row.id="row_card"+f_id; + row.innerHTML=getNodeText(req.responseXML.getElementsByTagName("code")[0]); + table_card.tBodies[0].appendChild(row); + new Effect.Highlight(row.id ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); + // + if ( table_card.tBodies[0].rows.length % 2 == 0 ) { + row.addClassName("odd"); + } else { + row.addClassName("even"); + + } + } + remove_waiting_box(); if ( elt.length != 0) { var eltid=getNodeText(elt[0]); @@ -1022,3 +1051,169 @@ function delete_card(obj) { } }); } +/** + * Display a card , modify it , redraw the row + * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id + * @param {type} p_fiche_id + * @returns {undefined} + */ +function modify_card(p_fiche_id) +{ + /* window with result */ + card_layer++; + + var content = 'card_' + card_layer; + var nTop = 170 + card_layer; + if (nTop > 300) { + nTop = 170; + } + var str_top = fixed_position(250, nTop) + var str_style = str_top + ";width:45em;height:auto;position:absolute"; + + var popup = {'id': content, 'cssclass': 'inner_box', 'style': str_style, 'html': loading(), 'drag': false}; + + add_div(popup); + + /* dossier id */ + if ( ! document.getElementById("card_gdossier")) { + + console.error("card_gdossier error"); + throw ("card_gdossier not set"); + } + var dossier = $('card_gdossier').value; + + + var action = new Ajax.Request('ajax_misc.php', + { + method: 'get', + parameters: {'gDossier':dossier,"op":'card',"op2":"dc","f_id":p_fiche_id,'ctl':content,after_save:2} , + onFailure: errorFid, + onSuccess: function (respTxt) { + fill_box(respTxt); + } + } + ); +} +/** + * Delete a card and remove the row + * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id + * @param {type} p_fiche_id + * @returns {undefined} + */ +function delete_card_id(p_fiche_id) +{ + var row="row_card"+p_fiche_id; + if ( ! document.getElementById("card_gdossier")) { + + console.error("card_gdossier error"); + throw ("card_gdossier not set"); + } + $(row).addClassName("background-selected"); + var dossier = $('card_gdossier').value; + smoke.confirm(content[47], function (e) { + if (e) { + waiting_box(); + new Ajax.Request("ajax_misc.php", { + "method": "get", + parameters: {'gDossier':dossier,"op":'card',"op2":"rm_card","f_id":p_fiche_id,'ctl':row} , + onSuccess: function (req) { + remove_waiting_box(); + var table_card=$('fiche_tb_id'); + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + if (a.length == 0) + { + var rec = req.responseText; + alert_box('erreur :' + rec); + } + var html = answer.getElementsByTagName('code'); + var namectl = a[0].firstChild.nodeValue; + var nodeXml = html[0]; + var code_html = getNodeText(nodeXml); + code_html = unescape_xml(code_html); + + if ((code_html) == "OK") { + Effect.Fade(row, {duration: 0.1}); + table_card.tBodies[0].removeChild($(row)); + alternate_row_color("fiche_tb_id"); + } else { + smoke.alert(code_html); + + } + } + + }); + } else{ + $(row).removeClassName("background-selected"); + + } + }); + +} + +/** +* update a card in ajax , and update a row +* +*/ +function card_update_row(obj) +{ + try { + var name = obj.id; + + var qs = Form.serialize(name) + '&op2=upr&op=card'; + var action = new Ajax.Request('ajax_misc.php', + { + method: 'get', + parameters: qs, + onFailure: errorFid, + onSuccess: function (req) { + try { + + remove_waiting_box(); + + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + var html = answer.getElementsByTagName('code'); + if (a.length === 0) { + var rec = req.responseText; + alert_box('erreur :' + rec); + } + var name_ctl = "row_card" + obj.f_id.value; + var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car. + code_html = unescape_xml(code_html); + + if ( document.getElementById(name_ctl)) { + // update the row + $(name_ctl).innerHTML = code_html; + new Effect.Highlight(name_ctl ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); + + } + $(a[0].firstChild.nodeValue).remove(); + + + } catch (e) { + alert_box(e.message); + if (console) { + console.error(e); + console.error("log answer = " + req.responseText); + } + } + try { + code_html.evalScripts(); + } catch (e) { + if (console) { + console.error(e); + console.error("log answer = " + req.responseText); + } + alert_box(content[53] + "\n" + e.message); + } + + + } + } + ); + } catch (e) { + alert_box(e.message); + return false; + } +} \ No newline at end of file diff --git a/html/js/lang/calendar-fr.js b/html/js/lang/calendar-fr.js index 2a9e0b20b..e2ee53d0f 100644 --- a/html/js/lang/calendar-fr.js +++ b/html/js/lang/calendar-fr.js @@ -39,7 +39,7 @@ Calendar._SDN = new Array ("Dim", "Lun", "Mar", - "Mar", + "Mer", "Jeu", "Ven", "Sam", @@ -48,17 +48,17 @@ Calendar._SDN = new Array // full month names Calendar._MN = new Array ("Janvier", - "Février", + "FĂ©vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", - "Août", + "AoĂ»t", "Septembre", "Octobre", "Novembre", - "Décembre"); + "DĂ©cembre"); // short month names Calendar._SMN = new Array @@ -83,7 +83,7 @@ Calendar._TT["ABOUT"] = "DHTML Date/Heure Selecteur\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-) "Pour la derniere version visitez : http://www.dynarch.com/projects/calendar/\n" + -"Distribué par GNU LGPL. Voir http://gnu.org/licenses/lgpl.html pour les details." + +"DistribuĂ© par GNU LGPL. Voir http://gnu.org/licenses/lgpl.html pour les details." + "\n\n" + "Selection de la date :\n" + "- Utiliser les bouttons \xab, \xbb pour selectionner l\'annee\n" + @@ -95,13 +95,13 @@ Calendar._TT["ABOUT_TIME"] = "\n\n" + "- ou Maj-clic pour decrementer\n" + "- ou clic et glisser-deplacer pour une selection plus rapide"; -Calendar._TT["PREV_YEAR"] = "Année préc. (maintenir pour menu)"; -Calendar._TT["PREV_MONTH"] = "Mois préc. (maintenir pour menu)"; +Calendar._TT["PREV_YEAR"] = "AnnĂ©e prĂ©c. (maintenir pour menu)"; +Calendar._TT["PREV_MONTH"] = "Mois prĂ©c. (maintenir pour menu)"; Calendar._TT["GO_TODAY"] = "Atteindre la date du jour"; Calendar._TT["NEXT_MONTH"] = "Mois suiv. (maintenir pour menu)"; -Calendar._TT["NEXT_YEAR"] = "Année suiv. (maintenir pour menu)"; -Calendar._TT["SEL_DATE"] = "Sélectionner une date"; -Calendar._TT["DRAG_TO_MOVE"] = "Déplacer"; +Calendar._TT["NEXT_YEAR"] = "AnnĂ©e suiv. (maintenir pour menu)"; +Calendar._TT["SEL_DATE"] = "SĂ©lectionner une date"; +Calendar._TT["DRAG_TO_MOVE"] = "DĂ©placer"; Calendar._TT["PART_TODAY"] = " (Aujourd'hui)"; // the following is to inform that "%s" is to be the first day of week diff --git a/html/js/scripts.js b/html/js/scripts.js index c30e34995..507048061 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -257,7 +257,8 @@ function set_value(p_ctl, p_value, p_add) function compute_number(value) { var retval = 0; - var exp = new RegExp("^[0-9/*+-.]+$", "g"); + + var exp = new RegExp("^[0-9/*+-.()]+$", "g"); /*pour Ă©viter un eval() mal intentionnĂ©*/ var res = exp.test(value); if (res) @@ -2971,6 +2972,8 @@ function init_scroll() up.innerHTML = ' '; document.body.appendChild(up); window.onscroll = function () { + if ( document.getElementById("select_box_content") ) + { document.getElementById("select_box_content").setStyle({display:"none"})}; if (document.viewport.getScrollOffsets().top > 0) { if ($('go_up').visible() == false) { $('go_up').setOpacity(0.65); @@ -2981,6 +2984,7 @@ function init_scroll() $('go_up').hide(); } } + } /** * Confirm a form thanks a modal dialog Box, it returns true if we agree otherwise @@ -3047,28 +3051,21 @@ function alert_box(p_message) */ function alternate_row_color(p_table) { - var len = $(p_table).tBodies[0].rows.length; + var table_colored=$(p_table); + var len = table_colored.tBodies[0].rows.length; var i = 0; var localClass = ""; for (i = 1; i < len; i++) { localClass = (i % 2 == 0) ? "even" : "odd"; - if (localClass == "even" && $(p_table).tBodies[0].rows[i].hasClassName("odd")) + if ( table_colored.tBodies[0].rows[i].hasClassName("odd")) { - $(p_table).tBodies[0].rows[i].removeClassName("odd"); + table_colored.tBodies[0].rows[i].removeClassName("odd"); } - if (localClass == "even" && !$(p_table).tBodies[0].rows[i].hasClassName("even")) + if (table_colored.tBodies[0].rows[i].hasClassName("even")) { - $(p_table).tBodies[0].rows[i].addClassName("even"); - } - - if (localClass == "odd" && $(p_table).tBodies[0].rows[i].hasClassName("even")) - { - $(p_table).tBodies[0].rows[i].removeClassName("even"); - } - if (localClass == "odd" && !$(p_table).tBodies[0].rows[i].hasClassName("odd")) - { - $(p_table).tBodies[0].rows[i].addClassName("odd"); + table_colored.tBodies[0].rows[i].removeClassName("even"); } + table_colored.tBodies[0].rows[i].addClassName(localClass); } } @@ -3685,4 +3682,4 @@ function toggle_row_warning_enable(p_enable, p_row) } else { $(p_row).hide(); } -} \ No newline at end of file +} diff --git a/html/recherche.php b/html/recherche.php index b2ebdba50..f34549a23 100644 --- a/html/recherche.php +++ b/html/recherche.php @@ -28,6 +28,11 @@ require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; +if ( ! isset ($_SESSION['g_theme'])) +{ + echo "

"._('Vous ĂȘtes dĂ©connectĂ©')."

"; + die(); +} html_page_start($_SESSION['g_theme']); @@ -69,7 +74,7 @@ window.onload=function () { create_anchor_up(); init_scroll(); - sorttable.init + sorttable.init(); } $v) - $r.=HtmlInput::hidden('r_jrn['.$k.']',$v); + $http=new HttpInput(); + $a_rjrn=$http->get("r_jrn","array"); + foreach ($a_rjrn as $k=>$v) { + // Protect : check that $k and $v are numeric + if (isNumber($k)&&isNumber($v)) { + $r.=HtmlInput::hidden('r_jrn['.$k.']',$v); + } + } } echo ''; echo $r; diff --git a/html/style-classic.css b/html/style-classic.css index e830a15b2..0dd8480a1 100644 --- a/html/style-classic.css +++ b/html/style-classic.css @@ -2426,4 +2426,11 @@ span.tab_row { } span.title_tab_row { +} + +/* Selected row in a table */ +.background-selected { + background-color: #000066 !important; + color : white !important; + } \ No newline at end of file diff --git a/html/style-classic7.css b/html/style-classic7.css index 0edfef6ee..5c8882cfd 100644 --- a/html/style-classic7.css +++ b/html/style-classic7.css @@ -1539,6 +1539,7 @@ div.box { float:left; font-size:14px; font-size:0.90rem; + border-radius:5px; } @media only screen and (max-width: 1426px) { div.box { @@ -2465,4 +2466,10 @@ span.title_tab_row { background-color: darkblue; color:white; padding : 3px; -} \ No newline at end of file +} +/* Selected row in a table */ +.background-selected { + background-color: #000066 !important; + color : white !important; + +} diff --git a/html/style-light.css b/html/style-light.css index 95b758593..c2b7c88da 100644 --- a/html/style-light.css +++ b/html/style-light.css @@ -2359,4 +2359,10 @@ span.title_tab_row { color:white; padding : 3px; +} +/* Selected row in a table */ +.background-selected { + background-color: #000066 !important; + color : white !important; + } \ No newline at end of file diff --git a/html/user_login.php b/html/user_login.php index 94e4a9099..0780af731 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -129,7 +129,7 @@ if ( $User->admin == 0 || (defined("MULTI")&& MULTI == 0 ) ) $folder=$User->get_available_folder(); if ( $folder != null && count($folder) == 1 ) { - + echo _("Si la redirection ne fonctionne pas, vous devez changer la valeur de NOALYSS_URL "); redirect(NOALYSS_URL.'/do.php?gDossier='.$folder[0]['dos_id']); exit(); } diff --git a/include/action.common.inc.php b/include/action.common.inc.php index eb6ff979b..59d9041f3 100644 --- a/include/action.common.inc.php +++ b/include/action.common.inc.php @@ -149,7 +149,7 @@ if ($sub_action == "update") $act->get(); $act->fromArray($_POST); $error_id=$e->getCode(); - record_log($e->getTraceAsString()); + record_log($e); } } //---------------------------------------------------------------------- @@ -296,7 +296,7 @@ if ($sub_action == "save_action_st2") echo ''; $sub_action="add_action"; $error_id=$e->getCode(); - record_log($e->getTraceAsString()); + record_log($e); } } //-------------------------------------------------------------------------------- diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 980215825..9b61631ba 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -77,7 +77,7 @@ foreach ($var as $v) $cont=1; } } -extract($_REQUEST, EXTR_SKIP ); +extract($_REQUEST, EXTR_SKIP ); if ( $cont != 0 ) exit(); @@ -118,7 +118,7 @@ case 'rmfa': { $cn->rollback(); record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); echo $e->getMessage(); } $html=ob_get_contents(); @@ -132,6 +132,29 @@ case 'dc': $f=new Fiche($cn); /* add title + close */ $html=HtmlInput::title_box(_("Détail fiche"), $ctl,"close","","y"); + + // if there is no qcode then try to find it thanks the card id + if ( ! isset ($qcode) ){ + $f->id=$http->get("f_id","number"); + $qcode=$f->get_quick_code(); + } + + // after save , we can either show a card in readonly or update a row + $safter_save=$http->request("after_save","string","1"); + switch ($safter_save) + { + case "1": + // show a card it readonly and fade it + $after_save="update_card(this)"; + break; + case "2": + // update a row in the table X + $after_save="card_update_row(this)"; + break; + default: + break; + } + if ( $qcode != '') { $f->get_by_qcode($qcode); @@ -153,7 +176,7 @@ case 'dc': if ($can_modify==1) { - $html.=''; + $html.=''; $html.=dossier::hidden(); $html.=HtmlInput::hidden('f_id',$f->id); $html.=HtmlInput::hidden('ctl',$ctl); @@ -207,6 +230,9 @@ case 'bc': if ( isset ($eltid)) { $r.=HtmlInput::hidden("eltid", $eltid); } + // Action after save = 0, the card is display one second and fade out + $after_save=$http->get("after_save","number",0); + $r.=HtmlInput::hidden("after_save",$after_save); $r.='
'; $html=$r; } @@ -336,7 +362,7 @@ return; * ----------------------------------------------------------------------*/ case 'sc': - $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl); + if ( $g_user->check_action(FICADD)==1 ) { $f=new Fiche($cn); @@ -344,19 +370,46 @@ case 'sc': try { $f->insert($fd_id,$_POST); $f->Get(); - $html.='

'._('Fiche sauvée').'

'; - $html.=$f->Display(true); - $js=""; - if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); - $html.=$js; - if ( isset ($eltid)) { - // after adding a new card, we update some field - $extra="$eltid". - "{$f->get_quick_code ()}"; + $after_save=$http->post("after_save","number",0); + // Action after save = 0, the card is display one second and fade out + // + if ( $after_save == 0 ) { + $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl); + $html.='

'._('Fiche sauvée').'

'; + $html.=$f->Display(true); + $js=""; + if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); + $html.=$js; + if ( isset ($eltid)) { + // after adding a new card, we update some field + $extra="$eltid". + "{$f->get_quick_code ()}"; + + + } + $extra.=$status; + $extra.="0"; + + } + // Action after save = 1 ; after adding a card the table must be updated + // see fiche.inc.php + // + if ( $after_save == 1 ){ + $f_id=$f->id; + ob_start(); + $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)). + " ". + Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id)); + $html = td($detail); + $html .= $f->display_row(); + $html.=ob_get_contents(); + ob_clean(); + $extra="".$f_id.""; + $ctl="row_card".$f_id; + $extra.="1"; + } - $extra.=$status; - $html.=HtmlInput::button_close($ctl); } catch (Exception $exc) { $html="

"._("Erreur sauvegarde")."

"; $html.=$exc->getMessage(); @@ -592,6 +645,9 @@ case 'scc': $ctl="info_div"; } break; + +// Update a card and then display the result +// in a readonly box case 'upc': $html=HtmlInput::title_box("DĂ©tail fiche", $ctl); @@ -619,17 +675,52 @@ case 'upc': } } break; - //------------------------------------------------------------------ - // Unlink a card - //------------------------------------------------------------------ - case 'rm_card': - $html=HtmlInput::title_box("DĂ©tail fiche", $ctl); +// Update a card and then display the result +// in the table +case 'upr': + $f_id=$http->get("f_id","number"); + $html=""; + if ( $g_user->check_action(FICADD)==0 ) + { + $html.=alert(_('Action interdite'),true); + } + else + { + if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' ) + { + $html.=alert(_('Fiche non valide'),true); + } - if ( $g_user->check_action(FIC)==0 ) + else + { + + $f=new Fiche($cn,$f_id ); + ob_start(); + $f->update($_GET); + $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)). + " ". + Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id)); + $html.=td($detail); + $html.=$f->display_row(); + $html.=ob_get_contents(); + ob_end_clean(); + } + } + break; + + + +//------------------------------------------------------------------ +// Unlink a card +//------------------------------------------------------------------ + case 'rm_card': + $html=HtmlInput::title_box("DĂ©tail fiche", $ctl); + + if ( $g_user->check_action(FIC)==0 ) { $html.=alert(_('Action interdite'),true); } - else + else { if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' ) { diff --git a/include/ajax/ajax_display_letter.php b/include/ajax/ajax_display_letter.php index 7e8f8007c..06f36e189 100644 --- a/include/ajax/ajax_display_letter.php +++ b/include/ajax/ajax_display_letter.php @@ -38,7 +38,7 @@ try { }catch (Exception $e ) { record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); return; } diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php index 8b90b6e98..316a5a662 100644 --- a/include/ajax/ajax_ledger.php +++ b/include/ajax/ajax_ledger.php @@ -161,7 +161,7 @@ case 'rmop': } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $e->getMessage(); $cn->rollback(); } @@ -207,7 +207,7 @@ case 'de': } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo Icon_Action::close($div); echo '

'._("Désolé il y a une erreur").'

'; } @@ -512,7 +512,7 @@ case 'save': } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); if ( DEBUG ) echo $e->getMessage(); alert(_( "Changement impossible: on ne peut pas changer la date dans une période fermée")); } @@ -570,13 +570,29 @@ case 'reverseop': } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo $e->getMessage(); $cn->rollback(); } } $html=ob_get_contents(); ob_end_clean(); + break; + +case 'duplicateop': + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Duplicate operation + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + $operation=new Acc_Operation($cn); + $operation->jr_id=$jr_id; + ob_start(); + echo HtmlInput::title_box(_("Dupliquer une opération"), $div); + echo $operation->form_clone_operation("cloneit"); + + $html=ob_get_contents(); + ob_end_clean(); + + break; } $html=escape_xml($html); diff --git a/include/ajax/ajax_periode.php b/include/ajax/ajax_periode.php index 367546ef2..e8e2cb133 100644 --- a/include/ajax/ajax_periode.php +++ b/include/ajax/ajax_periode.php @@ -205,7 +205,7 @@ switch ($act) } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $html=$e->getTrace(); throw $e; } diff --git a/include/ajax/ajax_tva_parameter.php b/include/ajax/ajax_tva_parameter.php index cf2107aa0..8be4577bb 100644 --- a/include/ajax/ajax_tva_parameter.php +++ b/include/ajax/ajax_tva_parameter.php @@ -42,7 +42,7 @@ try } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); return; } diff --git a/include/anc_key.inc.php b/include/anc_key.inc.php index a2b343f43..7298ca5a5 100644 --- a/include/anc_key.inc.php +++ b/include/anc_key.inc.php @@ -56,7 +56,7 @@ switch ($op) } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo span($e->getMessage(), ' class="notice"'); Anc_Key::display_list(); Anc_Key::key_add(); diff --git a/include/anc_pa.inc.php b/include/anc_pa.inc.php index f3fc67433..f16170804 100644 --- a/include/anc_pa.inc.php +++ b/include/anc_pa.inc.php @@ -145,8 +145,8 @@ if ($sa=="pa_detail") $accounting->add_json_param("pa_id", $pa_id); $accounting->set_sort_column("po_name"); ob_start(); - $accounting->display_table(" where pa_id = $1 order by po_name ",array($pa_id)); $accounting->create_js_script(); + $accounting->display_table(" where pa_id = $1 order by po_name ",array($pa_id)); $ret.=ob_get_clean(); $ret.= ''; } diff --git a/include/card_attr.inc.php b/include/card_attr.inc.php index 88e3d9a9b..fa8bcae8d 100644 --- a/include/card_attr.inc.php +++ b/include/card_attr.inc.php @@ -56,7 +56,7 @@ if ( isset($_POST['save'])) } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); alert($e->getMessage()); $cn->rollback(); } diff --git a/include/cfgledger.inc.php b/include/cfgledger.inc.php index 679827d06..7984d48b9 100644 --- a/include/cfgledger.inc.php +++ b/include/cfgledger.inc.php @@ -62,7 +62,7 @@ if ( $action_frm == 'update') } catch (Exception $e) { record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); alert($e->getMessage()); } } @@ -88,7 +88,7 @@ if ($action_frm == 'delete' ) catch (Exception $e) { record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); alert ($e->getMessage()); } @@ -111,7 +111,7 @@ if (isset($_POST['add'])) catch (Exception $e) { record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); alert($e->getMessage()); } } @@ -146,7 +146,7 @@ switch ($sa) catch (Exception $e) { record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); alert($e->getMessage()); } break; diff --git a/include/class/acc_bilan.class.php b/include/class/acc_bilan.class.php index 398a3eb81..51b8b5fba 100644 --- a/include/class/acc_bilan.class.php +++ b/include/class/acc_bilan.class.php @@ -284,7 +284,7 @@ class Acc_Bilan } catch(Exception $Ex) { - record_log($e->getTraceAsString()); + record_log($e); echo $Ex->getMessage(); throw $Ex; } diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index b6a068262..ab4ce5c30 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -389,7 +389,7 @@ class Acc_Ledger extends jrn_def_sql } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $this->db->rollback(); throw $e; } @@ -869,7 +869,7 @@ class Acc_Ledger extends jrn_def_sql } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); if ($e->getCode()==1) { echo _("Aucune période ouverte"); @@ -1503,7 +1503,7 @@ class Acc_Ledger extends jrn_def_sql } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $this->db->rollback(); echo _('OPERATION ANNULEE '); echo '
'; @@ -2307,7 +2307,7 @@ class Acc_Ledger extends jrn_def_sql catch (Exception $e) { $cn->rollback(); - record_log($e->getTraceAsString()); + record_log($e); } $cn->commit(); } @@ -2576,7 +2576,7 @@ class Acc_Ledger extends jrn_def_sql } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); throw $e; } } @@ -2608,22 +2608,17 @@ class Acc_Ledger extends jrn_def_sql switch ($this->jrn_def_type) { case 'ACH': - $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join($ACH_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join($ACH_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join(',',$ACH_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join(',',$ACH_FICHEDEB):""; break; case 'VEN': - $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join($VEN_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join($VEN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join(',',$VEN_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join(',',$VEN_FICHEDEB):""; break; case 'ODS': $this->jrn_def_class_deb=$p_jrn_class_deb; - $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join($ODS_FICHEDEB, - ','):''; ; + $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join(',',$ODS_FICHEDEB):''; ; $this->jrn_def_fiche_cred=null; break; @@ -2632,8 +2627,7 @@ class Acc_Ledger extends jrn_def_sql $result=$a->get_by_qcode(trim(strtoupper($_POST['bank'])), false); $bank=$a->id; $this->jrn_def_bank=$bank; - $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join($FIN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join(',',$FIN_FICHEDEB):""; if ($result==-1) throw new Exception(_("Aucun compte en banque n'est donné")); $this->jrn_def_num_op=(isset($numb_operation))?1:0; @@ -2812,22 +2806,17 @@ class Acc_Ledger extends jrn_def_sql switch ($this->jrn_def_type) { case 'ACH': - $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join($ACH_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join($ACH_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join(',',$ACH_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join(',',$ACH_FICHEDEB):""; break; case 'VEN': - $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join($VEN_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join($VEN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join(',',$VEN_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join(',',$VEN_FICHEDEB):""; break; case 'ODS': $this->jrn_def_class_deb=$p_jrn_class_deb; - $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join($ODS_FICHEDEB, - ','):''; ; + $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join(',',$ODS_FICHEDEB):''; ; $this->jrn_def_fiche_cred=null; break; case 'FIN': @@ -2835,8 +2824,7 @@ class Acc_Ledger extends jrn_def_sql $result=$a->get_by_qcode(trim(strtoupper($_POST['bank'])), false); $bank=$a->id; $this->jrn_def_bank=$bank; - $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join($FIN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join(',',$FIN_FICHEDEB):""; if ($result==-1) throw new Exception(_("Aucun compte en banque n'est donné")); $this->jrn_def_num_op=(isset($numb_operation))?1:0; @@ -2862,7 +2850,7 @@ class Acc_Ledger extends jrn_def_sql } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); throw $e; } } diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index 65a5766e9..654c462b7 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -1076,7 +1076,7 @@ class Acc_Ledger_Fin extends Acc_Ledger __FILE__ . ':' . __LINE__ . ' ' . $e->getMessage(); $this->db->rollback(); - record_log($e->getTraceAsString()); + record_log($e); throw new Exception($r); } $this->db->commit(); diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 87bbd498f..f257cb3c2 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -417,7 +417,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History function get_rowSimple($trunc=0, $p_limit=-1, $p_offset=-1) { global $g_user; - $jrn=" jrn_def_id in (".join($this->ma_ledger, ",").")"; + $jrn=" jrn_def_id in (".join(',',$this->ma_ledger).")"; $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', 'jr_tech_per'); diff --git a/include/class/acc_ledger_info.class.php b/include/class/acc_ledger_info.class.php index 44efb7fb2..be9e9ea1d 100644 --- a/include/class/acc_ledger_info.class.php +++ b/include/class/acc_ledger_info.class.php @@ -63,7 +63,7 @@ class Acc_Ledger_Info } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo "Echec sauvegarde info additionnelles"; throw $e; } @@ -86,7 +86,7 @@ class Acc_Ledger_Info } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $this->cn->rollback(); echo "Echec sauvegarde info additionnelles"; throw $e; diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 44a5ea0e2..24ba1b1e7 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -49,10 +49,12 @@ require_once NOALYSS_INCLUDE.'/class/stock_goods.class.php'; */ class Acc_Ledger_Purchase extends Acc_Ledger { + private $payment_operation; /*ledger_type='ACH'; parent::__construct($p_cn,$p_init); + $this->payment_operation=-1; } /*!\brief verify that the data are correct before inserting or confirming *\param an array (usually $_POST) @@ -960,7 +962,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $acc_pay->grpt=$acseq; $acc_pay->jrn=$mp->get_parameter('ledger_target'); $acc_pay->periode=$tperiode; - $acc_pay->type=($famount>=0)?'c':'d'; + $acc_pay->type=($famount>=0)?'c':'d'; $acc_pay->insert_jrnx(); /* Insert supplier */ @@ -996,6 +998,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger // insert into the table JRN $mp_jr_id=$acc_pay->insert_jrn(); + $this->payment_operation=$mp_jr_id; $acjrn->grpt_id=$acseq; $acjrn->update_internal_code($acinternal); // add an automatic PJ if ODS @@ -1038,7 +1041,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger }//end try catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo ''. 'Erreur dans l\'enregistrement '. __FILE__.':'.__LINE__.' '. @@ -1146,7 +1149,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); if ($e->getCode() == 1 ) { throw new Exception( _("Aucune période ouverte")); @@ -1855,19 +1858,30 @@ EOF; */ if ( $e_mp!=0 && strlen (trim (${'e_mp_qcode_'.$e_mp})) != 0 ) { + $r.="

"; $r.=HtmlInput::hidden('e_mp_qcode_'.$e_mp,${'e_mp_qcode_'.$e_mp}); $r.=HtmlInput::hidden('acompte',$acompte); - $r.=HtmlInput::hidden('e_comm_paiement',$e_comm_paiement); - $r.=HtmlInput::hidden('mp_date',$mp_date); + $r.=HtmlInput::hidden('e_comm_paiement',$e_comm_paiement); + $r.=HtmlInput::hidden('mp_date',$mp_date); /* needed for generating a invoice */ $r.=HtmlInput::hidden('qcode_benef', ${'e_mp_qcode_' . $e_mp}); $fname = new Fiche($this->db); $fname->get_by_qcode(${'e_mp_qcode_' . $e_mp}); + $detail_payment=""; + // payment operation + if ($this->payment_operation != 1) { + $pay_internal=$this->db->get_value("select jr_internal from jrn where jr_id=$1", + [$this->payment_operation]); + $detail_payment=HtmlInput::detail_op($this->payment_operation,$pay_internal); + } $r.='

' . _("Payé par")." " . ${'e_mp_qcode_' . $e_mp} . - " " . $fname->getName() . '

' . '

' . _('Déduction acompte ') . h($acompte) . '

' . + " " . $fname->getName() .$detail_payment. ' ' ; + $r.='

' . _('Déduction acompte ') . h($acompte) . '

' . _('Libellé :') . h($e_comm_paiement) ; $r.='
'; $r.='
'; + + $r.="

"; } // check for upload piece /* diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index 8bb00437d..2372a0fa3 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -716,8 +716,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { } } } catch (Exception $e) { - record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); echo '' . 'Erreur dans l\'enregistrement ' . __FILE__ . ':' . __LINE__ . ' ' . diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index 453763e3f..999ae98cf 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -609,8 +609,8 @@ class Acc_Operation $ret=new Acc_Fin($this->db,$this->jr_id); break; default: - $ret=new Acc_Misc($this->db,$this->jr_id); - break; + $ret=new Acc_Misc($this->db,$this->jr_id); + break; } $ret->get(); if ( empty($ret->det->array)) @@ -747,6 +747,71 @@ class Acc_Operation $type_operation->selected=$p_status; return $type_operation; } + /** + * create a form to recreate the operation and returns it, just like a correct + * + */ + function form_clone_operation($p_id) { + // retrieve all info about operation + $operation = $this->get_quant(); + $array=$operation->compute_array(); + global $g_user; + // Prepare the form + $r='
'; + $r.=Dossier::hidden(); + $a_code=$this->db->get_array("select code from v_menu_dependency vmd where me_code=$1 and p_id=$2", + array( $operation->signature,$g_user->get_profile())); + + // select the menu where the operation will be duplicated + if ( empty ($a_code)) { + $r.=_("Menu invalide"); + return $r; + } + $r.="

"; + $r.="

    "; + $r.=sprintf("
  • %s
  • ",$operation->det->jr_pj_number); + $r.=sprintf("
  • %s
  • ",$operation->det->jr_comment); + $r.=sprintf("
  • %s
  • ",$operation->det->jr_montant); + $r.="
"; + $r.="

"; + if (count($a_code) == 1 ) { + $r.=HtmlInput::hidden("ac",$a_code[0]['code']); + $r.=sprintf(_("Voulez-vous aller à %s pour dupliquer cette opération ?"),$a_code[0]['code']); + + } else { + $select=new ISelect("ac"); + $select->value=array(); + $nb_code=count($a_code); + + for ($i=0;$i<$nb_code;$i++) { + $select->value[]=array("label"=>$a_code[$i]['code'],"value"=>$a_code[$i]['code']); + } + $r.=sprintf(_("Voulez-vous aller à %s pour dupliquer cette opération ?"),$select->input()); + + } + + $r.="

"; + + // For Misc Operation , if a card is given then there is no accounting + if ( $operation->signature==="ODS") { + $nb_array=count($array); + for ($i=0;$i<$nb_array;$i++) { + if (isset ($array["qc_".$i] ) && $array["qc_".$i] != "" ) { + $array["poste".$i]=""; + } + } + } + + // transform the operation into hidden element + $r.=HtmlInput::simple_array_to_hidden($array); + + $r.=HtmlInput::submit(uniqid(), _("Dupliquer")); + $r.='
'; + + + // return the form as a string + return $r; + } } ///////////////////////////////////////////////////////////////////////////// @@ -779,6 +844,19 @@ class Acc_Detail extends Acc_Operation $this->det->note=$this->db->get_value($sql,array($this->jr_id)); $this->det->note=strip_tags($this->det->note); } + /** + * + */ + function compute_array() + { + $array=array(); + $array['desc']=$this->det->jr_comment; + $array['e_date']=""; + $array['e_ech']=""; + $array['p_jrn']=$this->det->jr_def_id; + return $array; + + } } ///////////////////////////////////////////////////////////////////////////// /** @@ -805,6 +883,30 @@ class Acc_Misc extends Acc_Detail FROM jrnx where j_grpt = $1 order by j_debit desc,j_poste"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + for ($i=0;$i<$nb_array;$i++) { + $array["qc_".$i]=$this->det->array[$i]['j_qcode']; + $array["poste".$i]=$this->det->array[$i]['j_poste']; + $array["amount".$i]=$this->det->array[$i]['j_montant']; + if ( $this->det->array[$i]['j_debit'] == 't') { + $array["ck".$i]=1; + } + $array["ld".$i]=$this->det->array[$i]['j_text']; + } + + return $array; + + } } ///////////////////////////////////////////////////////////////////////////// /** @@ -828,6 +930,35 @@ class Acc_Sold extends Acc_Detail FROM quant_sold join jrnx using(j_id) where j_grpt=$1"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + + $array["e_client"]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[0]['qs_client'])); + + for ($i=0;$i<$nb_array;$i++) { + $array["e_march".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[$i]['qs_fiche'])); + + $array["e_march".$i."_price"]=$this->det->array[$i]['qs_unit']; + $array["e_march".$i."_label"]=$this->det->array[$i]['j_text']; + $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qs_vat_code']; + $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qs_vat']; + $array["e_quant".$i]=$this->det->array[$i]['qs_quantite']; + } + $array['correct']=1; + return $array; + + } } ///////////////////////////////////////////////////////////////////////////// @@ -854,6 +985,37 @@ class Acc_Purchase extends Acc_Detail FROM quant_purchase join jrnx using(j_id) where j_grpt=$1"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + + $array["e_client"]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[0]['qp_supplier'])); + + for ($i=0;$i<$nb_array;$i++) { + $array["e_march".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[$i]['qp_fiche'])); + + $array["e_march".$i."_price"]=$this->det->array[$i]['qp_unit']; + $array["e_march".$i."_label"]=$this->det->array[$i]['j_text']; + $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qp_vat_code']; + $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qp_vat']; + $array["e_quant".$i]=$this->det->array[$i]['qp_quantite']; + } + $array['correct']=1; + return $array; + + } + + } ///////////////////////////////////////////////////////////////////////////// /** @@ -876,4 +1038,27 @@ class Acc_Fin extends Acc_Detail FROM quant_fin where jr_id = $1"; $this->det->array=$this->db->get_array($sql,array($this->jr_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + + for ($i=0;$i<$nb_array;$i++) { + $array["e_other".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[$i]['qf_other'])); + + $array["e_other".$i."_amount"]=$this->det->array[$i]['qf_amount']; + $array["e_other".$i."_comment"]=$this->det->jr_comment; + } + $array['correct']=1; + return $array; + + } } diff --git a/include/class/acc_report.class.php b/include/class/acc_report.class.php index 0c15e17ce..952c40a37 100644 --- a/include/class/acc_report.class.php +++ b/include/class/acc_report.class.php @@ -216,7 +216,7 @@ class Acc_Report } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $this->db->rollback(); echo $e->getMessage(); } @@ -258,7 +258,7 @@ class Acc_Report } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $this->db->rollback(); echo $e->getMessage(); } diff --git a/include/class/anc_account_table.class.php b/include/class/anc_account_table.class.php index d92b0f909..08ad0c393 100644 --- a/include/class/anc_account_table.class.php +++ b/include/class/anc_account_table.class.php @@ -74,7 +74,7 @@ class Anc_Account_Table extends Manage_Table_SQL $table->po_name=str_replace(">", '', $table->po_name); // po_name must be uniq in the Analytic Plan - if ( $cn->get_value("select count(*) from poste_analytique where pa_id=$1 and po_name=$2 and po_id != $3", + if ( $cn->get_value("select count(*) from poste_analytique where pa_id=$1 and po_name=upper($2) and po_id != $3", array($table->pa_id,$table->po_name,$table->po_id)) > 0) { $is_error++; @@ -90,4 +90,36 @@ class Anc_Account_Table extends Manage_Table_SQL if ($is_error==0)return TRUE; return FALSE; } + + /** + * @brief display a data row in the table, with the order defined + * in a_order and depending of the visibility of the column + */ + function display_row($p_row) + { + $cn=Dossier::connect(); + $count=$cn->get_value("select count(*) from public.operation_analytique where po_id=$1",[$p_row["po_id"]]); + $p_row["po_name"]=sprintf("%s (%d)",$p_row['po_name'],$count); + parent::display_row($p_row); + } + + /** + * Before deleting , we check that nothing is in a closed periode + */ + function delete() { + $cn=Dossier::connect(); + $count_closed=$cn->get_value(" select count(*) + from jrnx as jx1 + join jrn jn1 on (jx1.j_grpt = jn1.jr_grpt_id ) + join jrn_def as jf1 on (jn1.jr_def_id =jf1.jrn_def_id ) + join jrn_periode as je1 on (jf1.jrn_def_id =je1.jrn_def_id ) + join operation_analytique as oa on (oa.j_id =jx1.j_id ) + where + je1.status = 'CL' and oa.po_id=$1 ",[$this->table->po_id]); + if ( $count_closed > 0 ) { + throw new \Exception(_("Effacement impossible : le poste est utilisĂ© dans une pĂ©riode fermĂ©e")); + } + + } + } diff --git a/include/class/anc_group_operation.class.php b/include/class/anc_group_operation.class.php index c5e45061d..b0058ef71 100644 --- a/include/class/anc_group_operation.class.php +++ b/include/class/anc_group_operation.class.php @@ -74,7 +74,7 @@ class Anc_Group_Operation } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo $e->getTrace(); $this->db->rollback(); throw new Exception($e); @@ -260,7 +260,7 @@ class Anc_Group_Operation } catch (Exception $ex) { - record_log($e->getTraceAsString()); + record_log($e); echo ''. 'Erreur dans l\'enregistrement '. __FILE__.':'.__LINE__.' '. diff --git a/include/class/anc_key.class.php b/include/class/anc_key.class.php index ed06eb074..4fec773ed 100644 --- a/include/class/anc_key.class.php +++ b/include/class/anc_key.class.php @@ -268,7 +268,7 @@ class Anc_Key { if ( DEBUG ) { echo $e->getTraceAsString(); } else { echo _('erreur').$e->getMessage();} - record_log($e->getTraceAsString()); + record_log($e); $cn->rollback(); } } diff --git a/include/class/anc_operation.class.php b/include/class/anc_operation.class.php index 24c0562ce..fcba66ab2 100644 --- a/include/class/anc_operation.class.php +++ b/include/class/anc_operation.class.php @@ -505,7 +505,7 @@ class Anc_Operation } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); } } /*!\brief display the form for PA diff --git a/include/class/database.class.php b/include/class/database.class.php index 101cc5e61..30da3f448 100644 --- a/include/class/database.class.php +++ b/include/class/database.class.php @@ -89,7 +89,7 @@ class Database extends DatabaseCore $r = pg_fetch_array($ret, 0); $old_oid = $r['jr_pj']; if (strlen($old_oid) != 0) - pg_lo_unlink($cn, $old_oid); + $this->lo_unlink( $old_oid); } // Load new document $this->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2, @@ -115,7 +115,7 @@ class Database extends DatabaseCore /** * \brief loop to apply all the path to a folder or a template * Upgrade check if the folder $p_name needs to be upgrade thanks the variable DBVERSION - * and run all the SQL script named upgradeX.sql from the folder noalyss/include/sql/patch + * and run all the SQL script named upgradeX.sql from the folder noalyss/include/sql/patch * until X equal DBVERSION-1 * * \param $p_name database name @@ -226,7 +226,7 @@ class Database extends DatabaseCore if (!DEBUG) ob_end_clean(); - + } } echo ''; @@ -253,4 +253,4 @@ class Database extends DatabaseCore } return $sys_name; } -} \ No newline at end of file +} diff --git a/include/class/default_menu.class.php b/include/class/default_menu.class.php index acb85207f..80a9de07d 100644 --- a/include/class/default_menu.class.php +++ b/include/class/default_menu.class.php @@ -106,7 +106,7 @@ class Default_Menu } } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo $e->getMessage(); throw $e; } diff --git a/include/class/document_modele.class.php b/include/class/document_modele.class.php index 7c29a8333..a1722a9d2 100644 --- a/include/class/document_modele.class.php +++ b/include/class/document_modele.class.php @@ -194,7 +194,7 @@ class Document_modele } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); rollback($this->cn); return ; } @@ -360,7 +360,7 @@ class Document_modele } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); rollback($this->cn); return ; } diff --git a/include/class/document_type.class.php b/include/class/document_type.class.php index 92ffc823b..8f0d2fbf1 100644 --- a/include/class/document_type.class.php +++ b/include/class/document_type.class.php @@ -103,7 +103,7 @@ class Document_type } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); alert(j(_("Impossible d'ajouter [$p_value] ") . $e->getMessage())); } } @@ -120,7 +120,7 @@ class Document_type } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); alert(" Erreur " . $e->getMessage()); } } @@ -133,7 +133,7 @@ class Document_type } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); alert("Erreur " . $e->getMessage()); } } diff --git a/include/class/dossier.class.php b/include/class/dossier.class.php index ecd439e1a..1f62b042b 100644 --- a/include/class/dossier.class.php +++ b/include/class/dossier.class.php @@ -326,7 +326,7 @@ class Dossier { echo_warning($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); $cn->rollback(); } } diff --git a/include/class/extension.class.php b/include/class/extension.class.php index 64e4d33e5..5fad200ec 100644 --- a/include/class/extension.class.php +++ b/include/class/extension.class.php @@ -353,7 +353,7 @@ class Extension extends Menu_Ref_sql $extension->me_type='PL'; $extension->me_menu=trim($xml->plugin[$i]->name); $extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code); - $extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):""; + $extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):"EXT"; $extension->order=(isset($xml->plugin[$i]->order))?trim($xml->plugin[$i]->order):9000; $a_extension[]=clone $extension; } diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index 635c25f64..734226e63 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -937,7 +937,7 @@ class Fiche } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e->getMessage()." ".$e->getTraceAsString()); $this->cn->rollback(); throw ($e); return; @@ -1133,7 +1133,7 @@ class Fiche $e->getMessage(). ''; record_log($e->getMessage()); - record_log($e->getTraceAsString()); + record_log($e); $this->cn->rollback(); return; } @@ -2342,6 +2342,45 @@ class Fiche throw $e; } } + /** + * @brief display card as a table row , the tag TR must be added + * + * @return HTMLT string starting + * + */ + function display_row() + { + $this->getAttribut(); + foreach($this->attribut as $attr) { + $sort=""; + + if ($attr->ad_type!='select') + { + + if ($attr->ad_type=="date") { + // format YYYYMMDD + $sort='sorttable_customkey="'.format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD").'"'; + } + elseif ($attr->ad_type=="poste"){ + $sort='sorttable_customkey="TEXT'.$attr->av_text.'"'; + } + echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort); + } + else { + $value=$this->cn->make_array($attr->ad_extra); + $row_content=""; + for ($e=0; $eav_text) { + $row_content=h($value[$e]['label']); + break; + } + } + echo td($row_content, 'style="padding: 0 10 1 10;white-space:nowrap;"'); + + } + } + + } } ?> diff --git a/include/class/fiche_attr.class.php b/include/class/fiche_attr.class.php index 98cea2e90..c764731e5 100644 --- a/include/class/fiche_attr.class.php +++ b/include/class/fiche_attr.class.php @@ -99,7 +99,7 @@ class Fiche_Attr $this->cn->exec_sql($this->ad_extra); }catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); throw new Exception ("La requĂȘte SQL ".h($this->ad_extra)." est invalide "); } } @@ -161,7 +161,7 @@ class Fiche_Attr ); } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); throw $e; } @@ -185,7 +185,7 @@ class Fiche_Attr ); }catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); throw $e; } diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 3f9327142..29164ce8d 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -104,6 +104,7 @@ class Follow_Up $this->aAction_detail=array(); $this->operation=""; $this->action=""; + $this->f_dest_id=0; } /** * Create a filter based on the current user, diff --git a/include/class/pdf_operation.class.php b/include/class/pdf_operation.class.php index 867b24392..3403d0195 100644 --- a/include/class/pdf_operation.class.php +++ b/include/class/pdf_operation.class.php @@ -457,7 +457,7 @@ class PDF_Operation extends PDF { return $file_name; } function download_pdf() { - $this->pdf->Output("acc_op".$this->acc_detail->det->jr_internal.".pdf"); + $this->pdf->Output("acc_op".$this->acc_detail->det->jr_internal.".pdf","D"); } /** * @brief unlink the file if exists diff --git a/include/class/periode.class.php b/include/class/periode.class.php index 16ca96d80..43cde5797 100644 --- a/include/class/periode.class.php +++ b/include/class/periode.class.php @@ -273,7 +273,7 @@ class Periode catch (Exception $e) { record_log($e->getMessage()." - ".$e->getCode()); - record_log($e->getTraceAsString()); + record_log($e); $this->cn->rollback(); throw $e; } @@ -495,7 +495,7 @@ class Periode } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); $this->cn->rollback(); throw $e; } diff --git a/include/class/pre_op_ach.class.php b/include/class/pre_op_ach.class.php index fb9640e77..722c9deed 100644 --- a/include/class/pre_op_ach.class.php +++ b/include/class/pre_op_ach.class.php @@ -104,7 +104,7 @@ class Pre_op_ach extends Pre_operation_detail } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo ($e->getMessage()); $this->db->rollback(); } diff --git a/include/class/pre_op_advanced.class.php b/include/class/pre_op_advanced.class.php index 2c110fe45..3d78bc9e7 100644 --- a/include/class/pre_op_advanced.class.php +++ b/include/class/pre_op_advanced.class.php @@ -98,7 +98,7 @@ class Pre_Op_Advanced extends Pre_operation_detail } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo ($e->getMessage()); $this->db->rollback(); } diff --git a/include/class/pre_op_fin.class.php b/include/class/pre_op_fin.class.php index f293eb253..ea16b0dbf 100644 --- a/include/class/pre_op_fin.class.php +++ b/include/class/pre_op_fin.class.php @@ -86,7 +86,7 @@ class Pre_op_fin extends Pre_operation_detail } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo ($e->getMessage()); $this->db->rollback(); } diff --git a/include/class/pre_op_ods.class.php b/include/class/pre_op_ods.class.php index d886768aa..1130e6208 100644 --- a/include/class/pre_op_ods.class.php +++ b/include/class/pre_op_ods.class.php @@ -78,7 +78,7 @@ class Pre_op_ods extends Pre_operation_detail } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo ($e->getMessage()); $this->db->rollback(); } diff --git a/include/class/pre_op_ven.class.php b/include/class/pre_op_ven.class.php index c76252c1b..3d97c0687 100644 --- a/include/class/pre_op_ven.class.php +++ b/include/class/pre_op_ven.class.php @@ -102,7 +102,7 @@ class Pre_op_ven extends Pre_operation_detail } catch (Exception $e) { - record_log($e->getTraceAsString()); + record_log($e); echo ($e->getMessage()); $this->db->rollback(); } diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php index 403f513ab..460d7e857 100644 --- a/include/class/tva_rate_mtable.class.php +++ b/include/class/tva_rate_mtable.class.php @@ -53,8 +53,8 @@ class Tva_Rate_MTable extends Manage_Table_SQL $this->set_col_label("tva_purchase", _("TVA Achat (D)")); $this->set_col_type("tva_both_side", "select", array( - ["value"=>0, "label"=>_("Normal")], - ["value"=>1, "label"=>_("Autoliquidation")] + ["value"=>0, "label"=>_("Non")], + ["value"=>1, "label"=>_("Oui")] )); $this->set_property_updatable("tva_id", FALSE); $this->set_col_label("tva_payment_purchase",_("Exigible achat")); diff --git a/include/config.inc.example b/include/config.inc.example index d3024056c..65650be22 100644 --- a/include/config.inc.example +++ b/include/config.inc.example @@ -13,6 +13,8 @@ define ("noalyss_psql_host","localhost"); // If you change the NOALYSS_ADMINISTRATOR , you will need to rerun http://..../noalyss/html/install.php // But it doesn't change the password define ("NOALYSS_ADMINISTRATOR","admin"); +// used only for install +define ("NOALYSS_ADMIN_PASSWORD",""); define ("LOCALE",1); define ("domaine",""); define ("MULTI",1); diff --git a/include/constant.php b/include/constant.php index 640e9f78f..be6f479ed 100644 --- a/include/constant.php +++ b/include/constant.php @@ -107,7 +107,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",143); +define ("DBVERSION",144); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); @@ -325,7 +325,7 @@ if ( ! defined ("NOALYSS_URL")) { $protocol=$_SERVER['REQUEST_SCHEME']; } $base=$protocol.'://'. - $_SERVER['HTTP_HOST']. + $_SERVER['SERVER_NAME']. ":".$_SERVER['SERVER_PORT']. dirname($_SERVER['PHP_SELF']); define ("NOALYSS_URL",$base); diff --git a/include/export/export_operation_pdf.php b/include/export/export_operation_pdf.php new file mode 100644 index 000000000..0e6b90bc1 --- /dev/null +++ b/include/export/export_operation_pdf.php @@ -0,0 +1,35 @@ + + +if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); + +require_once NOALYSS_INCLUDE."/class/pdf_operation.class.php"; +$http=new HttpInput(); +/** + * @file + * @brief export an operation in PDF + */ +$operation=$http->get("operation_id","number"); + +$op=new PDF_Operation($cn, $operation); + +$op->export_pdf(["acc","anc"]); +$op->download_pdf(); \ No newline at end of file diff --git a/include/fiche.inc.php b/include/fiche.inc.php index 43bed6ead..de2ef70d9 100644 --- a/include/fiche.inc.php +++ b/include/fiche.inc.php @@ -37,7 +37,7 @@ global $g_user, $g_failed; */ /* category */ $categorie = new ISelect('cat'); -$categorie->value = $cn->make_array("select fd_id,fd_label||'('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id)::text||')' from fiche_def order by fd_label"); +$categorie->value = $cn->make_array("select fd_id,fd_label||' ('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id)::text||')' from fiche_def order by fd_label"); $categorie->selected = $http->get('cat','number',0); $str_categorie = $categorie->input(); $ac = $http->request('ac'); @@ -128,7 +128,8 @@ if ( $allcard == 0 ){ echo h1($fiche_def->label,""); echo h2($fiche_def->fd_description,""); } -if ($array == null && $allcard == 0) +// if no card found , stop here +if ($array == null && $allcard == 0 && $histo->selected != 3 ) { echo '
'; echo '

'._('Aucune fiche trouvée').'

'; @@ -138,10 +139,10 @@ if ($array == null && $allcard == 0) } echo '
'; -/* * ********************************************************************************************************************************* +/* * ************************************************************************************************************* * Liste * - * ******************************************************************************************************************************** */ + * ***************************************************************************************************************/ if ($histo->selected == -1) { $write = $g_user->check_action(FICADD); @@ -234,16 +235,25 @@ if ($histo->selected == 3) $cat_card = new Fiche_Def($cn); $cat_card->id =$http->get('cat','number'); $aHeading = $cat_card->getAttribut(); - if ( $allcard == 0) echo $str_add_card; + $str_add_card=""; + if ( $allcard == 0 ) { + $h_add_card_b = new IButton('add_card'); + $h_add_card_b->label = _('Créer une nouvelle fiche'); + $h_add_card_b->javascript = "dis_blank_card({gDossier:$gDossier,fd_id:$fd_id,after_save:1,ref:2})"; + $str_add_card=$h_add_card_b->input(); + } + echo $str_add_card; require_once NOALYSS_TEMPLATE.'/result_cat_card_summary.php'; $hid = new IHidden(); - echo '
' . dossier::hidden() . - HtmlInput::submit('bt_csv', _("Export CSV")) . - HtmlInput::hidden('act', "CSV:fiche") . - $hid->input("type", "fiche") . - $hid->input("ac", $http->request('ac')) . - $hid->input("fd_id", $http->request('cat',"number")); + echo '' . dossier::hidden() ; + echo $str_add_card; + echo + HtmlInput::submit('bt_csv', _("Export CSV")) . + HtmlInput::hidden('act', "CSV:fiche") . + $hid->input("type", "fiche") . + $hid->input("ac", $http->request('ac')) . + $hid->input("fd_id", $http->request('cat',"number")); echo "
"; return; diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index df4ae72e8..44ee884ad 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -342,7 +342,17 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") $p_script2 . " "; echo ' - + '; + + if (isset($_SESSION['g_lang']) && $_SESSION['g_lang']=='fr_FR.utf8' ) + { + echo ''; + } + if (isset($_SESSION['g_lang']) && $_SESSION['g_lang']=='nl_NL.utf8' ) + { + echo ''; + } + echo ' '; @@ -1321,9 +1331,8 @@ function is_msie() */ function record_log($p_message) { - error_log("noalyss".$p_message,0); - error_log("noalyss GET [".var_export($_GET, true)."]",0); - error_log( "noalyss POST [".var_export($_POST, true)."]",0); + error_log("noalyss".print_r($p_message,true),0); + error_log("noalyss GET [".var_export($_GET, true)."] POST [".var_export($_POST, true)."]",0); } if(!function_exists('tracedebug')) { function tracedebug($file,$var, $label = NULL) { @@ -1365,4 +1374,4 @@ function convert_to_rtf($p_string) } } return $result; -} \ No newline at end of file +} diff --git a/include/lib/config_file.php b/include/lib/config_file.php index 42587f287..3f7c7e62a 100644 --- a/include/lib/config_file.php +++ b/include/lib/config_file.php @@ -70,6 +70,7 @@ function config_file_form($p_array=null) $cdbname=""; $chost="localhost"; $cadmin='admin'; + $cpassword_admin=""; } else extract ($p_array, EXTR_SKIP); diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index 098b7d6ca..2bcba2307 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -75,9 +75,11 @@ class DatabaseCore } $this->is_open = TRUE; + } + public function verify() { // Verify that the elt we want to add is correct diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index f67c83f2c..4b69ab42c 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -605,11 +605,24 @@ class HtmlInput } } } - } - + } + + return $r; + } + /** + * Transform a double array as a HTML string with hidden html value + * array has the formarray ["name"]="x",array['value']="y") the key name will be the hidden input name; + * @param double $array + */ + static function simple_array_to_hidden($array) + { + if (empty ($array)) return ""; + $r=""; + foreach ( $array as $key=>$value) { + $r.=HtmlInput::hidden($key, $value); + } return $r; } - /** * @brief transform a json to hidden * @param json $p_json diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 68a4da608..67b58351e 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -1037,7 +1037,7 @@ function check() { $s1=$xml->createElement("status", "NOK"); $s2=$xml->createElement("ctl_row", - $this->object_name+"_"+$this->table->get_pk_value()); + $this->object_name."_".$this->table->get_pk_value()); $s4=$xml->createElement("ctl", $this->object_name); $s3=$xml->createElement("html", $ex->getTraceAsString()); $root=$xml->createElement("data"); @@ -1113,7 +1113,7 @@ function check() $s1=$xml->createElement("status", "NOK"); $s3=$xml->createElement("ctl", $this->object_name); $s2=$xml->createElement("ctl_row", - $this->object_name+"_"+$this->table->get_pk_value()); + $this->object_name."_".$this->table->get_pk_value()); $s4=$xml->createElement("html", $ex->getTraceAsString()); $root=$xml->createElement("data"); diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index 6e54ab8d8..e9b9d1ebf 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -74,8 +74,8 @@ content[40]=" à zéro pour effacer la ligne"))?>"; content[42]=""; content[43]=""; -content[44]=""; -content[45]=""; +content[44]=""; +content[45]=""; content[46]=""; content[47]=""; content[48]=""; @@ -107,4 +107,4 @@ content[73]=""; content[75]=""; content[76]=""; - \ No newline at end of file + diff --git a/include/lib/select_box.class.php b/include/lib/select_box.class.php index 82c5547c4..28e6bc740 100644 --- a/include/lib/select_box.class.php +++ b/include/lib/select_box.class.php @@ -36,7 +36,8 @@ class Select_Box private $cnt; private $filter; //!< allow a dynamic not case sensitive search var $default_value; - + private $position ; //!< change depending if we are in an absolute block or not + /** * Default constructor * @param type $p_id javascript DOMid @@ -52,6 +53,98 @@ class Select_Box $this->default_value=-1; $this->style_box=""; $this->filter=""; + $this->position="normal"; + } + public function get_position() + { + return $this->position; + } + + public function set_position($position) + { + if ( ! in_array($position,array("normal","in-absolute") ) ) { + throw new Exception("SB0005",EXC_PARAM_VALUE); + } + $this->position=$position; + return $this; + } + + private function compute_position() + { + $list_id=sprintf('%s_list', $this->id); + switch ($this->position) + { + case "normal": + + // Show when click + $javascript=sprintf('$("%s_bt").onclick=function() { + try { + var newDiv=$("select_box%s"); + var pos=$("%s_bt").cumulativeOffset(); + newDiv.setStyle({display:"block",position:"fixed",top:pos.top+25+"px",left:pos.left+5+"px"}); + + if ( $("search_%s") ) { $("search_%s").focus();} + + } catch(e) { + alert(e.message); + } + } + ', $this->id, $this->id, $this->id, $list_id, $list_id); + // Hide when out of the zone + $javascript.=sprintf('$("select_box%s").onmouseleave=function() { + try { + var newDiv=$("select_box%s"); + newDiv.setStyle({display:"none"}); + } catch(e) { + alert(e.message); + } + }',$this->id,$this->id); + break; + case "in-absolute": + // Show when click + $javascript=sprintf(' + $("%s_bt").onclick=function() { + try { + + + if (! document.getElementById("select_box_content") ) { + + var newDiv=new Element("div"); + newDiv.id="select_box_content"; + document.body.appendChild(newDiv); + newDiv.addClassName("select_box"); + $("select_box_content").onmouseleave=function() { + try { + var newDiv=$("select_box_content"); + newDiv.setStyle({display:"none"}); + } catch(e) { + alert(e.message); + } + } + } else { + var newDiv=document.getElementById("select_box_content"); + } + newDiv.innerHTML=$("select_box%s").innerHTML; + var pos=$("%s_bt").cumulativeOffset(); + var nTop=pos.top; + var viewport = document.viewport.getDimensions(); + if ( nTop> viewport.height-newDiv.getHeight()-20) { nTop-=newDiv.getHeight()-5} + + newDiv.setStyle({display:"block",position:"absolute",top:nTop+"px",left:pos.left+5+"px","z-index":999}); + + if ( $("search_%s") ) { $("search_%s").focus();} + } catch(e) { + alert(e.message); + } + } + ', $this->id, $this->id, $this->id, $list_id, $list_id); + + break; + + default: + break; + } + return $javascript; } function input() @@ -59,36 +152,16 @@ class Select_Box $list_id=sprintf('%s_list',$this->id); // Show when click - $javascript=sprintf('$("%s_bt").onclick=function() { - try { - var newDiv=$("select_box%s"); - var pos=$("%s_bt").cumulativeOffset(); - newDiv.setStyle({display:"block",position:"fixed",top:pos.top+25+"px",left:pos.left+5+"px"}); - - if ( $("search_%s") ) { $("search_%s").focus();} - - } catch(e) { - alert(e.message); - } - } - ', $this->id, $this->id, $this->id, $list_id,$list_id); + $javascript=$this->compute_position(); + - // Hide when out of the zone - $javascript.=sprintf('$("select_box%s").onmouseleave=function() { - try { - var newDiv=$("select_box%s"); - newDiv.setStyle({display:"none"}); - } catch(e) { - alert(e.message); - } - }',$this->id,$this->id); // display the button - printf('', + printf('', $this->id, $this->value); printf('', $this->id, $this->id, $this->default_value); - printf('
', + printf('
', $this->id, $this->style_box); // Show the filter if there is one, diff --git a/include/lib/sendmail_core.class.php b/include/lib/sendmail_core.class.php index 11a5180af..b62061d0c 100644 --- a/include/lib/sendmail_core.class.php +++ b/include/lib/sendmail_core.class.php @@ -78,7 +78,8 @@ class Sendmail_Core */ function set_message($p_message) { - $this->message = $p_message; + // $this->message =wordwrap($p_message,70,"\r\n"); + $this->message =$p_message; } /** @@ -134,24 +135,26 @@ class Sendmail_Core $this->content .= "Content-Type: text/plain; charset=\"utf-8\"" . $eol; $this->content .= "Content-Transfer-Encoding: 7bit" . $eol.$eol ; $this->content .= $this->message . $eol ; - - // attachment - for ($i = 0; $i < count($this->afile); $i++) + if ( ! empty($this->afile ) ) { - $file = $this->afile[$i]; - $file_size = filesize($file->full_name); - $handle = fopen($file->full_name, "r"); - $content = fread($handle, $file_size); - fclose($handle); - $content = chunk_split(base64_encode($content)); - $this->content .= "--" . $separator . $eol; - $this->content .= "Content-Type: " . $file->type . "; name=\"" . $file->filename . "\"" . $eol; - $this->content .= "Content-Disposition: attachment; filename=\"" . $file->filename . "\"" . $eol; - $this->content .= "Content-Transfer-Encoding: base64" . $eol; - $this->content.=$eol; - $this->content .= $content . $eol ; + // attachment + for ($i = 0; $i < count($this->afile); $i++) + { + $file = $this->afile[$i]; + $file_size = filesize($file->full_name); + $handle = fopen($file->full_name, "r"); + $content = fread($handle, $file_size); + fclose($handle); + $content = chunk_split(base64_encode($content)); + $this->content .= "--" . $separator . $eol; + $this->content .= "Content-Type: " . $file->type . "; name=\"" . $file->filename . "\"" . $eol; + $this->content .= "Content-Disposition: attachment; filename=\"" . $file->filename . "\"" . $eol; + $this->content .= "Content-Transfer-Encoding: base64" . $eol; + $this->content.=$eol; + $this->content .= $content . $eol ; + } } - if ( count ($this->afile) == 0 ) $this->content.=$eol; + if ( empty ($this->afile) ) $this->content.=$eol; $this->content .= "--" . $separator . "--"; } diff --git a/include/recover.php b/include/recover.php index ec082d1fc..cf9dac818 100644 --- a/include/recover.php +++ b/include/recover.php @@ -25,6 +25,7 @@ define('SIZE_REQUEST', 70); require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; +require_once NOALYSS_INCLUDE.'/class/sendmail.class.php'; /** * @brief generate a random string of char * @param $car int length of the string @@ -95,12 +96,22 @@ elseif ($action=="send_email") : if ($valid==true): $request_id=generate_random(SIZE_REQUEST); $user_password=generate_random(10); - /* - * save the request into - */ - $cn->exec_sql("insert into recover_pass(use_id,request,password,created_on,created_host) " - ." values ($1,$2,$3,now(),$4)", array($user_id, $request_id, $user_password, $_SERVER['REMOTE_ADDR'])); - + // exist a valid request for this user ? + $exist_request= $cn->get_array("select request , password from recover_pass + where use_id=$1 and created_on > now() - interval '12 hours'",[$user_id]); + if ( empty($exist_request ) ) { + /* save the request into */ + $cn->exec_sql("insert into recover_pass(use_id,request,password,created_on,created_host) " + ." values ($1,$2,$3,now(),$4)", array($user_id, $request_id, $user_password, $_SERVER['REMOTE_ADDR'])); + } else { + $request_id=$exist_request[0]["request"]; + $user_password=$exist_request[0]['password']; + /* if too many request , there is a bug somewhere , so record an warning */ + if ( count($exist_request)> 1 ){ + error_log("WRE109 Trop de request pour ".var_export($exist_request,true)); + } + + } /* * send an email */ diff --git a/include/sql/patch/upgrade143.sql b/include/sql/patch/upgrade143.sql new file mode 100644 index 000000000..03ab785ce --- /dev/null +++ b/include/sql/patch/upgrade143.sql @@ -0,0 +1,8 @@ +begin; + +insert into menu_ref (me_code,me_description ,me_file) values ('PDF:operation_detail','Export Operation','export_operation_pdf.php'); +insert into profile_menu(me_code,p_id,p_type_display ,pm_default ) select 'PDF:operation_detail',p_id,'P',0 from profile ; + +insert into version (val,v_description) values (144,'Export Operation PDF'); + +commit; diff --git a/include/sql/patch/upgrade36.sql b/include/sql/patch/upgrade36.sql index 82e2f3a5d..3b74bb2d3 100644 --- a/include/sql/patch/upgrade36.sql +++ b/include/sql/patch/upgrade36.sql @@ -177,8 +177,7 @@ CREATE TABLE bud_hypothese CONSTRAINT fk_bud_hypo_pa_id FOREIGN KEY (pa_id) REFERENCES plan_analytique (pa_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE -) -WITHOUT OIDS; +); create sequence seq_bud_hypothese_bh_id; diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index a92a35f24..37625db7f 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -1,5 +1,6 @@
set_position("in-absolute"); $cn=Dossier::connect(); // Contains all the linked actions $a_followup = Follow_Up::get_all_operation($jr_id); @@ -199,7 +204,6 @@ if ($aRap != null ) { $e ); $remove=Icon_Action::trash(uniqid(), $js); -// $remove=$rmReconciliation->input(); } else $remove=''; @@ -315,25 +319,35 @@ if ( $div != 'popup' ) { echo HtmlInput::submit('save',_('Sauver'),'onClick="return verify_ca(\'popup\');"'); $owner=new Noalyss_Parameter_Folder($cn); if ($owner->MY_ANALYTIC != 'nu' /*&& $div=='popup' */){ - echo ''; + + $select_box->add_javascript(_("Vérification CA"), sprintf("verify_ca('%s')",$div)); } $per=new Periode($cn,$obj->det->jr_tech_per); if ( $per->is_closed() == 0 && $owner->MY_STRICT=='N' && $g_user->check_action(RMOPER)==1) { - $remove=new IButton('Effacer'); - $remove->label=_('Effacer'); - $remove->javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; - echo $remove->input(); + $javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; + $select_box->add_javascript(_("Effacer"), $javascript); } //---------------------------------------------------- // Extourne //---------------------------------------------------- - $reverse=new IButton('bext'.$div); - $reverse->label=_('Extourner'); - $reverse->javascript="g('ext".$div."').style.display='block'"; - echo $reverse->input(); - echo '

'; + $select_box->add_javascript(_("Extourne"), sprintf("g('ext%s').style.display='block'",$div)); + + //------------------------------------------------------------------- + // Duplicate + //------------------------------------------------------------------- + $select_box->add_javascript(_("Duplicate"),sprintf("duplicate_operation('%s','%s')",Dossier::id(),$obj->jr_id)); + + //------------------------------------------------------------------- + // Export PDF + //------------------------------------------------------------------- + $select_box->add_url(_("Export PDF"), "export.php?". + http_build_query(array("act"=>"PDF:operation_detail","gDossier"=>Dossier::id(),"operation_id"=>$obj->jr_id))); + + +echo $select_box->input(); +echo '

'; echo ''; echo '