<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Customer
 *
 * @author abrah_000
 */
class InventoryDevDetails extends ActiveRecord\Model {

    static $connection = 'pesaje';
    static $table_name = 'inventory_return_details';
    static $primary_key = 'id';
	
	static function GetPistol($dev_num,$co_art,$lote){
		$sql = "SELECT
	ISNULL(SUM(ird.packageweight),0) kg
FROM inventory_return_details ird
WHERE ird.dev_num = ?
AND ird.co_art = ?
AND ird.lote = ? ";
	return self::find_by_sql($sql,array($dev_num,$co_art,$lote))[0]->kg;
	}
	
static function NewInsert($data){
		$sql ="
INSERT INTO [dbo].[inventory_return_details]
           ([dev_num]
           ,[co_art]
           ,[serie]
           ,[lote]
           ,[box]
           ,[pallete]
           ,[packagecode]
           ,[packageweight])
     VALUES
           (?
           ,?
           ,?
           ,?
           ,?
           ,?
           ,?
           ,?)
"; 
			$pdo = self::connection()->connection;
			$Exe = $pdo->prepare($sql);
			return $Exe->execute(array($data['dev_num'],$data['co_art'],$data['serie'],$data['lote'],$data['box'],$data['pallete'],$data['packagecode'],$data['packageweight']));
		   
	}

}
