fetch_data(); } protected function fetch_data(){ // les data... $this->cashdesk_list=array(); $rqt = "select * from cashdesk order by cashdesk_name"; $res = mysql_query($rqt); $i=0; if(mysql_num_rows($res)){ while($row = mysql_fetch_object($res)){ $this->cashdesk_list[$i]['id'] = $row->cashdesk_id; $this->cashdesk_list[$i]['name'] = $row->cashdesk_name; $i++; } } } public function get_form(){ global $msg; global $cashdesk_list_form, $charset; foreach ($this->cashdesk_list as $index =>$cashdesk){ if ($parity++ % 2) $pair_impair = "even"; else $pair_impair = "odd"; $form.= " ".htmlentities($cashdesk['name'],ENT_QUOTES, $charset)." "; } $cashdesk_list_form = str_replace('!!cashdesk_list!!', $form, $cashdesk_list_form); return $cashdesk_list_form; } public function get_form_summarize(){ global $msg; global $cashdesk_list_form_summarize, $charset; global $cashdesk_filter,$start_date, $stop_date,$field_start_date,$field_stop_date; if(!count($this->cashdesk_list))return ""; if(!$cashdesk_filter)$cashdesk_filter=array(); if(!$cashdesk_filter[0])$cashdesk_filter=array(); if(!count($cashdesk_filter) )$selected= " selected=\"selected\" "; $cashdesk_filter_form=""; $found=0; $tt_realisee_no=0; $tt_realisee=0; $tt_encaissement_no=0; $tt_encaissement=0; foreach ($this->cashdesk_list as $index =>$cashdesk){ if(count($cashdesk_filter) ){ if(! in_array($cashdesk['id'], $cashdesk_filter)) continue; } $cashdesk_info=new cashdesk($cashdesk['id']); $all_transactions=$cashdesk_info->summarize($start_date, $stop_date, $transactype,$encaissement); foreach($all_transactions as $transactions){ if ($parity++ % 2) $pair_impair = "even"; else $pair_impair = "odd"; $form.= " ".htmlentities($cashdesk['name'],ENT_QUOTES, $charset)." ".htmlentities($transactions['name'],ENT_QUOTES, $charset)." ".htmlentities($transactions['unit_price'],ENT_QUOTES, $charset)." ".htmlentities($transactions['montant'],ENT_QUOTES, $charset)." ".htmlentities($transactions['realisee_no'],ENT_QUOTES, $charset)." ".htmlentities($transactions['realisee'],ENT_QUOTES, $charset)." ".htmlentities($transactions['encaissement_no'],ENT_QUOTES, $charset)." ".htmlentities($transactions['encaissement'],ENT_QUOTES, $charset)." "; $tt_realisee_no+=$transactions['realisee_no']; $tt_realisee+=$transactions['realisee']; $tt_encaissement_no+=$transactions['encaissement_no']; $tt_encaissement+=$transactions['encaissement']; $found++; } } $formall=str_replace('!!cashdesk_list!!', $form, $cashdesk_list_form_summarize); $formall=str_replace('!!cashdesk_filter!!', $cashdesk_filter_form, $formall); $formall=str_replace('!!start_date!!', $start_date, $formall); $formall=str_replace('!!field_start_date!!', $field_start_date, $formall); $formall=str_replace('!!stop_date!!', $stop_date, $formall); $formall=str_replace('!!field_stop_date!!', $field_stop_date, $formall); $formall=str_replace('!!realisee_no!!',$tt_realisee_no , $formall); $formall=str_replace('!!realisee!!',$tt_realisee , $formall); $formall=str_replace('!!encaissement_no!!',$tt_encaissement_no , $formall); $formall=str_replace('!!encaissement!!',$tt_encaissement , $formall); $formall=str_replace('!!transaction_filter!!', $transaction_filter_form, $formall); return $formall; } public function get_html_summarize(){ global $msg; global $charset,$cashdesk_list_form_summarize_table,$titre_page; global $cashdesk_filter,$start_date, $stop_date; if(!count($this->cashdesk_list))return ""; if(!$cashdesk_filter)$cashdesk_filter=array(); if(!$cashdesk_filter[0])$cashdesk_filter=array(); $found=0; $tt_realisee_no=0; $tt_realisee=0; $tt_encaissement_no=0; $tt_encaissement=0; foreach ($this->cashdesk_list as $index =>$cashdesk){ if(count($cashdesk_filter) ){ if(! in_array($cashdesk['id'], $cashdesk_filter)) continue; } $cashdesk_info=new cashdesk($cashdesk['id']); $all_transactions=$cashdesk_info->summarize($start_date, $stop_date, $transactype,$encaissement); foreach($all_transactions as $transactions){ $form.= " ".htmlentities($cashdesk['name'],ENT_QUOTES, $charset)." ".htmlentities($transactions['name'],ENT_QUOTES, $charset)." ".htmlentities($transactions['unit_price'],ENT_QUOTES, $charset)." ".htmlentities($transactions['montant'],ENT_QUOTES, $charset)." ".htmlentities($transactions['realisee_no'],ENT_QUOTES, $charset)." ".htmlentities($transactions['realisee'],ENT_QUOTES, $charset)." ".htmlentities($transactions['encaissement_no'],ENT_QUOTES, $charset)." ".htmlentities($transactions['encaissement'],ENT_QUOTES, $charset)." "; $tt_realisee_no+=$transactions['realisee_no']; $tt_realisee+=$transactions['realisee']; $tt_encaissement_no+=$transactions['encaissement_no']; $tt_encaissement+=$transactions['encaissement']; $found++; } } $formall=str_replace('!!cashdesk_list!!', $form, $cashdesk_list_form_summarize_table); $formall=str_replace('!!realisee_no!!',$tt_realisee_no , $formall); $formall=str_replace('!!realisee!!',$tt_realisee , $formall); $formall=str_replace('!!encaissement_no!!',$tt_encaissement_no , $formall); $formall=str_replace('!!encaissement!!',$tt_encaissement , $formall); return $formall; } public function get_excel_summarize(){ global $msg; global $charset,$fichier_temp_nom,$titre_page; global $cashdesk_filter,$start_date, $stop_date; if(!count($this->cashdesk_list))return ""; if(!$cashdesk_filter)$cashdesk_filter=array(); if(!$cashdesk_filter[0])$cashdesk_filter=array(); $fname = tempnam("./temp", "$fichier_temp_nom.xls"); $workbook = new writeexcel_workbook($fname); $worksheet = &$workbook->addworksheet(); $worksheet->write(0,0,$titre_page); $i=2; $j=2; $worksheet->write($i,$j++,$msg["cashdesk_edition_name"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_name"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_unit_price"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_montant"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_realisee_no"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_realisee"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_encaissement_no"]); $worksheet->write($i,$j++,$msg["cashdesk_edition_transac_encaissement"]); $i++; foreach ($this->cashdesk_list as $index =>$cashdesk){ if(count($cashdesk_filter) ){ if(! in_array($cashdesk['id'], $cashdesk_filter)) continue; } $cashdesk_info=new cashdesk($cashdesk['id']); $all_transactions=$cashdesk_info->summarize($start_date, $stop_date, $transactype,$encaissement); if(!count($all_transactions) ) continue; foreach($all_transactions as $transactions){ $j=2; $worksheet->write($i,$j++,$cashdesk['name']); $worksheet->write($i,$j++,$transactions['name']); $worksheet->write($i,$j++,$transactions['unit_price']); $worksheet->write($i,$j++,$transactions['montant']); $worksheet->write($i,$j++,$transactions['realisee_no']); $worksheet->write($i,$j++,$transactions['realisee']); $worksheet->write($i,$j++,$transactions['encaissement_no']); $worksheet->write($i,$j++,$transactions['encaissement']); $i++; } } $workbook->close(); $fh=fopen($fname, "rb"); fpassthru($fh); unlink($fname); } public function proceed(){ global $action; switch($action) { case 'add': break; default: break; } } }