Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions
Impacc_Csv_Misc_Operation Class Reference
Collaboration diagram for Impacc_Csv_Misc_Operation:
Collaboration graph

Public Member Functions

 record (Impacc_Csv $p_csv, Impacc_File $p_file)
 insert file into the table import_detail More...
 
 check (Impacc_Import_detail_SQL $row)
 Check if Data are valid for one row. More...
 
 adapt ($p_row)
 Transform a group of rows to an array and set $jr_date_paid. More...
 
 insert ($a_group, Acc_Ledger $p_ledger)
 Transfer operation with the status correct to the accountancy . More...
 

Detailed Description

Definition at line 28 of file class_impacc_csv_misc_operation.php.

Member Function Documentation

Impacc_Csv_Misc_Operation::adapt (   $p_row)

Transform a group of rows to an array and set $jr_date_paid.

useable by Acc_Ledger_Sold::insert

Definition at line 76 of file class_impacc_csv_misc_operation.php.

References $array, $cn, $g_parameter, and $nb_row.

Referenced by insert().

77  {
78  bcscale(4);
79  $cn=Dossier::connect();
80 
81  // Get the code_group
82  $code_group=$p_row;
83 
84  // get all rows from this group
85  $sql_row= "
86  select id,
87  id_amount_novat_conv,
88  id_date_conv,
89  (select f_id from fiche_detail where ad_value=id_acc and ad_id=23) as f_id ,
90  id_acc ,
91  id_label,
92  id_debit,
93  id_acc,
94  id_pj
95  from
96  impacc.import_detail
97  where
98  import_id=$1
99  and id_code_group=$2";
100  $all_row=$cn->get_array($sql_row,
101  array($p_row['import_id'],$p_row['id_code_group']));
102  // No block due to analytic
103  global $g_parameter;
104  $g_parameter->MY_ANALYTIC="N";
105 
106  // Initialise the array
107  $array=array();
108  // The first row gives all the information , the others of the group
109  // add services
110  $array['nb_item']=count($all_row);
111  $array['e_comm']=$all_row[0]['id_label'];
112  $array['desc']=$all_row[0]['id_label'];
113  $array['jrn_concerned']="";
114  // Must be transformed into DD.MM.YYYY
115  $array['e_pj']=$all_row[0]['id_pj'];
116  $array['e_date']=$all_row[0]['id_date_conv'];
117 
118  $array['mt']=microtime();
119  $array['jrn_type']='ODS';
120  $nb_row=count($all_row);
121  for ( $i=0;$i<$nb_row;$i++)
122  {
123  $price=$all_row[$i]['id_amount_novat_conv'];
124  if ( $all_row[$i]['id_debit'] == "D") {
125  $array["ck".$i]="";
126  }
127  if ($all_row[$i]['f_id']=="")
128  {
129  $array["poste".$i]=$all_row[$i]["id_acc"];
130  }else {
131  $array["qc_".$i]=$all_row[$i]["id_acc"];
132  }
133  $array["amount".$i]=$price;
134  $array["ld".$i]=$all_row[$i]["id_label"];
135  }
136  return $array;
137  }
$nb_row
Definition: search_view.php:6
global $g_parameter
Definition: ajax.php:27
if(isset($_POST['remove'])) $array
global $cn
Impacc_Csv_Misc_Operation::check ( Impacc_Import_detail_SQL  $row)

Check if Data are valid for one row.

Parameters
$rowis an Impacc_Import_detail_SQL object

Definition at line 70 of file class_impacc_csv_misc_operation.php.

71  {
72 
73  }
Impacc_Csv_Misc_Operation::insert (   $a_group,
Acc_Ledger  $p_ledger 
)

Transfer operation with the status correct to the accountancy .

Change the status of the row (id_status to 1) after because it can transferred several rows in one operation

Definition at line 141 of file class_impacc_csv_misc_operation.php.

References $array, $cn, and adapt().

142  {
143  $cn=Dossier::connect();
144  $nb_group=count($a_group);
145  for ( $i=0;$i< $nb_group;$i++)
146  {
147  $array=$this->adapt($a_group[$i]);
148 
149  //Complete the array
150  $array["p_jrn"]=$p_ledger->id;
151 
152  //Receipt
153  if (trim($array['e_pj'])=="") $array["e_pj"]=$p_ledger->guess_pj();
154  $array['e_pj_suggest']=$p_ledger->guess_pj();
155 
156  // Insert
157  $p_ledger->save($array);
158 
159  // Update this group , status = 2 , jr_id
160  // and date_payment
161  $cn->exec_sql("update impacc.import_detail set jr_id=$1 , id_status=2 where id_code_group=$2",
162  array($p_ledger->jr_id,$a_group[$i]['id_code_group']));
163 
164  }
165 
166  }
if(isset($_POST['remove'])) $array
adapt($p_row)
Transform a group of rows to an array and set $jr_date_paid.
global $cn
Impacc_Csv_Misc_Operation::record ( Impacc_Csv  $p_csv,
Impacc_File  $p_file 
)

insert file into the table import_detail

Parameters
Impacc_Csv$p_csvCSV setting
Impacc_File$p_fileFile information

Definition at line 35 of file class_impacc_csv_misc_operation.php.

References $aseparator, $cn, $error, $nb_row, $row, and while.

36  {
37  global $aseparator;
38  // Open the CSV file
39  $hFile=fopen($p_file->import_file->i_tmpname, "r");
40  $error=0;
41  $cn=Dossier::connect();
42  $delimiter=$aseparator[$p_csv->detail->s_delimiter-1]['label'];
43  $surround=($p_csv->detail->s_surround=="")?'"':$p_csv->detail->s_surround;
44  //---- For each row ---
45  while ($row=fgetcsv($hFile, 0, $delimiter, $surround))
46  {
47  $insert=new Impacc_Import_detail_SQL($cn);
48  $insert->import_id=$p_file->import_file->id;
49  $nb_row=count($row);
50  if ($nb_row<6)
51  {
52  $insert->id_status=-1;
53  $insert->id_message=join($row,$delimiter);
54  }
55  else
56  {
57  $insert->id_date=$row[0];
58  $insert->id_code_group=$row[1];
59  $insert->id_acc=$row[2];
60  $insert->id_pj=$row[3];
61  $insert->id_label=$row[4];
62  $insert->id_amount_novat=$row[5];
63  $insert->id_debit=$row[6];
64  }
65  $insert->insert();
66  }
67  }
while(($row=fgetcsv($fbank, 0, $sp))!==false)
for($i=0;$i< Database::num_row($ret);$i++) $row
global $aseparator
$nb_row
Definition: search_view.php:6
$error
global $cn

The documentation for this class was generated from the following file: