public function from_array($p_array)
 {
     extract($p_array);
     $ret = array();
     $ix = 0;
     $found = 0;
     foreach ($p_array as $r) {
         if (isset(${'form' . $ix}) && isset(${'text' . $ix})) {
             $obj = new Acc_Report_Row(${'text' . $ix}, ${'form' . $ix});
             if (isset(${'pos' . $ix}) && isNumber(${'pos' . $ix}) == 1) {
                 $obj->set_parameter("position", ${'pos' . $ix});
             } else {
                 $obj->set_parameter("position", $found);
                 $found++;
             }
             $obj->fo_id = 0;
             $obj->fo_fr_id = $this->fo_fr_id;
             $obj->db = $this->db;
             $ret[] = clone $obj;
         }
         $ix++;
     }
     return $ret;
 }
示例#2
0
 function upload()
 {
     if (empty($_FILES)) {
         return;
     }
     if (strlen(trim($_FILES['report']['tmp_name'])) == 0) {
         alert("Nom de fichier est vide");
         return;
     }
     $file_report = tempnam('tmp', 'file_report');
     if (move_uploaded_file($_FILES['report']['tmp_name'], $file_report)) {
         // File is uploaded now we can try to parse it
         $file = fopen($file_report, 'r');
         $data = fgetcsv($file);
         if (empty($data)) {
             return;
         }
         $this->name = $data[0];
         $array = array();
         while ($data = fgetcsv($file)) {
             $obj = new Acc_Report_Row();
             $obj->set_parameter("name", $data[0]);
             $obj->set_parameter("id", 0);
             $obj->set_parameter("position", $data[1]);
             $obj->set_parameter("formula", $data[2]);
             $obj->set_parameter('database', $this->db);
             $obj->set_parameter('form_id', 0);
             $array[] = clone $obj;
         }
         $this->aAcc_Report_row = $array;
         $this->insert();
     }
 }