Spade
Mini Shell
| Directory:~$ /proc/self/root/home/lmsyaran/public_html/j3/administrator/components/com_invoices/models/ |
| [Home] [System Details] [Kill Me] |
<?php
/*------------------------------------------------------------------------
# com_invoices - Invoice Manager for Joomla
# ------------------------------------------------------------------------
# author Germinal Camps
# copyright Copyright (C) 2012 - 2016 JoomlaThat.com. All Rights
Reserved.
# @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.joomlathat.com
# Technical Support: Forum - http://www.joomlathat.com/support
-------------------------------------------------------------------------*/
//no direct access
defined('_JEXEC') or die('Restricted access.');
jimport('joomla.application.component.model');
class ItemsModelItem extends JModelLegacy
{
var $input;
function __construct()
{
parent::__construct();
$mainframe = JFactory::getApplication();
$this->input = $mainframe->input;
$array = $this->input->get('cid', 0, '',
'array');
$this->setId((int)$array[0]);
}
function setId($id)
{
// Set id and wipe data
$this->_id = $id;
$this->_data = null;
}
function &getData()
{
// Load the data
if (empty( $this->_data )) {
$query = ' SELECT * FROM #__invoices_items '.
' WHERE id = '.$this->_id;
$this->_db->setQuery( $query );
$this->_data = $this->_db->loadObject();
}
//print_r( $this->_data);die();
if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
}
return $this->_data;
}
function store()
{
$row = $this->getTable();
$data = $this->input->post->getArray();
// Bind the form fields to the album table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the hello record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the web link table to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}
else{ //retornem el id de l'album!
$album_id = $data['album_id'];
}
if($album_id){ //retornem el id de l'album!
return $album_id;
}
return true;
}
function delete()
{
$cids = $this->input->get( 'cid', array(0),
'default', 'array' );
$row = $this->getTable();
if (count( $cids )) {
foreach($cids as $cid) {
$query = " SELECT invoice_id FROM #__invoices_items WHERE id =
".$cid ;
$this->_db->setQuery($query);
$invoice_id = $this->_db->loadResult();
if (!$row->delete( $cid )) {
$this->setError( $row->getErrorMsg() );
return false;
}
else{
InvoicesHelper::updateComputedStatus($invoice_id, true);
}
}
}
return true;
}
}