public function testShouldDeleteAllCorrectly()
 {
     $this->Item->deleteAll(['Item.id' => [1, 3]]);
     $this->assertEmpty($this->Item->find('all'));
     $this->Item->includeDeletedRecords();
     $item = $this->Item->read(null, 1);
     $this->assertEqual($item['Item']['description'], ItemFixture::DESCR_DELETED);
 }
<p class="form-title">Registro de Nuevo Lote</p>
<?php 
if (!Forms::checkPermission(FORM_LOT_NEW)) {
    return;
}
require_once 'inc/class.item.php';
require_once 'inc/class.store.php';
$db = Database::getInstance();
$itemid = isset($_GET['item']) && is_numeric($_GET['item']) ? $_GET['item'] : "";
$storeid = isset($_GET['store']) && is_numeric($_GET['store']) ? $_GET['store'] : "";
$item = new Item();
$store = new Store();
if ($itemid) {
    $item->read($itemid);
}
if ($storeid) {
    $store->read($storeid);
}
include 'inc/widget/error.php';
?>

<form action="" method="post">
	<table class="form">
	<tr>
		<td class="label">Nombre:</td>
		<td>
			<?php 
if ($itemid) {
    echo "<input type='hidden' name='itemid' value='{$itemid}'/><span>{$item->name}, {$item->type}</span>";
} else {
    $items = Item::getAll("name", "");
<p class="form-title">Detalle de Lote</p>
<?php 
if (!Forms::checkPermission(FORM_LOT_EDIT)) {
    return;
}
require_once 'inc/class.item.php';
require_once 'inc/class.store.php';
require_once 'inc/class.lot.php';
require_once 'inc/class.formatter.php';
$lot = new Lot();
$item = new Item();
$store = new Store();
$lotid = isset($_GET['lot']) && is_numeric($_GET['lot']) ? $_GET['lot'] : 0;
if ($lot->read($lotid)) {
    $item->read($lot->itemid);
    $store->read($lot->storeid);
}
include 'inc/widget/error.php';
?>
<form method="post">
	<table class="form">
	<tr>
		<td class="label">Lote Nro.:</td>
		<td><?php 
echo $lot->id;
?>
</td>
	</tr>
	<tr>
		<td class="label">Producto:</td>
		<td><?php 
Example #4
0
 function insert_item_to_drupal($item_id)
 {
     // set HTTP_HOST or drupal will refuse to bootstrap
     $_SERVER['HTTP_HOST'] = 'zl-apps';
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
     drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
     $item = new Item();
     $item_detail = $item->read(null, $item_id);
     $item_nid = null;
     $query = new EntityFieldQuery();
     $entities = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'items')->propertyCondition('status', 1)->fieldCondition('field_item_id', 'value', $item_detail['Item']['id'], '=')->execute();
     if (!empty($entities)) {
         foreach ($entities['node'] as $nid => $value) {
             $item_nid = $nid;
             break;
             // no need to loop more even if there is multiple (it is supposed to be unique
         }
     }
     $node = null;
     if (is_null($item_nid)) {
         $node = new stdClass();
         $node->language = LANGUAGE_NONE;
     } else {
         $node = node_load($item_nid);
     }
     $node->type = 'items';
     node_object_prepare($node);
     $node->title = $item_detail['Item']['item_title'];
     $node->field_item_id[$node->language][0]['value'] = $item_detail['Item']['id'];
     $node->field_item_number[$node->language][0]['value'] = $item_detail['Item']['number'];
     $node->field_item_group[$node->language][0]['value'] = $item_detail['Item']['item_group'];
     $node->field_item_width[$node->language][0]['value'] = $item_detail['Item']['width'];
     $node->field_item_length[$node->language][0]['value'] = $item_detail['Item']['length'];
     $node->field_item_price[$node->language][0]['value'] = $item_detail['Item']['price'];
     $node->field_item_description[$node->language][0]['value'] = $item_detail['Item']['description'];
     $node->sell_price = $item_detail['Item']['price'];
     $node->model = $item_detail['Item']['number'];
     $node->shippable = 1;
     $path = 'item/' . $node->title;
     $node->path = array('alias' => $path);
     node_save($node);
 }