Author: danydb Date: 2012-03-29 01:57:15 +0200 (Thu, 29 Mar 2012) New Revision: 321
Added: trunk/import_doli/doc/fiche-2.csv trunk/import_doli/doc/fiche.csv trunk/import_doli/doc/import-donnee-dolibarr test.csv trunk/import_doli/doc/import-donnee-dolibarr test.ods trunk/import_doli/doc/import-donnee-dolibarr.ods trunk/import_doli/doc/import-donnee-fiche.ods trunk/import_doli/impdol.js trunk/import_doli/include/class_impdol_operation.php trunk/import_doli/include/class_install_impdol.php trunk/import_doli/include/class_sql_impdol.php trunk/import_doli/include/imd_operation.inc.php trunk/import_doli/include/imd_parameter.inc.php trunk/import_doli/include/template/parameter.php trunk/import_doli/include/template/parameter_tva_add.php trunk/import_doli/include/template/test_operation.php trunk/import_doli/include/template/upload_operation.php Modified: trunk/import_doli/doc/ trunk/import_doli/index.php Log: impdoli import operation into operation_tmp Property changes on: trunk/import_doli/doc ___________________________________________________________________ Name: svn:ignore + .~lock.import-donnee-fiche.ods# .~lock.import-donnee-dolibarr test.ods# .~lock.import-donnee-dolibarr.ods# .~lock.import-donnee-dolibarr test.csv# Added: trunk/import_doli/doc/fiche-2.csv =================================================================== --- trunk/import_doli/doc/fiche-2.csv (rev 0) +++ trunk/import_doli/doc/fiche-2.csv 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,9 @@ +Dubbel Win SA;Schiettecatte Patrick;01.02.2010;01.02.2013;;;[email protected];400;BE463141049;AVENUE LAVOISIER 13;1300;WAVRE;Belgique;PSCHIET +FRMJC;[email protected];01.06.2011;01.06.2012;PLUSIEURS DOSSIERS;03 80 45 02 86;[email protected];400;;22 RUE DU TIRE PESSEAU; 21000;DIJON;FRANCE;FRMJC +marcellin champagnat;Jean marc PE;01.06.2010;01.06.2012;Compte à fermer au 30/5/2012;063/23.51.50;[email protected];400;ASBL 896.993;33 rue de bastogne;6700;Arlon;Belgique;MARCECHAMP +Self Reliance;Pierre willot;15.01.2008;15.01.2013;;071.77.36.17;[email protected];4000009;BE0874.449.753;rue Haut Vent 34;5070;Fosses-La-Ville;Belgique;SR +SHONAGON FILM;Aude Boesmans;01.02.2010;31.12.2011;Abonnement terminé;;;400;;;;;;SHONAGON +SNETAP FSU;Henri COMBEAU;01.07.2010;01.07.2012;;;;400;;Rue de Vaugirard 251;75732;Paris;France;SNETAP +Tangram Finance;Philippe LeclercS;26.02.2011;01.04.2012;Abonnement Entreprise sur Aevalys;;[email protected];4001;FR67384260733;7 rue Copernic;75016;Paris;France;TANGRAM +woningen123;Aude Boesmans;01.02.2010;01.08.2011;Aude m'a dit que cette abonnement terminera en janvier/février 2012;;[email protected];400;;;;;;WO123 +Wooha sprl;Vincent Oury;05.02.2009;05.02.2013;;;[email protected];4000012;BE0884986032;Bd Ernest Solvay 489;4000;Liège;Belgique;WOOHA Added: trunk/import_doli/doc/fiche.csv =================================================================== --- trunk/import_doli/doc/fiche.csv (rev 0) +++ trunk/import_doli/doc/fiche.csv 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,9 @@ +Dubbel Win SA;Schiettecatte Patrick;01.02.2010;01.02.2013;;;[email protected];400;BE463141049;AVENUE LAVOISIER 13;1300;WAVRE;Belgique;PSCHIET +FRMJC;[email protected];01.06.2011;01.06.2012;PLUSIEURS DOSSIERS;03 80 45 02 86;[email protected];400;;22 RUE DU TIRE PESSEAU; 21000;DIJON;FRANCE;FRMJC +marcellin champagnat;Jean marc PE;01.06.2010;01.06.2012;Compte à fermer au 30/5/2012;063/23.51.50;[email protected];400;ASBL 896.993;33 rue de bastogne;6700;Arlon;Belgique;MARCECHAMP +Self Reliance;Pierre willot;15.01.2008;15.01.2013;;071.77.36.17;[email protected];4000009;BE0874.449.753;rue Haut Vent 34;5070;Fosses-La-Ville;Belgique;SR +SHONAGON FILM;Aude Boesmans;01.02.2010;31.12.2011;Abonnement terminé;;;400;;;;;;SHONAGON +SNETAP FSU;Henri COMBEAU;01.07.2010;01.07.2012;;;;400;;Rue de Vaugirard 251;75732;Paris;France;SNETAP +Tangram Finance;Philippe Leclerc;26.02.2011;01.04.2012;Abonnement Entreprise sur Aevalys;;[email protected];400;FR67384260733;7 rue Copernic;75016;Paris;France;TANGRAM +woningen123;Aude Boesmans;01.02.2010;01.08.2011;Aude m'a dit que cette abonnement terminera en janvier/février 2012;;[email protected];400;;;;;;WO123 +Wooha sprl;Vincent Oury;05.02.2009;05.02.2013;;;[email protected];4000012;BE0884986032;Bd Ernest Solvay 489;4000;Liège;Belgique;WOOHA Added: trunk/import_doli/doc/import-donnee-dolibarr test.csv =================================================================== --- trunk/import_doli/doc/import-donnee-dolibarr test.csv (rev 0) +++ trunk/import_doli/doc/import-donnee-dolibarr test.csv 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,5 @@ +1;"13.03.2012";"WOOHA";"achat de marchandises";;;;;; +1;"13.03.2012";"M1";"Marchandise 1";;3;1,62;9;0,06;28,62 +1;"13.03.2012";"M2";"Marchandise 2";;12;0,72;1;0,06;12,72 +2;"14.03.2012";"TANGRAM";"Facture n°121212121 : Electricté";;;;;; +2;"14.03.2012";"ELEC";"Électricté";;125;7,5;1;0,06;132,5 Added: trunk/import_doli/doc/import-donnee-dolibarr test.ods =================================================================== (Binary files differ) Property changes on: trunk/import_doli/doc/import-donnee-dolibarr test.ods ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/import_doli/doc/import-donnee-dolibarr.ods =================================================================== (Binary files differ) Property changes on: trunk/import_doli/doc/import-donnee-dolibarr.ods ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/import_doli/doc/import-donnee-fiche.ods =================================================================== (Binary files differ) Property changes on: trunk/import_doli/doc/import-donnee-fiche.ods ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/import_doli/impdol.js =================================================================== --- trunk/import_doli/impdol.js (rev 0) +++ trunk/import_doli/impdol.js 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,7 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + + +content[50]="le taux est compris entre 0 et 100"; \ No newline at end of file Added: trunk/import_doli/include/class_impdol_operation.php =================================================================== --- trunk/import_doli/include/class_impdol_operation.php (rev 0) +++ trunk/import_doli/include/class_impdol_operation.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,85 @@ +<?php + +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/** + * @file + * @brief + * + */ +require_once 'class_sql_impdol.php'; +class Impdol_Operation +{ + + function save_file() + { + if (trim($_FILES['csv_operation']['name']) == '') + { + alert('Pas de fichier donné'); + return -1; + } + $this->filename = tempnam($_ENV['TMP'], 'upload_'); + move_uploaded_file($_FILES["csv_operation"]["tmp_name"], $this->filename); + + $imp=new Impdol_Import_sql(); + $imp->setp('temp_file',$this->filename); + $imp->setp('send_file',$_FILES['csv_operation']['name']); + $imp->insert(); + $this->impid=$imp->getp("id"); + } + + function record() + { + $foperation= fopen($this->filename, 'r'); + $this->row_count = 0; + $max = 0; + while (($row = fgetcsv($foperation, 0, ";", '"')) !== false) + { + if ( count($row) != 10 ) + { + echo "Attention $row ne contient pas 10 colonnes"; + continue; + } + $r=new impdol_Operation_tmp_Sql(); + $r->setp('dolibarr',$row[0]); + $r->setp('date',$row[1]); + $r->setp('qcode',$row[2]); + $r->setp('desc',$row[3]); + $r->setp('pj',$row[4]); + $r->setp('amount_unit',$row[5]); + $r->setp('amount_vat',$row[6]); + $r->setp('rate',$row[8]); + $r->setp('amount_total',$row[9]); + $r->setp("import_id",$this->impid); + $r->insert(); + $this->row_count++; + } + echo "Nombre de lignes enregistrées : ".$this->row_count; + $import=new impdol_import_sql($this->impid); + $import->setp("nbrow",$this->row_count); + $import->update(); + } + + +} + +?> Added: trunk/import_doli/include/class_install_impdol.php =================================================================== --- trunk/import_doli/include/class_install_impdol.php (rev 0) +++ trunk/import_doli/include/class_install_impdol.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,57 @@ +<?php + +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/** + * @file + * @brief + * + */ +class install_impdol +{ + + function install($p_cn) + { + + $cn->exec_sql("create schema impdol"); + $cn->exec_sql(" + create table impdol.version ( + v_id bigint primary key, + v_date now(), + v_text text + ) + "); + $cn->exec_sql("insert into impdol.version(v_id,v_text", array(1, "Installation")); + $cn->exec_sql(' + CREATE TABLE impdol.parameter_tva + ( + pt_id serial NOT NULL, + tva_id bigint, + pt_rate numeric(20,4) DEFAULT 0, + CONSTRAINT parameter_tva_pkey PRIMARY KEY (pt_id ) + ) + '); + } + +} + +?> Added: trunk/import_doli/include/class_sql_impdol.php =================================================================== --- trunk/import_doli/include/class_sql_impdol.php (rev 0) +++ trunk/import_doli/include/class_sql_impdol.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,330 @@ +<?php + +class sql_impdol +{ + + function __construct($p_cn, $p_id = -1) + { + $this->cn = $p_cn; + $pk=$this->primary_key; + $this->$pk= $p_id; + + if ($p_id == -1) + { + /* Initialize an empty object */ + foreach ($this->name as $key ) + { + $this->$key= null; + } + $this->$pk= $p_id; + } + else + { + /* load it */ + $this->load(); + } + } + + public function getp($p_string) + { + if (array_key_exists( $p_string,$this->name)) + { + $idx = $this->name[$p_string]; + return $this->$idx; + } + else + throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant '.$p_string); + } + + public function setp($p_string, $p_value) + { + if (array_key_exists( $p_string,$this->name)) + { + $idx = $this->name[$p_string]; + $this->$idx = $p_value; + } + else + throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant '.$p_string); + } + + public function insert() + { + $this->verify(); + $sql = "insert into " . $this->table . " ( "; + $sep = ""; + $par = ""; + $idx = 1; + $array = array(); + foreach ($this->name as $key=>$value) + { + if (isset($this->default[$value]) && $this->default[$value] == "auto" && $this->$value ==null ) + continue; + if ( $value==$this->primary_key && $this->$value == -1 ) continue; + $sql.=$sep.$value; + switch ($this->type[$value]) + { + case "date": + $par .=$sep. 'to_date($' . $idx . ",'" . $this->date_format . "')" ; + break; + default: + $par .= $sep."$" . $idx ; + } + + $array[] = $this->$value; + $sep = ","; + $idx++; + } + $sql.=") values (" . $par . ") returning " . $this->primary_key; + $pk=$this->primary_key; + $this->$pk = $this->cn->get_value($sql, $array); + } + + public function delete() + { + $pk=$this->primary_key; + $sql = " delete from " . $this->table . " where " . $this->primary_key . "=" . sql_string($this->$pk); + $this->cn->exec_sql($sql); + } + + public function update() + { + $this->verify(); + $pk=$this->primary_key; + $sql = "update " . $this->table . " "; + $sep = ""; + $idx = 1; + $array = array(); + $set=" set "; + foreach ($this->name as $key=>$value) + { + if (isset($this->default[$value]) && $this->default[$value] == "auto" ) + continue; + switch ($this->type[$value]) + { + case "date": + $par =$value. '=to_date($' . $idx . ",'" . $this->date_format . "')" ; + break; + default: + $par = $value."= $" . $idx ; + } + $sql.=$sep." $set " . $par ; + $array[] = $this->$value; + $sep = ",";$set="";$idx++; + } + $sql.=" where " . $this->primary_key . " =" . $this->$pk; + $this->cn->exec_sql($sql, $array); + + } + + public function load() + { + $sql = " select "; + $sep="";$par=""; + + foreach ($this->name as $key) + { + + switch ($this->type[$key]) + { + case "date": + $sql .= $sep.'to_char(' . $key . ",'" . $this->date_format . "') as ".$key ; + break; + default: + $sql.=$sep.$key ; + } + $sep = ","; + } + $pk=$this->primary_key; + $sql.=" from ".$this->table; + $sql.=" where " . $this->primary_key . " = " . $this->$pk; + $result = $this->cn->get_array($sql); + if ($this->cn->count() == 0 ) { + $this->$pk=-1; + return; + } + + foreach ($result[0] as $key=>$value) { + $this->$key=$value; + } + } + + public function get_info() + { + return var_export($this, true); + } + + public function verify() + { + foreach($this->name as $key){ + if ( trim($this->$key)=='') $this->$key=null; + } + return 0; + } + public function from_array($p_array) + { + foreach ($this->name as $key=>$value) + { + if ( isset ($p_array[$value])) + { + $this->$value=$p_array[$value]; + } + } + } + public function next($ret,$i) { + global $cn; + $array=$this->cn->fetch_array($ret,$i); + $this->from_array($array); + } + +} + +class impdol_operation_sql extends sql_impdol +{ + + function __construct($p_id=-1) + { + $this->table = "impdol.operation"; + $this->primary_key = "o_id"; + + $this->name=array( + "id"=>"o_id", + "dolibarr"=>"o_doli", + "date"=>"o_date", + "qcode"=>"o_qcode", + "fiche"=>"f_id", + "desc"=>"o_label", + "pj"=>"o_pj", + "amount_unit"=>"amount_unit", + "amount_vat"=>"amount_vat", + "number_unit"=>"number_unit", + "rate"=>"vat_rate", + "amount_total"=>"amount_total", + "jrn_def_id"=>"jrn_def_id", + "o_message"=>"o_message", + "import_id"=>"i_id", + "status"=>"o_status" + + ); + + $this->type = array( + "o_id"=>"numeric", + "o_doli"=>"numeric", + "o_date"=>"date", + "o_qcode"=>"text", + "f_id"=>"numeric", + "o_label"=>"text", + "o_pj"=>"text", + "amount_unit"=>"numeric", + "amount_vat"=>"numeric", + "number_unit"=>"numeric", + "vat_rate"=>"numeric", + "amount_total"=>"numeric", + "jrn_def_id"=>"numeric", + "o_message"=>"text", + "i_id"=>"numeric", + "o_status"=>"text" + ); + + $this->default = array( + "o_id" => "auto", + ); + $this->date_format = "DD.MM.YYYY"; + global $cn; + + parent::__construct($cn,$p_id); + } + +} + +class impdol_operation_tmp_sql extends sql_impdol +{ + + function __construct($p_id=-1) + { + $this->table = "impdol.operation_tmp"; + $this->primary_key = "o_id"; + + $this->name=array( + "id"=>"o_id", + "dolibarr"=>"o_doli", + "date"=>"o_date", + "qcode"=>"o_qcode", + "fiche"=>"f_id", + "desc"=>"o_label", + "pj"=>"o_pj", + "amount_unit"=>"amount_unit", + "amount_vat"=>"amount_vat", + "number_unit"=>"number_unit", + "rate"=>"vat_rate", + "amount_total"=>"amount_total", + "jrn_def_id"=>"jrn_def_id", + "o_message"=>"o_message", + "import_id"=>"i_id", + "code"=>"o_result" + + ); + + $this->type = array( + "o_id"=>"numeric", + "o_doli"=>"text", + "o_date"=>"text", + "o_qcode"=>"text", + "f_id"=>"text", + "o_label"=>"text", + "o_pj"=>"text", + "amount_unit"=>"text", + "amount_vat"=>"text", + "number_unit"=>"text", + "vat_rate"=>"text", + "amount_total"=>"text", + "jrn_def_id"=>"text", + "o_message"=>"text", + "i_id"=>"numeric", + "o_result"=>'text' + ); + + $this->default = array( + "o_id" => "auto", + ); + $this->date_format = "DD.MM.YYYY"; + global $cn; + + parent::__construct($cn,$p_id); + } + +} + +class impdol_import_sql extends sql_impdol +{ + function __construct($p_id=-1) + { + $this->table = "impdol.import"; + $this->primary_key = "i_id"; + + $this->name=array( + "id"=>"i_id", + "send_file"=>"send_file", + "temp_file"=>"temp_file", + "date"=>"i_date", + "nbrow"=>"i_row" + ); + + $this->type = array( + "i_id"=>"numeric", + "send_file"=>"text", + "temp_file"=>"text", + "i_date"=>"date", + "i_row"=>"numeric" + ); + + $this->default = array( + "i_id" => "auto", + "i_date" => "auto" + ); + $this->date_format = "DD.MM.YYYY"; + global $cn; + + parent::__construct($cn,$p_id); + } +} +?> \ No newline at end of file Added: trunk/import_doli/include/imd_operation.inc.php =================================================================== --- trunk/import_doli/include/imd_operation.inc.php (rev 0) +++ trunk/import_doli/include/imd_operation.inc.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,59 @@ +<?php + +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/** + * @file + * @brief upload operation + * + */ +require_once 'class_impdol_operation.php'; + +// step 1, select a file +if ( ! isset ($_POST['upload']) && ! isset ($_POST['check']) && ! isset($_POST['transfer'])) +{ + require_once 'template/upload_operation.php'; + + exit(); +} +// step 2 save file into impdol.operation +if ( isset ($_POST['upload'])) +{ + // save the file + $io=new Impdol_Operation(); + $io->save_file(); + + // record the file into the table operation + $io->record(); + + // show the result + error + $io->check(); + $io->result(); + +} +// step 3, insert data into the target ledger +if ( isset ($_POST['transfer'])) +{ + +} + +?> Added: trunk/import_doli/include/imd_parameter.inc.php =================================================================== --- trunk/import_doli/include/imd_parameter.inc.php (rev 0) +++ trunk/import_doli/include/imd_parameter.inc.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,89 @@ +<?php + +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/** + * @file + * @brief matching between tva and rate + * + */ +global $cn; +if (isset($_POST['ftvaadd'])) +{ + extract($_POST); + try + { + if (isNumber($pt_rate) == 0) + throw new Exception("le taux n'est pas un nombre"); + if ($pt_rate < 0 || $pt_rate > 100) + throw new Exception("le taux est invalide"); + $tva = new Acc_Tva($cn, $tva_id); + if ($tva->load() == -1) + throw new Exception('Cette tva est invalide'); + $sql = "insert into impdol.parameter_tva(tva_id,pt_rate) values ($1,$2)"; + $cn->exec_sql($sql, array($_POST['tva_id'], $_POST['pt_rate'])); + } + catch (Exception $e) + { + alert($e->getMessage()); + } +} +if (isset($_POST['mod'])) +{ + extract ($_POST); + $aparm = $cn->get_array("select pt_id from impdol.parameter_tva"); + try + { + for ($i = 0; $i < count($aparm); $i++) + { + if (isset(${'tva_' . $aparm[$i]['pt_id']})) + { + $pt_rate = ${'rate' . $aparm[$i]['pt_id']}; + $tva_id = ${'tva_' . $aparm[$i]['pt_id']}; + if (isNumber($pt_rate) == 0) + throw new Exception("le taux n'est pas un nombre"); + if ($pt_rate < 0 || $pt_rate > 100) + throw new Exception("le taux est invalide"); + $tva = new Acc_Tva($cn, $tva_id); + if ($tva->load() == -1) + throw new Exception('Cette tva est invalide'); + $sql = "update impdol.parameter_tva set tva_id = $1, pt_rate = $2 where pt_id=$3"; + $cn->exec_sql($sql, array($tva_id, $pt_rate,$aparm[$i]['pt_id'])); + } + } + } + catch (Exception $e) + { + alert($e->getMessage()); + } +} +/** + * get data from database + */ +$atva = $cn->get_array("select * from impdol.parameter_tva order by pt_rate"); +require 'template/parameter_tva_add.php'; +echo '<form method="POST">'; +require 'template/parameter.php'; +echo HtmlInput::submit("mod", "Modification"); + +echo '</form>'; +?> Added: trunk/import_doli/include/template/parameter.php =================================================================== --- trunk/import_doli/include/template/parameter.php (rev 0) +++ trunk/import_doli/include/template/parameter.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,38 @@ + +<? + $bt=new IButton("but_tva_add"); + $bt->label="Ajout d'une correspondance"; + $bt->javascript=" $('dtvaadd').show()"; + echo $bt->input(); +?> + +<table class="result" style="width:60%;margin-left:20%"> + <tr> + <th>Fiche TVA</th> + <th>Taux correspondant <?=HtmlInput::infobulle(50)?></th> + </tr> + <?php + for ($i = 0; $i < count($atva); $i++): + ?> + <tr> + <td> + <?php + $wtva = new ITva_Popup("tva_" . $atva[$i]['pt_id']); + $wtva->value = $atva[$i]['tva_id']; + echo $wtva->input(); + ?> + </td> + <td> + <?php + $wrate = new INum('rate' . $atva[$i]['pt_id']); + $wrate->value=$atva[$i]['pt_rate']; + echo $wrate->input(); + ?> + </td> + </tr> + + + + <?php endfor;?> + +</table> Added: trunk/import_doli/include/template/parameter_tva_add.php =================================================================== --- trunk/import_doli/include/template/parameter_tva_add.php (rev 0) +++ trunk/import_doli/include/template/parameter_tva_add.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,61 @@ +<?php +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/** + * @file + * @brief add a match between tva and rate + * + */ +?> +<div id="dtvaadd" class="inner_box" style="display:none"> + <h2 class="info">Ajout d'un taux de tva</h2> + <form method="POST"> + + <table> + <tr> + <td> + TVA + </td> + <td> + <? $tva_id = new ITva_Popup('tva_id'); + echo $tva_id->input()?> + </td> + </tr> + <tr> + <td> + Taux dans le fichier <?= HtmlInput::infobulle(50)?> + </td> + <td> + <? $w = new INum('pt_rate');echo $w->input();?> + </td> + </tr> + </table> + <?= HtmlInput::submit("ftvaadd", "Ajout");?> + <? + $bt = new IButton("but_tva_close"); + $bt->label = "Fermer"; + $bt->javascript = " $('dtvaadd').hide()"; + echo $bt->input(); + ?> + </form> + +</div> \ No newline at end of file Added: trunk/import_doli/include/template/test_operation.php =================================================================== --- trunk/import_doli/include/template/test_operation.php (rev 0) +++ trunk/import_doli/include/template/test_operation.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,91 @@ + +<h2> +<?php +echo _('Importation de données'); +?> +</h2> + +<p>Pour importer des données, c'est-à-dire transformer des fichiers CSV (Valeur séparé par des virgules) en des fiches. Vous devez choisir, un fichier et donner une catégorie de fiche existante. Ensuite, il suffit d'indiquer quelles colonnes correspondent à quelle attribut. +</p> + +<form method="POST" > +<?=$hidden?> +<table> +<tr> +<td>Délimiteur </td> +<td> <? echo $_POST['rdelimiter']?></td> +</tr> +<tr> +<td>Fichier à charger</td><td> <? echo $_FILES['csv_file']['name']?></td> +</tr> +<tr> +<td>Catégorie de fiche</td><td> <? echo $file_cat;?></td> +</tr> +<tr> +<td>Encodage </td><td> <? echo $encoding?></td> +</tr> +<tr> +<td>Texte entouré par</td><td> <? echo $_POST['rsurround'];?></td> +</tr> +</table> +<? +foreach (array('rfichedef','rdelimiter','encodage') as $e) +{ + if ( isset($_POST[$e])) echo HtmlInput::hidden($e,$_POST[$e]); +} +echo HtmlInput::hidden('filename',$filename); + + echo HtmlInput::submit('record_import','Valider'); +?> +<input type="hidden" name="rsurround" value='<?=$_POST['rsurround']?>'> + + + +<? + global $cn; + ob_start(); + /** + * Open the file and parse it + */ +$fcard=fopen($filename,'r'); +$row_count=0; +$max=0; +while (($row=fgetcsv($fcard,0,$_POST['rdelimiter'],$_POST['rsurround'])) !== false) + { + $row_count++; + echo '<tr style="border:solid 1px black">'; + echo td($row_count); + $count_col=count($row); + $max=($count_col>$max)?$count_col:$max; + for ($i=0;$i<$count_col;$i++) + { + echo td($row[$i],'style="border:solid 1px black"'); + } + echo '</tr>'; + } +$table=ob_get_contents(); +ob_clean(); + + +echo '<table style="border:solid 1px black;width:100%"> +<tr>'; + +/** + *create widget column header + */ +$header=new ISelect('head_col[]'); + +$sql=sprintf('select ad_id,ad_text from jnt_fic_attr join attr_def using(ad_id) where fd_id=%d order by ad_text ',$_POST['rfichedef']); +$header->value=$cn->make_array($sql); +$header->value[]=array('value'=>-1,'label'=>'-- Non Utilisé --'); +$header->selected=-1; +echo th('Numéro de ligne'); +for ($i=0;$i<$max;$i++) + { + echo '<th>'.$header->input().'</th>'; + } +echo '</tr>'; +echo $table; +echo '</table>'; +echo '</form>'; +?> \ No newline at end of file Added: trunk/import_doli/include/template/upload_operation.php =================================================================== --- trunk/import_doli/include/template/upload_operation.php (rev 0) +++ trunk/import_doli/include/template/upload_operation.php 2012-03-28 23:57:15 UTC (rev 321) @@ -0,0 +1,45 @@ +<?php + +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* $Revision$ */ + +// Copyright Author Dany De Bontridder [email protected] + +/** + * @file + * @brief upload operation + * + */ +?> +<h2> +<?php +echo _('Importation des opération'); +?> +</h2> + +<form method="POST" enctype="multipart/form-data"> +<table> +<tr> +<tr> + <td>Fichier à charger</td><TD> <? $file = new IFile('csv_operation');echo $file->input()?></td> +</tr> +</table> +<? echo HtmlInput::submit('upload','Valider');?> + +</form> \ No newline at end of file Modified: trunk/import_doli/index.php =================================================================== --- trunk/import_doli/index.php 2012-03-25 20:12:50 UTC (rev 320) +++ trunk/import_doli/index.php 2012-03-28 23:57:15 UTC (rev 321) @@ -38,14 +38,14 @@ Extension::check_version(4600); // Javascript -/* ob_start(); - require_once('impdoli-javascript.js'); + ob_start(); + require_once('impdol.js'); $j=ob_get_contents(); ob_clean(); echo create_script($j); -*/ + $url='?'.dossier::get().'&plugin_code='.$_REQUEST['plugin_code']."&ac=".$_REQUEST['ac']; $array=array ( @@ -70,16 +70,16 @@ $default=0; } - if ($cn->exist_schema('import_dolibarr') == false) + if ($cn->exist_schema('impdol') == false) { - /*require_once('include/class_install_plugin.php'); + require_once('include/class_install_impdol.php'); - $iplugn=new Install_Plugin($cn); + $iplugn=new Install_Impdol($cn); $iplugn->install(); -*/ + } echo ShowItem($array,'H','mtitle','mtitle',$default,' style="width:80%;margin-left:10%"'); - +echo '<div class="content" style="padding:10">'; if ($default==1) { if ( ! isset($_REQUEST['sb'])) @@ -102,3 +102,14 @@ Import_Card::new_import(); } } +if ($default == 5) +{ + require_once('include/imd_parameter.inc.php'); + exit(); + +} +if ( $default== 2 ) +{ + require_once 'include/imd_operation.inc.php'; + exit(); +} --- PhpCompta est un logiciel de comptabilité libre en ligne (full web) Projet opensource http://www.phpcompta.eu _______________________________________________ Phpcompta est un logiciel libre de comptabilité en ligne (http://www.phpcompta.eu) Phpcompta-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
