本文整理汇总了PHP中Inventory::movement_last_row方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::movement_last_row方法的具体用法?PHP Inventory::movement_last_row怎么用?PHP Inventory::movement_last_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::movement_last_row方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: take
/**
* take creates the form to take an inventoryitem from somebody else
*
* @param int $did entry-id for the inventoryitem
* @return string html-string with the form
*/
private function take($did)
{
// check rights
if (Rights::check_rights($did, 'inventory')) {
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.InventoryView#page#caption#take'));
// get db-object
$db = Db::newDb();
// get inventory-object
$inventory = new Inventory($did);
// check owned
if ($inventory->get_owned() == 'given') {
// smarty-template
$sT = new JudoIntranetSmarty();
// prepare return
$return = '';
// get preset
$preset = $inventory->get_preset();
// get fields
$fields = $preset->get_fields();
// add headline
$sT->assign('caption', parent::lang('class.InventoryView#take#page#headline') . ': ' . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
// add take from
$movements = Inventory::movement_last_row($db, $inventory->get_id(), 'user_id', 2);
$user = new User();
$user->change_user($movements[1], false, 'id');
$sT->assign('takefrom', parent::lang('class.InventoryView#take#page#TakeFrom') . ': ' . $user->get_userinfo('name'));
// add accessory info
$sT->assign('accessoryinfo', parent::lang('class.InventoryView#take#page#accessory.required'));
// formular
$form = new HTML_QuickForm2('inventory_take', 'post', array('name' => 'inventory_take', 'action' => 'inventory.php?id=take&did=' . $this->get('did')));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.InventoryView#entry#form#requiredNote'));
// generate field-quickform and add to form
foreach ($fields as $field) {
// check if given
if ($inventory->movement_last_accessories($field) === true || $field->get_type() == 'text') {
// generate quickform
$field->read_quickform();
} else {
// generate quickform
$field->read_quickform(array('disabled' => 'disabled'));
}
// add to form
$form->appendChild($field->get_quickform());
}
// submit-button
$form->addSubmit('submit', array('value' => parent::lang('class.InventoryView#take#form#submitButton')));
// validate
if ($form->validate()) {
// values
$values = $form->getValue();
// write to db
$insert_id = $this->movement_to_db('taken', $inventory->get_id(), $_SESSION['user']->userid());
// accessory to db
$this->values_to_db($insert_id, $fields, $values);
// headline
$sT->assign('action', $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ') ' . parent::lang('class.InventoryView#take#page#headline.taken'));
// accessory
$sT->assign('accessoryaction', parent::lang('class.InventoryView#take#page#accessory.taken'));
// walk through fields
$data = array();
foreach ($fields as $field) {
// check value
if (isset($values['inventory-' . $field->get_id()])) {
$field_value = $values['inventory-' . $field->get_id()];
} else {
$field_value = 0;
}
// return field and value as HTML
$field->value($field_value);
$data[] = $field->value_to_html();
}
$sT->assign('form', '');
$sT->assign('data', $data);
} else {
$sT->assign('form', $form->render($renderer));
}
// return
return $sT->fetch('smarty.inventory.takegive.tpl');
} else {
// error
$errno = $GLOBALS['Error']->error_raised('NotGivenTo', $this->get('id'), $did);
$GLOBALS['Error']->handle_error($errno);
return $GLOBALS['Error']->to_html($errno);
}
} else {
// error
$errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $did);
$GLOBALS['Error']->handle_error($errno);
return $GLOBALS['Error']->to_html($errno);
}
}
示例2: movement_last_values
/**
* movement_last_values returns an array containing the field values
* of the last movement
*
* @return array array contains tht field values of the last movement
*/
public function movement_last_values()
{
// get db-object
$db = Db::newDb();
// get last movements
$id = Inventory::movement_last_row($db, $this->get_id(), 'id', 2);
// prepare sql-statement
$sql = "SELECT v.field_id,v.value\n\t\t\t\tFROM value AS v\n\t\t\t\tWHERE table_name = 'inventory_movement'\n\t\t\t\tAND table_id = " . $id[1];
// execute
$result = $db->query($sql);
// fetch result
$return = array();
while (list($field_id, $value) = $result->fetch_array(MYSQL_NUM)) {
$return['inventory-' . $field_id] = $value;
}
// return
return $return;
}