*
Document ".$doc->a_ref().'
'; $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; // ag_cal $ag_cal=new ICheckBox('ag_cal'); $ag_cal->readonly=$readonly; $ag_cal->name="ag_cal"; if ( $this->ag_cal=='C' ) $ag_cal->selected=true; else $ag_cal->selected=false; $str_ag_cal=$ag_cal->input(); // 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(); // Person in charged of the action $ag_dest=new ISelect(); $ag_dest->readonly=$readonly; $ag_dest->name="ag_dest"; $repo=new Database(); $aAg_dest=$repo->make_array("select use_id as value, ". "use_first_name||' '||use_name||'('||use_login||')' as label ". " from ac_users natural join jnt_use_dos ". " join priv_user on (jnt_id=priv_jnt) ". "where dos_id= ".$_REQUEST['gDossier']); $aAg_dest[]=array('value'=>0,'label'=>'phpcompta'); $ag_dest->value=$aAg_dest; $ag_dest->selected=$this->ag_dest; $str_ag_dest=$ag_dest->input(); // ag_ref // Always false for update $ag_ref=new IText(); $ag_ref->readonly=$upd; $ag_ref->name="ag_ref"; $ag_ref->value=FormatString($this->ag_ref); $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 $lag_ref_ag_id=" 00 / 00 "; if ( $this->ag_ref_ag_id != 0 ) { $supl_hidden=''; if( isset($_REQUEST['sc'])) $supl_hidden.='&sc='.$_REQUEST['sc']; if( isset($_REQUEST['f_id'])) $supl_hidden.='&f_id='.$_REQUEST['f_id']; if( isset($_REQUEST['sb'])) $supl_hidden.='&sb='.$_REQUEST['sb']; $lag_ref_ag_id=''. $this->db->get_value("select ag_ref from action_gestion where ag_id=$1",array($this->ag_ref_ag_id)). ""; } // 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; // contact $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(); $str_ag_ref="".(($this->ag_ref != "")?$this->ag_ref:" Nouveau ").""; // Preparing the return string $r=""; /* for new files */ $upload=new IFile(); $upload->name="file_upload[]"; $upload->value=""; $aAttachedFile=$this->db->get_array('select d_id,d_filename,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; /* create aArticle for the detail section */ for ($i=0;$i< MAX_ARTICLE;$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->value=''; 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(); } } $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->name="e_march".$i."_label"; $text->size=40; $text->value=($tmp_ad)?$tmp_ad->get_parameter('text'):""; $aArticle[$i]['desc']=$text->input(); $num->javascript=' onchange="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"'; $num->name="e_march".$i."_price"; $num->size=8; $num->value=($tmp_ad)?$tmp_ad->get_parameter('price_unit'):0; $aArticle[$i]['pu']=$num->input(); $num->name="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->value=($tmp_ad)?$tmp_ad->get_parameter('tva_id'):0; $itva->javascript=' 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->value=($tmp_ad)?$tmp_ad->get_parameter('tva_amount'):0; $num->javascript=' onchange="compute_ledger('.$i.')"'; $num->size=8; $aArticle[$i]['tva']=$num->input(); $num->name="tvac_march".$i; $num->value=($tmp_ad)?$tmp_ad->get_parameter('total'):0; $num->size=8; $aArticle[$i]['tvac']=$num->input(); $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",MAX_ARTICLE); /* get template */ ob_start(); require_once ('template/detail-action.php'); $content=ob_get_contents(); ob_end_clean(); $r.=$content; //hidden $r.=""; $r.=$h2->input(); $r.=$h_agrefid->input("ag_ref_ag_id",$this->ag_ref_ag_id); $r.=$h_ag_id->input('ag_id',$this->ag_id); $hidden2=new IHidden(); $r.=$hidden2->input('f_id_dest',$this->f_id_dest); $r.="
"; // show the list of the concern operation if ( $this->db->count_sql('select * from action_gestion where ag_ref_ag_id!=0 and ag_ref_ag_id='.$this->ag_id. " limit 2") > 0 ) { $sql=sprintf(" and ag_id in (select action_get_tree from comptaproc.action_get_tree(%s)) ",$this->ag_id); $r.=$this->myList($p_base,"",$sql); } return $r; } //---------------------------------------------------------------------- /*!\brief This function shows the detail of an action thanks the ag_id */ function get() { $sql="select ag_id, ag_comment,to_char (ag_timestamp,'DD.MM.YYYY') as ag_timestamp,". " f_id_dest,ag_title,ag_comment,ag_ref,d_id,ag_type,ag_state, ". " ag_ref_ag_id, ag_dest, ag_hour, ag_priority, ag_cal,ag_contact ". " from action_gestion left join document using (ag_id) where ag_id=".$this->ag_id; $r=$this->db->exec_sql($sql); $row=Database::fetch_all($r); if ( $row==false) return; $this->ag_comment=$row[0]['ag_comment']; $this->ag_timestamp=$row[0]['ag_timestamp']; $this->ag_contact=$row[0]['ag_contact']; $this->f_id_dest=$row[0]['f_id_dest']; $this->ag_title=$row[0]['ag_title']; $this->ag_type=$row[0]['ag_type']; $this->ag_ref=$row[0]['ag_ref']; $this->ag_state=$row[0]['ag_state']; $this->ag_ref_ag_id=$row[0]['ag_ref_ag_id']; $this->d_id=$row[0]['d_id']; $this->ag_dest=$row[0]['ag_dest']; $this->ag_hour=$row[0]['ag_hour']; $this->ag_priority=$row[0]['ag_priority']; $this->ag_cal=$row[0]['ag_cal']; $action_detail=new Action_Detail($this->db); $action_detail->set_parameter('ag_id',$this->ag_id); $this->aAction_detail=$action_detail->load_all(); // if there is no document set 0 to d_id if ( $this->d_id == "" ) $this->d_id=0; // if there is a document fill the object if ($this->d_id != 0 ) { $this->state=$row['0']['ag_state']; $this->ag_state=$row[0]['ag_state']; } $this->dt_id=$this->ag_type; $aexp=new Fiche($this->db,$this->f_id_dest); $this->qcode_dest=$aexp->strAttribut(ATTR_DEF_QUICKCODE); } /*! * \brief Save the document and propose to save the generated document or * to upload one, the data are included except the file. Temporary the generated * document is save * * \return */ function save() { // Get The sequence id, $seq_name="seq_doc_type_".$this->dt_id; $str_file=""; $add_file=''; // f_id exp $exp=new Fiche($this->db); $exp->get_by_qcode($this->qcode_dest); $contact=new Fiche($this->db); $contact->get_by_qcode($this->ag_contact); if ( trim($this->ag_title) == "") { $doc_mod=new document_type($this->db); $doc_mod->dt_id=$this->dt_id; $doc_mod->get(); $this->ag_title=$doc_mod->dt_value; } $this->ag_id=$this->db->get_next_seq('action_gestion_ag_id_seq'); // Create the reference $ref=$this->dt_id.'/'.$this->ag_id; $this->ag_ref=$ref; if ( $this->ag_cal=='on') $ag_cal='C'; else $ag_cal='I'; $this->ag_ref_ag_id=(strlen(trim($this->ag_ref_ag_id))==0)?0:$this->ag_ref_ag_id; // save into the database $sql="insert into action_gestion". "(ag_id,ag_timestamp,ag_type,ag_title,f_id_dest,ag_comment,ag_ref,ag_ref_ag_id, ag_dest, ". " ag_hour, ag_priority,ag_cal,ag_owner,ag_contact,ag_state) ". " values ($1,to_date($2,'DD.MM.YYYY'),$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)"; $this->db->exec_sql($sql,array($this->ag_id, /* 1 */ $this->ag_timestamp, /* 2 */ $this->dt_id, /* 3 */ $this->ag_title, /* 4 */ $exp->id, /* 5 */ $this->ag_comment, /* 6 */ $ref, /* 7 */ $this->ag_ref_ag_id, /* 8 */ $this->ag_dest, /* 9 */ $this->ag_hour, /* 10 */ $this->ag_priority, /* 11 */ $ag_cal, /* 12 */ $_SESSION['g_user'], /* 13 */ $contact->id, /* 14 */ $this->ag_state /* 15 */ ) ); /* insert also the details */ for ( $i = 0; $i < MAX_ARTICLE;$i++) { $act=new Action_Detail($this->db); $act->from_array($_POST,$i); $act->ag_id=$this->ag_id; $act->save(); } /* Upload the documents */ $doc=new Document($this->db); $doc->Upload($this->ag_id); } /*! myList($p_filter="") * \brief Show list of action by default if sorted on date *\param $p_base base url with p_action... * \param $p_filter filters on the document_type * \param $p_search must a valid sql command ( ex 'and ag_title like upper('%hjkh%')) * \return string containing html code */ function myList($p_base,$p_filter="",$p_search="") { $str_dossier=dossier::get(); // for the sort $sort=""; $image_asc='