示例#1
0
 public function save(Merchandise $merchandise)
 {
     if ($merchandise->getItem_id() !== null) {
         $this->update($merchandise);
     } else {
         $this->insert($merchandise);
     }
 }
示例#2
0
 public static function validate(Merchandise $merchandise)
 {
     $errors = array();
     if (!trim($merchandise->getItem_name())) {
         $errors[] = new Error('item_name', 'Name cannot be empty.');
     } elseif (!trim($merchandise->getItem_price())) {
         $errors[] = new Error('item_price', 'Price cannot be empty');
     } elseif (!trim($merchandise->getOriginal_url())) {
         $errors[] = new Error('original_url', 'URL cannot be empty');
     } elseif (!trim($merchandise->getImg_url())) {
         $errors[] = new Error('img_url', 'Image cannot be empty');
     } elseif (!trim($merchandise->getCompany_id())) {
         $errors[] = new Error('company_id', 'Company cannot be empty');
     }
     return $errors;
 }
示例#3
0
 public static function map(Merchandise $merchandise, array $properties)
 {
     if (array_key_exists('item_id', $properties)) {
         $merchandise->setItem_id((int) $properties['item_id']);
     }
     if (array_key_exists('item_name', $properties)) {
         $merchandise->setItem_name($properties['item_name']);
     }
     if (array_key_exists('item_price', $properties)) {
         $merchandise->setItem_price((double) $properties['item_price']);
     }
     if (array_key_exists('original_url', $properties)) {
         $merchandise->setOriginal_url($properties['original_url']);
     }
     if (array_key_exists('img_url', $properties)) {
         $merchandise->setImg_url($properties['img_url']);
     }
     if (array_key_exists('company_id', $properties)) {
         $merchandise->setCompany_id((int) $properties['company_id']);
     }
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMerchandises()
 {
     return $this->hasMany(Merchandise::className(), ['type' => 'id']);
 }
示例#5
0
				FICHA DE ENTRADA DE MERCANCIAS
			</td>
		</tr>
		<tr>
			<td style="border: 1px solid #555;"><b>Fecha</b></td>
			<td style="border: 1px solid #555;"><b>Materia prima</b></td>
			<td style="border: 1px solid #555;"><b>Proveedor</b></td>
			<td style="border: 1px solid #555;"><b>Lote / Albaran</b></td>
			<td style="border: 1px solid #555;"><b>Estado</b></td>
			<td style="border: 1px solid #555;"><b>Temperatura</b></td>
			<td style="border: 1px solid #555;"><b>Caducidad</b></td>
			<td style="border: 1px solid #555;"><b>Observaciones</b></td>
		</tr>
		
		<?php 
$modelMerchandise = Merchandise::model()->findAllByAttributes(array("UserID" => Yii::app()->user->ID));
foreach ($modelMerchandise as $Merchandise) {
    ?>
				<tr>
					<td><?php 
    echo $Merchandise->Date;
    ?>
</td>
					<td><?php 
    echo $Merchandise->raw->Name;
    ?>
</td>
					<td><?php 
    echo $Merchandise->provider->Name;
    ?>
</td>
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Merchandise::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }