--- /dev/null
+<?php
+
+
+/**
+ *
+ */
+class cURL
+{
+ public $curl;
+ public $url = null;
+ private $options = Array();
+
+ public function __construct($_url)
+ {
+ if ( !extension_loaded('curl'))
+ {
+ throw new \ErrorException('cURL library not loaded');
+ }
+ $this->curl = curl_init();
+ }
+
+ /**
+ * @brief core function to execute a curl request
+ *
+ */
+ private function exec()
+ {
+ }
+ /**
+ *
+ */
+ public function get($_url,$_data = [])
+ {
+ }
+
+ /**
+ * @brief setOpt of curl instance
+ *
+ * @param $opt String Option to set
+ * @param $val Object or String or Function
+ *
+ * @return boolean true if sucess, 0 if failure
+ */
+ public function setOpt($opt,$val)
+ {
+ $ret = curl_setopt($this->curl,$opt,$val);
+ if ($ret)
+ {
+ $this->options[$opt] = $val;
+ }
+ return $ret;
+ }
+}
+
+?>
$this->texte = substr($this->texte, $fin) ;
} else
{
- error_log("no more paragraph ".$code." début=".$debut." text:".substr($this->texte,0,20));
+ //error_log("no more paragraph ".$code." début=".$debut." text:".substr($this->texte,0,20));
$this->para = '' ;
}
}
//$compte_id = $row_rs_compte['id'] ;
}
- public function onMouvement($type,$date,$montant,$reste,$libelle,$info)
+ public function onMouvement($type,$date,$montant,$mvmt_id,$libelle,$info)
+ {
+ }
+
+ public function onEnd()
{
}
-public function parse($fichier)
-{
+ public function parse($fichier)
+ {
$ofx_msg = "";
//if($_size_ > 3200000) $ofx_msg = "Erreur: le fichier est trop lourd (max 3M)";
if(empty($errStr))
$code_guichet = $this->valeur('BRANCHID') ;
$no_compte = $this->valeur('ACCTID') ;
$this->onAccount($code_banque,$code_guichet,$no_compte);
- $compte_id = 512000;
//$totalRows_rs_compte = mysql_num_rows($rs_compte);
$totalRows_rs_compte = 1;
if ($totalRows_rs_compte == 1) {
$type = $this->valeur('TRNTYPE') ;
$date = $this->valeur('DTPOSTED') ;
$montant = $this->valeur ('TRNAMT') ;
- $reste = $montant ;
- $banque_mouvement_id = $compte_id.' - '.$this->valeur('FITID') ;
+ $mouvement_id = $this->valeur('FITID') ;
$libelle = ucwords(strtolower(str_replace($a_supprimer, ' ', $this->valeur('NAME')))) ;
$info = ucwords(strtolower(str_replace($a_supprimer, ' ', $this->valeur ('MEMO')))) ;
//$values .= "(".$compte_id.",'".$type."',".$date.",".$montant.",".$reste.
// ",'".$banque_mouvement_id."','".$libelle."','".$info."'), " ;
$this->paragraphe('STMTTRN') ;
- $this->onMouvement($type,$date,$montant,$reste,$libelle,$info);
+ $this->onMouvement($type,$date,$montant,$mouvement_id,$libelle,$info);
}
//$values = substr($values, 0, strlen($values)-2) ;
//mysql_select_db($database_locations, $locations);
//if (mysql_query($query_insert, $locations) == 1)
// $ofx_msg = "Importation réussie de $i mouvements dans le compte ".$row_rs_compte['libelle'].'<br />'.mysql_info($locations) ;
//else $ofx_msg = "Erreur dans l'insertion des mouvements" ;
-
} else $ofx_msg = "Erreur: le compte bancaire $code_banque / $code_guichet / $no_compte n'existe pas" ;
} else $ofx_msg = "Erreur: le fichier ne semble pas être un fichier OFX valide" ;
} else $ofx_msg = "Erreur: échec lors de l'ouverture du fichier $fichier" ;
} else $ofx_msg = "Erreur: le fichier n'a pas été téléchargé" ;
- error_log("Parsing end ".$i." : ".$ofx_msg);
+ if (ofx_msg != "")
+ {
+ error_log("Parsing end ".$i." : ".$ofx_msg);
+ }
+ $this->onEnd();
}
}
}
}
if ($filter == FILTER_VALIDATE_INT) {
- // Fix code code validate 0 as integer (add filter_var === 0)
+ // Fix code code validate 0 as integer (add filter_var === 0)
if (! (filter_var($var,$filter) === 0 || filter_var($var,$filter) )) {
- throw new Exception(_("Field validation not an int ").$msg);
+ throw new Exception(_("Field validation not an int").$msg);
}
}
if ($filter == FILTER_VALIDATE_FLOAT) {
+ if ($var == "0.0" )
+ return; // it's ok
if (!filter_var($var,$filter)) {
- throw new Exception(_("Field validation not a float ").$msg);
- }
+ throw new Exception(_("Field validation not a float").$msg);
+ }
}
}