Esempio n. 1
0
 public function actionOceanTrade()
 {
     $shipper = new Shipper();
     if (isset($_GET['shipperId'])) {
         $shipperId = $_GET['shipperId'];
         $shipper->id = $shipperId;
     }
     if (isset($_POST['Shipper'])) {
         // CVarDumper::dump($_POST, 4, 1);
         $shipperId = $_POST['Shipper']['id'];
         foreach ($_POST['ShippingPrice'] as $portFromId => $data) {
             $shippingPrice = ShippingPrice::model()->find(array('condition' => "shipperId = {$shipperId} AND portFromId = {$portFromId}"));
             if (!$shippingPrice) {
                 $shippingPrice = new ShippingPrice();
                 $shippingPrice->shipperId = $shipperId;
                 $shippingPrice->portFromId = $portFromId;
             }
             $shippingPrice->price20ft = $data['20ft'];
             $shippingPrice->price40ft = $data['40ft'];
             $shippingPrice->price40hc = $data['40hc'];
             $shippingPrice->note = $data['note'];
             $shippingPrice->date = Helpers::formateDateToDb($data['date']);
             $shippingPrice->save(false);
         }
         Yii::app()->user->setFlash('success', 'Data updated');
     }
     $this->render('oceanTrade', array('shipper' => $shipper));
 }
Esempio n. 2
0
			</thead>
			<tbody>
				<?php 
$ports = PortFrom::model()->findAll(array('order' => 'name ASC'));
?>
				<?php 
if ($shipper->id) {
    foreach ($ports as $port) {
        ?>
				<tr>
					<?php 
        $sp = ShippingPrice::model()->find(array('condition' => "shipperId = {$shipper->id} AND portFromId = {$port->id}"));
        ?>
					<?php 
        if (!$sp) {
            $sp = new ShippingPrice();
        }
        ?>
					<td><?php 
        echo $port->name;
        ?>
</td>
					<td><input name="ShippingPrice[<?php 
        echo $port->id;
        ?>
][20ft]" type="text" class="smallinput" value="<?php 
        echo $sp->price20ft;
        ?>
"/></td>
					<td><input name="ShippingPrice[<?php 
        echo $port->id;