public function readEdiData($edi_id)
 {
     echo '$edi_id=' . $edi_id . PHP_EOL;
     $error = array();
     $edifact = Edifact::model()->FindByPk($edi_id);
     $parser = new EDI\Parser();
     $f = explode(PHP_EOL, $edifact->message);
     $parser->parse($f);
     $EdiReader = new ContainerReader($f);
     $dateTimePreparation = $EdiReader->readDateTimePreparation();
     $terminal = $EdiReader->readEdiDataValue('UNB', 2);
     $MessageType = $EdiReader->readUNHmessageType();
     $MessageCode = $EdiReader->readEdiDataValue('BGM', 1);
     if ($terminal == 'RIXBCT' || $terminal == 'LVRIXKRA') {
         if ($MessageType == 'COARRI') {
             //TDT        8067 Mode of transport, coded: codes
             //                '1' maritime transport
             //                '8' inland water transport
             $ModeOfTransport = $EdiReader->readEdiDataValue(['TDT', [1 => 20]], 3, 1);
             $container_count = $EdiReader->readEdiDataValue('CNT', 1, 1);
             if ($container_count == 1) {
                 $containers = [$EdiReader->getParsedFile()];
             } else {
                 $containers = $EdiReader->readGroups('NAD', 'EQD', 'NAD', 'CNT');
             }
             if ($container_count != count($containers)) {
                 $error[] = 'Mismatch contaier count. CNT=' . $container_count . ' groups=' . count($containers);
                 EcntContainer::saveEdiData(array(), $EdiReader, $error, $edifact);
                 return false;
             }
             foreach ($containers as $container) {
                 $error = [];
                 $ecnt_data = [];
                 $EdiReader->resetErrors();
                 //PARTY QUALIFIER
                 //CA Carrier
                 //(3126) Party undertaking or arranging transport of goods between named points.
                 $ecnt_data['ecnt_fwd'] = $EdiReader->readEdiDataValue(['NAD', ['1' => 'CA']], 2, 0);
                 //8051 TRANSPORT STAGE QUALIFIER:
                 //  '20' (main carriage)
                 // Read: 8028 CONVEYANCE REFERENCE NUMBER: the vessel operator's loading voyage number
                 $ecnt_data['ecnt_transport_id'] = $EdiReader->readEdiDataValue(['TDT', ['1' => 20]], 2);
                 //var_dump($container);
                 $ConEdiReader = new ContainerReader();
                 $ConEdiReader->setParsedFile($container);
                 $container_number = $ConEdiReader->readEdiDataValue('EQD', 2);
                 $ecnt_data['ecnt_edifact_id'] = $edifact->id;
                 $ecnt_data['ecnt_container_nr'] = $container_number;
                 $ecnt_data['ecnt_terminal'] = $terminal;
                 $ecnt_data['ecnt_message_type'] = $MessageType;
                 $ecnt_data['ecnt_iso_type'] = $ConEdiReader->readEdiDataValue('EQD', 3, 0);
                 //2005 Date/time/period qualifier: code
                 //‘203' Execution date
                 $ecnt_data['ecnt_datetime'] = $ConEdiReader->readEdiSegmentDTM(203);
                 //$LoadingLocationIdentification = $EdiReader->readEdiDataValue(['LOC',[1=>9]],2,0);
                 //$DischargingLocationIdentification = $ConEdiReader->readEdiDataValue(['LOC',[1=>11]],2,0);
                 if ($MessageCode == 270) {
                     $ecnt_data['ecnt_operation'] = EcntContainer::ECNT_OPERATION_VESSEL_LOAD;
                     $ecnt_data['ecnt_ib_carrier'] = 'TRUCK';
                 } elseif ($MessageCode == 98) {
                     $ecnt_data['ecnt_operation'] = EcntContainer::ECNT_OPERATION_VESSEL_DISCHARGE;
                     $ecnt_data['ecnt_ob_carrier'] = 'TRUCK';
                 } else {
                     $error[] = 'Neatrada operation - vessel load/unload!' . '/Loading:' . $LoadingLocationIdentification . '/Discharging:' . $DischargingLocationIdentification . '/MessageCode:' . $MessageCode;
                 }
                 $ecnt_data['ecnt_weight'] = $ConEdiReader->readEdiDataValue(['MEA', ['2' => 'G']], 3, 1);
                 $ecnt_data['ecnt_booking'] = $ConEdiReader->readEdiDataValue(['RFF', ['1.0' => 'BN']], 1, 1);
                 $ecnt_data['ecnt_statuss'] = $ConEdiReader->readFullEmpty();
                 EcntContainer::saveEdiData($ecnt_data, $EdiReader, $error, $edifact);
             }
             return;
         } elseif ($MessageType == 'CODECO') {
             //get count of containers
             $container_count = $EdiReader->readEdiDataValue('CNT', 1, 1);
             //get container group detais
             if ($container_count == 1) {
                 $containers = [$EdiReader->getParsedFile()];
             } else {
                 $containers = $EdiReader->readGroups('NAD', 'EQD', 'TDT', 'CNT');
             }
             if ($container_count != count($containers)) {
                 $error[] = 'Mismatch contaier count. CNT=' . $container_count . ' groups=' . count($containers);
                 EcntContainer::saveEdiData(array(), $EdiReader, $error, $edifact);
                 return false;
             }
             //LOC Place of loading
             // 9 - [3334] Seaport, airport, freight terminal,
             //              rail station or other place at which the goods (cargo)
             //              are loaded on to the means of transport being used for their carriage.
             //    TRUCK IN
             //11 - Place of discharge
             //      [3392] Seaport, airport, freight terminal, rail station or other
             //      place at which goods are unloaded from the means of transport
             //      having been used for their carriage.
             // TRUCK OUT
             $LocationFunctionPlaceLoading = $EdiReader->readEdiDataValue(['LOC', [1 => 9]], 2);
             $LocationFunctionPlaceDischarge = $EdiReader->readEdiDataValue(['LOC', [1 => 11]], 2);
             $LocationFunctionKS = $EdiReader->readEdiDataValue(['LOC', [1 => 165]], 2);
             if (!empty($LocationFunctionPlaceLoading)) {
                 $ecnt_operation = EcntContainer::ECNT_OPERATION_TRUCK_IN;
             } elseif (!empty($LocationFunctionPlaceDischarge)) {
                 $ecnt_operation = EcntContainer::ECNT_OPERATION_TRUCK_OUT;
             } elseif (!empty($LocationFunctionKS)) {
                 $ecnt_operation = EcntContainer::ECNT_OPERATION_TRUCK_OUT;
             } else {
                 $error[] = 'Neatrada operation - truck in/out';
             }
             //PARTY QUALIFIER
             //CF Container operator/lessee
             // Party to whom the possession of specified property (e.g. container) has been conveyed for a period of time in return for rental payments.
             $ecnt_fwd = $EdiReader->readEdiDataValue(['NAD', ['1' => 'CF']], 2);
             //process all containers
             foreach ($containers as $container) {
                 $error = [];
                 $EdiReader->resetErrors();
                 $ConEdiReader = new ContainerReader();
                 $ConEdiReader->setParsedFile($container);
                 $ecnt_data = [];
                 $ecnt_data['ecnt_terminal'] = $terminal;
                 $ecnt_data['ecnt_container_nr'] = $ConEdiReader->readEdiDataValue('EQD', 2);
                 $ecnt_data['ecnt_iso_type'] = $ConEdiReader->readEdiDataValue('EQD', 3, 0);
                 $ecnt_data['ecnt_message_type'] = $MessageType;
                 $ecnt_data['ecnt_operation'] = $ecnt_operation;
                 $ecnt_data['ecnt_fwd'] = $ecnt_fwd;
                 //2005 Date/time/period qualifier: code
                 // 7 - efective datetime
                 $ecnt_data['ecnt_datetime'] = $ConEdiReader->readEdiSegmentDTM(7);
                 $ecnt_data['ecnt_transport_id'] = $ConEdiReader->readTDTtransportIdentification(1);
                 if (!empty($ecnt_data['ecnt_transport_id'])) {
                     $ecnt_data['ecnt_ib_carrier'] = 'TRUCK';
                 }
                 $ecnt_data['ecnt_statuss'] = $ConEdiReader->readFullEmpty();
                 EcntContainer::saveEdiData($ecnt_data, $EdiReader, $error, $edifact);
             }
             return;
         } else {
             $error[] = 'Unknown message type:' . $MessageType;
             EcntContainer::saveEdiData(array(), $EdiReader, $error, $edifact);
             return;
         }
     } elseif ($terminal == 'RIXCT') {
         if ($MessageType == 'COARRI') {
             $ecnt_data = [];
             $ecnt_data['ecnt_terminal'] = $terminal;
             $ecnt_data['ecnt_message_type'] = $MessageType;
             $ecnt_data['ecnt_fwd'] = $EdiReader->readEdiDataValue(['NAD', ['1' => 'CA']], 2, 0);
             $ecnt_data['ecnt_transport_id'] = $EdiReader->readEdiDataValue(['TDT', ['1' => 20]], 2);
             $ecnt_data['ecnt_edifact_id'] = $edifact->id;
             $ecnt_data['ecnt_container_nr'] = $EdiReader->readEdiDataValue('EQD', 2);
             $ecnt_data['ecnt_iso_type'] = $EdiReader->readEdiDataValue('EQD', 3, 0);
             $ecnt_data['ecnt_datetime'] = $EdiReader->readEdiSegmentDTM(203);
             //2005 Date/time/period qualifier: code
             //‘203' Execution date
             $ecnt_data['ecnt_datetime'] = $EdiReader->readEdiSegmentDTM(203);
             if ($MessageCode == 270) {
                 $ecnt_data['ecnt_operation'] = EcntContainer::ECNT_OPERATION_VESSEL_LOAD;
                 $ecnt_data['ecnt_ib_carrier'] = 'TRUCK';
             } elseif ($MessageCode == 98) {
                 $ecnt_data['ecnt_operation'] = EcntContainer::ECNT_OPERATION_VESSEL_DISCHARGE;
                 $ecnt_data['ecnt_ob_carrier'] = 'TRUCK';
             } else {
                 $error[] = 'Neatrada operation - vessel load/unload!' . '/Loading:' . $LoadingLocationIdentification . '/Discharging:' . $DischargingLocationIdentification . '/MessageCode:' . $MessageCode;
             }
             $ecnt_data['ecnt_weight'] = $EdiReader->readEdiDataValue(['MEA', ['2' => 'G']], 3, 1);
             $ecnt_data['ecnt_statuss'] = $EdiReader->readFullEmpty();
             EcntContainer::saveEdiData($ecnt_data, $EdiReader, $error, $edifact);
             return true;
         } elseif ($MessageType == 'CODECO') {
             $ecnt_data = [];
             $ecnt_data['ecnt_terminal'] = $terminal;
             $ecnt_data['ecnt_message_type'] = $MessageType;
             $ecnt_data['ecnt_container_nr'] = $EdiReader->readEdiDataValue('EQD', 2);
             $ecnt_data['ecnt_iso_type'] = $EdiReader->readEdiDataValue('EQD', 3, 0);
             $ecnt_data['ecnt_fwd'] = $EdiReader->readEdiDataValue(['NAD', ['1' => 'CF']], 2);
             // 1001 Document name code
             $DocumentNameCode = $EdiReader->readEdiDataValue('BGM', 1);
             if ($DocumentNameCode == 34) {
                 $ecnt_data['ecnt_operation'] = EcntContainer::ECNT_OPERATION_TRUCK_IN;
             } elseif ($DocumentNameCode == 36) {
                 $ecnt_data['ecnt_operation'] = EcntContainer::ECNT_OPERATION_TRUCK_OUT;
             } else {
                 $error[] = 'Neatrada operation - truck in/out';
             }
             $ecnt_data['ecnt_statuss'] = $EdiReader->readFullEmpty();
             //Effective from date/time
             $ecnt_data['ecnt_datetime'] = $EdiReader->readEdiSegmentDTM('181');
             $ecnt_data['ecnt_transport_id'] = $EdiReader->readEdiDataValue(['TDT', ['1' => '1']], 8, 0);
             if (!empty($ecnt_data['ecnt_transport_id'])) {
                 $ecnt_data['ecnt_ib_carrier'] = 'TRUCK';
             }
             $ecnt_data['ecnt_weight'] = $EdiReader->readEdiDataValue(['MEA', ['2' => 'AAE']], 3, 1);
             $ecnt_data['ecnt_booking'] = $EdiReader->readEdiDataValue(['RFF', ['1.0' => 'BN']], 1, 1);
             EcntContainer::saveEdiData($ecnt_data, $EdiReader, $error, $edifact);
             return true;
         } else {
             $error[] = 'Unknown message type:' . $MessageType;
             EcntContainer::saveEdiData(array(), $EdiReader, $error, $edifact);
             return true;
         }
     }
     $error[] = 'Unrecognised message';
     EcntContainer::saveEdiData(array(), $EdiReader, $error, $edifact);
     return false;
 }
示例#2
0
 public function actionDay()
 {
     $this->menu_route = "edifactdata/Report/Day";
     $report_date = Yii::app()->request->getPost('report_date');
     $excel = Yii::app()->request->getPost('excel');
     if (!$report_date) {
         $report_date = date('Y.m.d');
     }
     $data = EcntContainer::reportDay($report_date);
     if (empty($excel)) {
         $this->render('day', array('report_date' => $report_date, 'data' => $data));
     } else {
         $this->render('day_xls', array('report_date' => $report_date, 'data' => $data));
     }
 }
示例#3
0
 public function searchPrevContainer()
 {
     $criteria = new CDbCriteria();
     //$criteria->compare('t.ecnt_container_nr', $this->ecnt_container_nr);
     $criteria->condition = "ecnt_datetime < '" . $this->ecnt_datetime . "' and t.ecnt_container_nr ='" . $this->ecnt_container_nr . "'";
     $criteria->order = "ecnt_datetime DESC";
     $criteria->limit = 1;
     return EcntContainer::model()->find($criteria);
 }
示例#4
0
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), EcntContainer::model()->attributeLabels());
 }
示例#5
0
<div class="table-header">
    <i class="icon-road"></i>
<?php 
echo Yii::t('EdifactDataModule.model', 'On The Way');
?>
</div>

    <?php 
if (!empty($grid_error)) {
    ?>
    <div class="alert alert-error"><?php 
    echo $grid_error;
    ?>
</div>
    <?php 
}
if (!empty($grid_warning)) {
    ?>
    <div class="alert alert-warning"><?php 
    echo $grid_warning;
    ?>
</div>
    <?php 
}
//if (!empty($modelMain->ecerErrors)) {
// render grid view
$model = EcntContainer::model();
$this->widget('TbGridView', array('id' => 'ecnt-way-grid', 'dataProvider' => $model->searchOnTheWay(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('name' => 'ecnt_terminal', 'type' => 'raw', 'value' => 'Chtml::tag("span" , array("class" => $data->getTerminalClass() ), $data->ecnt_terminal)'), array('name' => 'ecnt_transport_id'), array('name' => 'ecnt_container_nr'), array('name' => 'ecnt_datetime'), array('name' => 'ecnt_move_code', 'value' => '$data->getEnumColumnLabel("ecnt_move_code")'), array('name' => 'ecnt_iso_type'), array('class' => 'editable.EditableColumn', 'name' => 'ecnt_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('/edifactdata/ecntContainer/editableSaver'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'TRUE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'FALSE')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("ecntContainer/view", array("ecnt_id" => $data->ecnt_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip')))));
//}
Yii::endProfile('ecnt_on_the_way.view.grid');
 public function loadModel($id)
 {
     $m = EcntContainer::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('EdifactDataModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }
    <div class="table-header">
        <?php 
    echo Yii::t('EdifactDataModule.model', 'Container Moving');
    ?>
    </div>

    <?php 
    if (!empty($grid_error)) {
        ?>
        <div class="alert alert-error"><?php 
        echo $grid_error;
        ?>
</div>
        <?php 
    }
    if (!empty($grid_warning)) {
        ?>
        <div class="alert alert-warning"><?php 
        echo $grid_warning;
        ?>
</div>
        <?php 
    }
    if (!empty($modelMain->ecntContainers)) {
        $model = new EcntContainer();
        $model->ecnt_ecpr_id = $modelMain->primaryKey;
        // render grid view
        $this->widget('TbGridView', array('id' => 'ecnt-container-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('name' => 'ecnt_message_type'), array('name' => 'ecnt_datetime'), array('name' => 'ecnt_operation'), array('name' => 'ecnt_transport_id'), array('name' => 'ecnt_iso_type'), array('name' => 'ecnt_ib_carrier'), array('name' => 'ecnt_ob_carrier'), array('name' => 'ecnt_weight', 'htmlOptions' => array('class' => 'numeric-column')), array('name' => 'ecnt_line'), array('name' => 'ecnt_fwd'), array('name' => 'ecnt_booking'), array('name' => 'ecnt_eu_status', 'filter' => $model->getEnumFieldLabels('ecnt_eu_status')), array('name' => 'ecnt_imo_code'), array('class' => 'editable.EditableColumn', 'name' => 'ecnt_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//edifactdata/ecntContainer/editableSaver')), 'footer' => 'Total:', 'footerHtmlOptions' => array('class' => 'total-row')), array('name' => 'ecnt_action_amt', 'htmlOptions' => array('class' => 'numeric-column'), 'footer' => EcntContainer::getContainerActionAmtTotal($modelMain->ecpr_id), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('name' => 'ecnt_action_calc_notes'), array('name' => 'ecnt_time_amt', 'htmlOptions' => array('class' => 'numeric-column'), 'footer' => EcntContainer::getContainerTimeAmtTotal($modelMain->ecpr_id), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('name' => 'ecnt_time_calc_notes'))));
    }
    Yii::endProfile('ecnt_ecpr_id.view.grid');
}
    <div class="table-header">
        <?php 
    echo Yii::t('EdifactDataModule.model', 'Ecnt Container');
    ?>
    </div>

    <?php 
    if (!empty($grid_error)) {
        ?>
        <div class="alert alert-error"><?php 
        echo $grid_error;
        ?>
</div>
        <?php 
    }
    if (!empty($grid_warning)) {
        ?>
        <div class="alert alert-warning"><?php 
        echo $grid_warning;
        ?>
</div>
        <?php 
    }
    $model = new EcntContainer();
    $model->unsetAttributes();
    $model->ecnt_container_nr = $modelMain->ecnt_container_nr;
    // render grid view
    $this->widget('TbGridView', array('id' => 'ecnt-container-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('name' => 'ecnt_terminal', 'type' => 'raw', 'value' => 'Chtml::tag("span" , array("class" => $data->getTerminalClass() ), $data->ecnt_terminal)'), array('name' => 'ecnt_move_code'), array('name' => 'ecnt_datetime'), array('name' => 'ecnt_operation'), array('name' => 'ecnt_transport_id'), array('name' => 'ecnt_statuss'), array('class' => 'editable.EditableColumn', 'name' => 'ecnt_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//edifactdata/ecntContainer/editableSaver'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'TRUE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'FALSE')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("", array("ecnt_id" => $data->ecnt_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip')))));
    Yii::endProfile('ecnt_edifact_id.view.grid');
}