示例#1
0
 public function openfrmt($line)
 {
     $accs = '';
     //get all fields (b110) sort by id
     $criteria = new CDbCriteria();
     $criteria->condition = "type_id = :type_id";
     $criteria->params = array(':type_id' => "B110");
     $fields = OpenFormat::model()->findAll($criteria);
     //loop strfgy
     foreach ($fields as $field) {
         $accs .= $this->openfrmtFieldStr($field, $line);
     }
     return $accs . "\r\n";
 }
示例#2
0
 public function readLine($line, $type)
 {
     $fields = Yii::app()->cache->get("Openformat." . $type);
     if ($fields === false) {
         $criteria = new CDbCriteria();
         $criteria->condition = "type_id = :type_id";
         $criteria->params = array(':type_id' => $type);
         $fields = OpenFormat::model()->findAll($criteria);
         Yii::app()->cache->set("Openformat." . $type, $fields, 600);
         Yii::log("Openformat" . $type . ' saved', 'info', 'app');
     }
     $pos = 0;
     $encoding = "utf-8";
     foreach ($fields as $field) {
         $str = mb_substr($line, $pos, $field->size, $encoding);
         //echo "$pos,";
         $pos += $field->size;
         //echo "$str,";
         //Yii::log($field->id."(".$pos.",".$field->size."):".$str,'info','app');
         $this->openfrmtFieldValue($field, $str);
     }
     //Yii::app()->end();
     //echo "****************************<br />\n";
     return true;
 }
示例#3
0
 public function z900($line, $id, $count)
 {
     $rec = '';
     //get all fields (b110) sort by id
     $criteria = new CDbCriteria();
     $criteria->condition = "type_id = :type_id";
     $criteria->params = array(':type_id' => "Z900");
     $fields = OpenFormat::model()->findAll($criteria);
     //loop strfgy
     foreach ($fields as $field) {
         if ($field->id == 1153) {
             $rec .= sprintf("%015d", $id);
             continue;
         }
         if ($field->id == 1155) {
             $rec .= sprintf("%015d", $count);
             continue;
         }
         $rec .= $this->openfrmtFieldStr($field, $line);
     }
     return $rec . "\r\n";
 }