Ejemplo n.º 1
0
 public static function registreError($ecnt_id, $descr)
 {
     /**
      * parbauda, vai jau nav pievienota kljuda
      */
     $search_attributes = ['ecer_ecnt_id' => $ecnt_id, 'ecer_descr' => $descr];
     if (EcerErrors::model()->findByAttributes($search_attributes)) {
         return false;
     }
     $ecer = new EcerErrors();
     $ecer->ecer_ecnt_id = $ecnt_id;
     $ecer->ecer_descr = $descr;
     return $ecer->save();
 }
Ejemplo n.º 2
0
 /**
  * Execute the action.
  *
  */
 public function run($args)
 {
     echo 'START ' . date("Y-m-d H:i:s") . PHP_EOL;
     include_once realpath(Yii::getPathOfAlias('edifact-parser')) . '/Parser.php';
     include_once realpath(Yii::getPathOfAlias('edifact-parser')) . '/Reader.php';
     include_once realpath(Yii::getPathOfAlias('edifact-parser')) . '/Analyser.php';
     if (empty($args)) {
         foreach (Yii::app()->params['terminal_pop3'] as $terminal => $pop3_settings) {
             echo 'Read terminal: ' . $terminal . PHP_EOL;
             $attacments = $this->readPop3Attachments($pop3_settings['host'], $pop3_settings['user'], $pop3_settings['password']);
             echo 'Found  ' . count($attacments) . ' attachments' . PHP_EOL;
             if ($attacments) {
                 $att = [];
                 foreach ($attacments as $attachment) {
                     $EdiReader = new EDI\Reader($attachment['data']);
                     $messageCount = $EdiReader->readEdiDataValue('UNZ', 1);
                     if ($messageCount != 1) {
                         $aM = EDI\Reader::splitMultiMessage($attachment['data']);
                         foreach ($aM as $a) {
                             $att[] = ['filename' => $attachment['filename'], 'data' => $a];
                         }
                         continue;
                     }
                     $att[] = $attachment;
                 }
                 echo 'Found  ' . count($att) . ' messages' . PHP_EOL;
                 foreach ($att as $attachment) {
                     $this->saveAttachment($attachment['filename'], $attachment['data']);
                 }
             }
             echo 'Finish Read terminal: ' . $terminal . PHP_EOL;
         }
         echo 'FINISH ' . date("Y-m-d H:i:s") . PHP_EOL;
         return true;
     }
     if ($args[0] == 'analyze') {
         $this->analyze($args[1]);
     }
     if ($args[0] == 'read_codes') {
         $this->codes_to_db();
     }
     if ($args[0] == 'read') {
         if (isset($args[1])) {
             $this->readEdiData($args[1]);
         } else {
             $all = Edifact::model()->findAll();
             foreach ($all as $edifact) {
                 $this->readEdiData($edifact->id);
             }
         }
     }
     if ($args[0] == '7days') {
         $count = EcerErrors::mark7DaysNoMoving();
         echo '7days no moving: ' . $count . PHP_EOL;
     }
 }
Ejemplo n.º 3
0
 public function beforeSave()
 {
     //nosaka garumu
     if (!empty($this->ecnt_iso_type)) {
         switch (substr($this->ecnt_iso_type, 0, 1)) {
             case '2':
                 $this->ecnt_length = EcntContainer::ECNT_LENGTH_20;
                 break;
             case '4':
                 $this->ecnt_length = EcntContainer::ECNT_LENGTH_40;
                 break;
             default:
                 $error[] = 'Nekorekts ISO TYPR:' . $this->ecnt_iso_type;
                 break;
         }
     }
     //sameklee procesing record
     if (empty($this->ecnt_ecpr_id) && $this->ecnt_operation != EcntContainer::ECNT_OPERATION_TRUCK_IN && $this->ecnt_operation != EcntContainer::ECNT_OPERATION_VESSEL_DISCHARGE) {
         $sql = "\n                SELECT \n                    ecpr_id \n                FROM\n                    ecnt_container \n                    INNER JOIN ecpr_container_procesing \n                      ON ecnt_ecpr_id = ecpr_id \n                      AND ecpr_start_ecnt_id = ecnt_id \n                WHERE ecnt_container_nr = :container\n                    AND ecpr_end_ecnt_id IS NULL \n                    AND ecnt_datetime < :datetime\n                ";
         $rawData = Yii::app()->db->createCommand($sql);
         $container = $this->ecnt_container_nr;
         $datetime = $this->ecnt_datetime;
         $rawData->bindParam(":container", $container, PDO::PARAM_STR);
         $rawData->bindParam(":datetime", $datetime, PDO::PARAM_STR);
         $ecpr_id = $rawData->queryScalar();
         if ($ecpr_id) {
             $this->ecnt_ecpr_id = $ecpr_id;
         }
     }
     //calc movment code
     if ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_VESSEL_DISCHARGE && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_FULL) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_DF;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_TRUCK_OUT && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_FULL) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_LD;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_TRUCK_IN && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_EMPTY) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_TE;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_TRUCK_OUT && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_EMPTY) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_LV;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_TRUCK_IN && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_FULL) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_TF;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_VESSEL_LOAD && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_FULL) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_VF;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_VESSEL_LOAD && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_EMPTY) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_VE;
     } elseif ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_VESSEL_DISCHARGE && $this->ecnt_statuss == EcntContainer::ECNT_STATUSS_EMPTY) {
         $this->ecnt_move_code = EcntContainer::ECNT_MOVE_CODE_DE;
     } else {
         $this->ecnt_move_code = NULL;
     }
     /**
      * search prev moving and analyse move code sqn
      */
     $this->ecnt_error = null;
     //    $this->ecnt_notes = '';
     if (!empty($this->ecnt_move_code) && $this->ecnt_move_code != EcntContainer::ECNT_MOVE_CODE_DF) {
         $prev_ecnt = $this->searchPrevContainer();
         if (!$prev_ecnt) {
             EcerErrors::registreError($this->ecnt_id, 'Can not find previous moving');
         } else {
             $sqn_rules = ['DF' => 'LD', 'LD' => 'TE', 'TE' => 'LV', 'LV' => 'TF', 'TF' => 'VF'];
             if (isset($sqn_rules[$prev_ecnt->ecnt_move_code]) && $sqn_rules[$prev_ecnt->ecnt_move_code] != $this->ecnt_move_code) {
                 $notes = 'Ilegal sequence: ' . $prev_ecnt->ecnt_move_code . '- ' . $this->ecnt_move_code;
                 EcerErrors::registreError($this->ecnt_id, $notes);
             }
         }
     }
     return parent::beforeSave();
 }
Ejemplo n.º 4
0
    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 = EcerErrors::model();
$this->widget('TbGridView', array('id' => 'ecer-errors-grid2', 'dataProvider' => $model->search($criteria_ecer_7days), 'template' => '{summary}{items}{pager}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'ecer_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//edifactdata/ecerErrors/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'ecer_status', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//edifactdata/ecerErrors/editableSaver'), 'source' => $model->getEnumFieldLabels('ecer_status')), 'filter' => $model->getEnumFieldLabels('ecer_status')), 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_container_nr'), array('name' => 'ecnt_datetime'), array('name' => 'ecnt_operation'), array('name' => 'ecnt_transport_id'), array('name' => 'ecnt_iso_type'), 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->ecer_ecnt_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip')))));
//}
Yii::endProfile('ecer_ecnt_id2.view.grid');
Yii::beginProfile('ecnt.view.grid');
$grid_error = '';
$grid_warning = '';
?>

<div class="table-header">
    <i class="icon-th-large"></i>
<?php 
echo Yii::t('EdifactDataModule.model', 'Empty containers');
?>
</div>
Ejemplo n.º 5
0
        <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)) {
        $model = new EcerErrors();
        $model->unsetAttributes();
        $model->ecer_ecnt_id = $modelMain->primaryKey;
        // render grid view
        $this->widget('TbGridView', array('id' => 'ecer-errors-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('name' => 'ecer_descr'), array('class' => 'editable.EditableColumn', 'name' => 'ecer_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//edifactdata/ecerErrors/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'ecer_status', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//edifactdata/ecerErrors/editableSaver'), 'source' => $model->getEnumFieldLabels('ecer_status')), 'filter' => $model->getEnumFieldLabels('ecer_status')))));
    }
    Yii::endProfile('ecer_ecnt_id.view.grid');
}
if (!$ajax || $ajax == 'ecnt-container-grid') {
    Yii::beginProfile('ecnt_edifact_id.view.grid');
    $grid_error = '';
    $grid_warning = '';
    ?>

    <div class="table-header">
        <?php 
Ejemplo n.º 6
0
 public function loadModel($id)
 {
     $m = EcerErrors::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;
 }