* * * \brief Misc Operation for analytic accountancy * */ if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); } require_once NOALYSS_INCLUDE . '/class_ihidden.php'; require_once NOALYSS_INCLUDE . '/class_iselect.php'; require_once NOALYSS_INCLUDE . '/class_anc_account.php'; require_once NOALYSS_INCLUDE . '/class_anc_operation.php'; require_once NOALYSS_INCLUDE . '/class_anc_plan.php'; require_once NOALYSS_INCLUDE . '/class_anc_group_operation.php'; global $g_user; $str_dossier = Dossier::get(); $pa = new Anc_Plan($cn); $m = $pa->get_list(); if (!$m) { echo '<div style="float:left;width:60%;margin-left:20%"><h2 class="error">' . _('Aucun plan analytique défini') . '</h2></div>'; return; } //---------------------------------------------------------------------- // show the left menu //---------------------------------------------------------------------- echo ' <div class="content" > <div class="menu2"> <table> <tr> <td class="mtitle" >
$mp = new Acc_Payment($cn); $r = $mp->blank(); echo '<form method="POST" id="payment_frm" onsubmit="return confirm_box(this,\'Vous confirmez ?\')">'; echo dossier::hidden(); echo HtmlInput::hidden('ac', $_REQUEST['ac']), HtmlInput::hidden('insert', 0); echo $r; echo HtmlInput::submit('insertsub', _('Enregistre')); echo HtmlInput::button_anchor(_('Retour sans sauver'), '?p_action=divers&sa=mp&' . dossier::get() . "&ac=" . $_REQUEST['ac'], "", "", "smallbutton"); echo '</form>'; return; } //-------------------------------------------------------------------------------- //LIST //-------------------------------------------------------------------------------- /* Get the data from database */ $header = new Sort_Table(); $base_url = $_SERVER['PHP_SELF'] . "?" . Dossier::get() . "&ac=" . $_REQUEST['ac']; $header->add(_("Libelle"), $base_url, "order by mp_lib asc", "order by mp_lib desc", 'la', 'ld'); $header->add(_("Pour le journal"), $base_url, "order by jrn_def_name asc", "order by jrn_def_name desc", 'ja', 'jd'); $header->add(_("Type de fiche"), $base_url, "order by fd_label asc", "order by fd_label desc", 'tc', 'td'); $header->add(_("Enregistré dans le journal"), $base_url, "order by jrn_target asc", "order by jrn_target desc", 'jta', 'jtd'); $header->add(_("Avec la fiche"), $base_url, "order by vw_name asc", "order by vw_name desc", 'na', 'nd'); $order = isset($_REQUEST['ord']) ? $_REQUEST['ord'] : 'la'; $sql = $header->get_sql_order($order); $array = $cn->get_array("\n\tselect\n\t\t\tmp_id,mp_lib,mp_jrn_def_id,mp_fd_id,mp_qcode,j.jrn_def_id,\n\t\t\tj.jrn_def_name as jrn_def_name,\n\t\t\tj2.jrn_def_name as jrn_target,\n\t\t\tfd_label,\n\t\t\tcoalesce(mp_qcode,'A choisir à l''encodage') as vw_name\n\t\t\tfrom mod_payment as mp\n\t\t\tleft join jrn_def as j on (j.jrn_def_id=mp.jrn_def_id)\n\t\t\tleft join jrn_def as j2 on (j2.jrn_def_id=mp.mp_jrn_def_id)\n\t\t\tleft join fiche_def as fd on (mp.mp_fd_id=fd.fd_id)\n\t\t\t{$sql}\n\t"); /* if there are data show them in a table */ if (!empty($array)) { require_once NOALYSS_INCLUDE . '/template/list_mod_payment.php'; echo HtmlInput::button_anchor("Ajout", $base_url . "&sb=ins", "", "", "smallbutton"); } echo '</div>';
/** * Returns HTML code for displaying a icon with a link to a receipt document from * the ledger * @global $cn database connx * @param $p_jr_id jrn.jr_id * @return nothing or HTML Code for a link to the document */ static function show_receipt_document($p_jr_id) { global $cn; $array = $cn->get_array('select jr_def_id,jr_pj_name,jr_grpt_id from jrn where jr_id=$1', array($p_jr_id)); if (count($array) == 0) { return ""; } if ($array[0]['jr_pj_name'] == "") { return ""; } $str_dossier = Dossier::get(); $image = '<IMG style="width:24px;height:24px;border:0px" SRC="image/documents.png" title="' . $array[0]['jr_pj_name'] . '" >'; $r = sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s">%s</A>', $array[0]['jr_def_id'], $array[0]['jr_grpt_id'], $str_dossier, $image); return $r; }
/** * \brief Display the object, the tags for the FORM * are in the caller. It will be used for adding and updating * action * \note If ag_id is not equal to zero then it is an update otherwise * it is a new document * * \param $p_view form will be in readonly mode (value: READ, UPD or NEW ) * \param $p_gen true we show the tag for generating a doc (value : true or false) and adding files * \param $p_base is the ac parameter * \param $retour is the html code for the return button * \note update the reference number or the document type is not allowed * * * \return string containing the html code */ function Display($p_view, $p_gen, $p_base, $retour = "") { global $g_user; if ($p_view == 'UPD') { $upd = true; $readonly = false; } elseif ($p_view == "NEW") { $upd = false; $readonly = false; $this->ag_ref = _("Nouveau"); } elseif ($p_view == 'READ') { $upd = true; $readonly = true; } else { throw new Exception('class_action' . __LINE__ . 'Follow_Up::Display error unknown parameter' . $p_view); } // Compute the widget // Date $date = new IDate(); $date->readOnly = $readonly; $date->name = "ag_timestamp"; $date->id = "ag_timestamp"; $date->value = $this->ag_timestamp; $remind_date = new IDate(); $remind_date->readOnly = $readonly; $remind_date->name = "ag_remind_date"; $remind_date->id = "ag_remind_date"; $remind_date->value = $this->ag_remind_date; // Doc Type $doc_type = new ISelect(); $doc_type->name = "dt_id"; $doc_type->value = $this->db->make_array("select dt_id,dt_value from document_type order by dt_value", 1); $doc_type->selected = $this->dt_id; $doc_type->readOnly = $readonly; $str_doc_type = $doc_type->input(); // Description $desc = new ITextArea(); $desc->style = ' class="itextarea" style="width:80%;margin-left:0px"'; $desc->name = "ag_comment"; $desc->readOnly = $readonly; $acomment = $this->db->get_array("SELECT agc_id, ag_id, to_char(agc_date,'DD.MM.YYYY HH24:MI') as str_agc_date, agc_comment, tech_user\n\t\t\t\t FROM action_gestion_comment where ag_id=\$1 order by agc_id;", array($this->ag_id)); // List opération liées $operation = $this->db->get_array("select ago_id,j.jr_id,j.jr_internal,j.jr_comment,to_char(j.jr_date,'DD.MM.YY') as str_date\n\t\t\tfrom jrn as j join action_gestion_operation as ago on (j.jr_id=ago.jr_id)\n\t\t\twhere ag_id=\$1 order by jr_date", array($this->ag_id)); $iconcerned = new IConcerned('operation'); // List related action $action = $this->db->get_array("\n\t\t\tselect ag_id,ag_ref,substr(ag_title,1,40) as sub_title,to_char(ag_timestamp,'DD.MM.YY') as str_date ,\n\t\t\t\tag_timestamp,dt_value\n\t\t\t\t\tfrom action_gestion\n\t\t\t\t\t join document_type on (ag_type=dt_id)\n\t\t\t\twhere\n\t\t\t\tag_id in (select aga_greatest from action_gestion_related where aga_least =\$1)\n\t\t\t\tor\n\t\t\t\tag_id in (select aga_least from action_gestion_related where aga_greatest =\$1)\n\t\t\t\torder by ag_timestamp", array($this->ag_id)); $iaction = new IRelated_Action('action'); $iaction->value = isset($this->action) ? $this->action : ""; // state // Retrieve the value $a = $this->db->make_array("select s_id,s_value from document_state "); $state = new ISelect(); $state->readOnly = $readonly; $state->name = "ag_state"; $state->value = $a; $state->selected = $this->ag_state; $str_state = $state->input(); // Retrieve the value if there is an attached doc $doc_ref = ""; // Document id $h2 = new IHidden(); $h2->name = "d_id"; $h2->value = $this->d_id; if ($this->d_id != 0 && $this->d_id != "") { $h2->readonly = $p_view == 'NEW' ? false : true; $doc = new Document($this->db, $this->d_id); $doc->get(); if (strlen(trim($doc->d_lob)) != 0) { $d_id = new IHidden(); $doc_ref = "<p> Document " . $doc->anchor() . '</p>'; $doc_ref .= $h2->input() . $d_id->input('d_id', $this->d_id); } } // title $title = new IText(); $title->readOnly = $readonly; $title->name = "ag_title"; $title->value = $this->ag_title; $title->size = 60; // Priority of the ag_priority $ag_priority = new ISelect(); $ag_priority->readOnly = $readonly; $ag_priority->name = "ag_priority"; $ag_priority->selected = $this->ag_priority; $ag_priority->value = array(array('value' => 1, 'label' => 'Haute'), array('value' => 2, 'label' => 'Moyenne'), array('value' => 3, 'label' => 'Basse')); $str_ag_priority = $ag_priority->input(); // hour of the action (meeting) ag_hour $ag_hour = new IText(); $ag_hour->readOnly = $readonly; $ag_hour->name = "ag_hour"; $ag_hour->value = $this->ag_hour; $ag_hour->size = 6; $ag_hour->javascript = " onblur=check_hour('ag_hour');"; $str_ag_hour = $ag_hour->input(); // Profile in charged of the action $ag_dest = new ISelect(); $ag_dest->readOnly = $readonly; $ag_dest->name = "ag_dest"; // select profile $aAg_dest = $this->db->make_array("select p_id as value, " . "p_name as label " . " from profile where p_id in (select p_granted from user_sec_action_profile where ua_right='W' and p_id=" . $g_user->get_profile() . ") order by 2"); $ag_dest->value = $aAg_dest; $ag_dest->selected = $this->ag_dest; $str_ag_dest = $ag_dest->input(); // ag_ref // Always false for update $client_label = new ISpan(); /* Add button */ $f_add_button = new IButton('add_card'); $f_add_button->label = _('Créer une nouvelle fiche'); $f_add_button->set_attribute('ipopup', 'ipop_newcard'); $filter = $this->db->make_list('select fd_id from fiche_def '); $f_add_button->set_attribute('filter', $filter); $f_add_button->javascript = " select_card_type(this);"; $str_add_button = $f_add_button->input(); // f_id_dest sender if ($this->qcode_dest != NOTFOUND && strlen(trim($this->qcode_dest)) != 0) { $tiers = new Fiche($this->db); $tiers->get_by_qcode($this->qcode_dest); $qcode_dest_label = $tiers->strAttribut(1); $this->f_id_dest = $tiers->id; } else { $qcode_dest_label = $this->f_id_dest == 0 || trim($this->qcode_dest) == "" ? 'Interne ' : 'Error'; } $h_ag_id = new IHidden(); // if concerns another action : show the link otherwise nothing // // sender $w = new ICard(); $w->readOnly = $readonly; $w->jrn = 0; $w->name = 'qcode_dest'; $w->value = $this->f_id_dest != 0 ? $this->qcode_dest : ""; $w->label = ""; $list_recipient = $this->db->make_list('select fd_id from fiche_def where frd_id in (14,25,8,9,16)'); $w->extra = $list_recipient; $w->set_attribute('typecard', $list_recipient); $w->set_dblclick("fill_ipopcard(this);"); $w->set_attribute('ipopup', 'ipopcard'); // name of the field to update with the name of the card $w->set_attribute('label', 'qcode_dest_label'); // name of the field to update with the name of the card $w->set_attribute('typecard', $w->extra); $w->set_function('fill_data'); $w->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $w->name); $sp = new ISpan(); $sp->name = 'qcode_dest_label'; $sp->value = $qcode_dest_label; // autre - a refaire pour avoir plusieurs fiches // Sur le modèle des tags $ag_contact = new ICard(); $ag_contact->readOnly = $readonly; $ag_contact->jrn = 0; $ag_contact->name = 'ag_contact'; $ag_contact->value = ''; $ag_contact->set_attribute('ipopup', 'ipopcard'); if ($this->ag_contact != 0) { $contact = new Fiche($this->db, $this->ag_contact); $ag_contact->value = $contact->get_quick_code(); } $ag_contact->label = ""; $list_contact = $this->db->make_list('select fd_id from fiche_def where frd_id=16'); $ag_contact->extra = $list_contact; $ag_contact->set_dblclick("fill_ipopcard(this);"); // name of the field to update with the name of the card $ag_contact->set_attribute('label', 'ag_contact_label'); // name of the field to update with the name of the card $ag_contact->set_attribute('typecard', $list_contact); $ag_contact->set_function('fill_data'); $ag_contact->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $ag_contact->name); $spcontact = new ISpan(); $spcontact->name = 'ag_contact_label'; $spcontact->value = ''; $fiche_contact = new Fiche($this->db); $fiche_contact->get_by_qcode($this->ag_contact); if ($fiche_contact->id != 0) { $spcontact->value = $fiche_contact->strAttribut(ATTR_DEF_NAME); } $h_agrefid = new IHidden(); $iag_ref = new IText("ag_ref"); $iag_ref->value = $this->ag_ref; $iag_ref->readOnly = $p_view == "NEW" || $p_view == 'READ' ? true : false; $str_ag_ref = $iag_ref->input(); // Preparing the return string $r = ""; /* for new files */ $upload = new IFile(); $upload->name = "file_upload[]"; $upload->readOnly = $readonly; $upload->value = ""; $aAttachedFile = $this->db->get_array('select d_id,d_filename,d_description,d_mimetype,' . '\'show_document.php?' . Dossier::get() . '&d_id=\'||d_id as link' . ' from document where ag_id=$1', array($this->ag_id)); /* create the select for document */ $aDocMod = new ISelect(); $aDocMod->name = 'doc_mod'; $aDocMod->value = $this->db->make_array('select md_id,dt_value||\' : \'||md_name as md_name' . ' from document_modele join document_type on (md_type=dt_id)' . ' order by md_name'); $str_select_doc = $aDocMod->input(); /* if no document then do not show the generate button */ if (empty($aDocMod->value)) { $str_submit_generate = ""; } else { $str_submit_generate = HtmlInput::submit("generate", _("Génére le document")); } $ag_id = $this->ag_id; /* fid = Icard */ $icard = new ICard(); $icard->jrn = 0; $icard->table = 0; $icard->extra2 = 'QuickCode'; $icard->noadd = "no"; $icard->extra = 'all'; /* Text desc */ $text = new IText(); $num = new INum(); /* TVA */ $itva = new ITva_Popup($this->db); $itva->in_table = true; $aCard = array(); /* create aArticle for the detail section */ $article_count = count($this->aAction_detail) == 0 ? MAX_ARTICLE : count($this->aAction_detail); /* Compute total */ $tot_item = 0; $tot_vat = 0; for ($i = 0; $i < $article_count; $i++) { /* fid = Icard */ $icard = new ICard(); $icard->jrn = 0; $icard->table = 0; $icard->noadd = "no"; $icard->extra = 'all'; $icard->name = "e_march" . $i; $tmp_ad = isset($this->aAction_detail[$i]) ? $this->aAction_detail[$i] : false; $icard->readOnly = $readonly; $icard->value = ''; $aCard[$i] = 0; if ($tmp_ad) { $march = new Fiche($this->db); $f = $tmp_ad->get_parameter('qcode'); if ($f != 0) { $march->id = $f; $icard->value = $march->get_quick_code(); $aCard[$i] = $f; } } $icard->set_dblclick("fill_ipopcard(this);"); // name of the field to update with the name of the card $icard->set_attribute('label', "e_march" . $i . "_label"); // name of the field to update with the name of the card $icard->set_attribute('typecard', $icard->extra); $icard->set_attribute('ipopup', 'ipopcard'); $icard->set_function('fill_data'); $icard->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $icard->name); $aArticle[$i]['fid'] = $icard->search() . $icard->input(); $text->javascript = ' onchange="clean_tva(' . $i . ');compute_ledger(' . $i . ')"'; $text->css_size = "100%"; $text->name = "e_march" . $i . "_label"; $text->id = "e_march" . $i . "_label"; $text->size = 40; $text->value = $tmp_ad ? $tmp_ad->get_parameter('text') : ""; $text->readOnly = $readonly; $aArticle[$i]['desc'] = $text->input(); $num->javascript = ' onchange="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ')"'; $num->name = "e_march" . $i . "_price"; $num->id = "e_march" . $i . "_price"; $num->size = 8; $num->readOnly = $readonly; $num->value = $tmp_ad ? $tmp_ad->get_parameter('price_unit') : 0; $aArticle[$i]['pu'] = $num->input(); $num->name = "e_quant" . $i; $num->id = "e_quant" . $i; $num->size = 8; $num->value = $tmp_ad ? $tmp_ad->get_parameter('quantity') : 0; $aArticle[$i]['quant'] = $num->input(); $itva->name = 'e_march' . $i . '_tva_id'; $itva->id = 'e_march' . $i . '_tva_id'; $itva->value = $tmp_ad ? $tmp_ad->get_parameter('tva_id') : 0; $itva->readOnly = $readonly; $itva->js = ' onchange="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ')"'; $itva->set_attribute('compute', $i); $aArticle[$i]['tvaid'] = $itva->input(); $num->name = "e_march" . $i . "_tva_amount"; $num->id = "e_march" . $i . "_tva_amount"; $num->value = $tmp_ad ? $tmp_ad->get_parameter('tva_amount') : 0; $num->javascript = " onchange=\"compute_ledger('" . $i . " ')\""; $num->size = 8; $aArticle[$i]['tva'] = $num->input(); $tot_vat = bcadd($tot_vat, $num->value); $num->name = "tvac_march" . $i; $num->id = "tvac_march" . $i; $num->value = $tmp_ad ? $tmp_ad->get_parameter('total') : 0; $num->size = 8; $aArticle[$i]['tvac'] = $num->input(); $tot_item = bcadd($tot_item, $num->value); $aArticle[$i]['hidden_htva'] = HtmlInput::hidden('htva_march' . $i, 0); $aArticle[$i]['hidden_tva'] = HtmlInput::hidden('tva_march' . $i, 0); $aArticle[$i]['ad_id'] = $tmp_ad ? HtmlInput::hidden('ad_id' . $i, $tmp_ad->get_parameter('id')) : HtmlInput::hidden('ad_id' . $i, 0); } /* Add the needed hidden values */ $r .= dossier::hidden(); /* add the number of item */ $Hid = new IHidden(); $r .= $Hid->input("nb_item", $article_count); $r .= HtmlInput::request_to_hidden(array("closed_action", "remind_date_end", "remind_date", "sag_ref", "only_internal", "state", "qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate", "searchtag")); $a_tag = $this->tag_get(); $menu = new Default_Menu(); /* get template */ ob_start(); require 'template/detail-action.php'; $content = ob_get_contents(); ob_end_clean(); $r .= $content; //hidden $r .= "<p>"; $r .= $h2->input(); $r .= $h_ag_id->input('ag_id', $this->ag_id); $hidden2 = new IHidden(); $r .= $hidden2->input('f_id_dest', $this->f_id_dest); $r .= "</p>"; return $r; }