first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
<?php
if (SF_APP == 'backend')
{
stPluginHelper::addEnableModule('stProductObserveBackend');
stPluginHelper::addRouting('stProductObserveBackend', '/st-product-observe/:action/*', 'stProductObserveBackend', 'config');
stConfiguration::addModule(['label' => 'Obserwowane produkty', 'route' => '@stProductObserveBackend', 'icon' => 'stProductObservePlugin'], 'offer');
}
elseif (SF_APP == 'frontend')
{
stPluginHelper::addEnableModule('stProductObserveFrontend');
stPluginHelper::addRouting('stProductObserveFrontend', '/st-product-observe/:action/*', 'stProductObserveFrontend', 'index');
$dispatcher->connect('smarty.slot.append', array('stProductObservePluginListener', 'append'));
}

View File

@@ -0,0 +1,32 @@
---
propel:
_attributes:
defaultIdMethod: native
package: plugins.stProductObservePlugin.lib.model
st_product_observe:
_attributes:
phpName: stProductObserve
id:
type: INTEGER
primaryKey: true
required: true
autoIncrement: true
cookie_id:
type: VARCHAR
size: 255
required: true
product_id:
type: INTEGER
required: true
foreignTable: st_product
foreignReference: id
onDelete: cascade
sf_guard_user_id:
type: INTEGER
foreignTable: sf_guard_user
foreignReference: id
required: false
onDelete: setnull
product_order:
type: INTEGER
required: true

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_product_observe' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stProductObservePlugin.lib.model.map
*/
class stProductObserveMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stProductObservePlugin.lib.model.map.stProductObserveMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_product_observe');
$tMap->setPhpName('stProductObserve');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('COOKIE_ID', 'CookieId', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addForeignKey('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
$tMap->addForeignKey('SF_GUARD_USER_ID', 'SfGuardUserId', 'int', CreoleTypes::INTEGER, 'sf_guard_user', 'ID', false, null);
$tMap->addColumn('PRODUCT_ORDER', 'ProductOrder', 'int', CreoleTypes::INTEGER, true, null);
} // doBuild()
} // stProductObserveMapBuilder

View File

@@ -0,0 +1,944 @@
<?php
/**
* Base class that represents a row from the 'st_product_observe' table.
*
*
*
* @package plugins.stProductObservePlugin.lib.model.om
*/
abstract class BasestProductObserve extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the id field.
* @var int
*/
protected $id;
/**
* The value for the cookie_id field.
* @var string
*/
protected $cookie_id;
/**
* The value for the product_id field.
* @var int
*/
protected $product_id;
/**
* The value for the sf_guard_user_id field.
* @var int
*/
protected $sf_guard_user_id;
/**
* The value for the product_order field.
* @var int
*/
protected $product_order;
/**
* @var Product
*/
protected $aProduct;
/**
* @var sfGuardUser
*/
protected $asfGuardUser;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [id] column value.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get the [cookie_id] column value.
*
* @return string
*/
public function getCookieId()
{
return $this->cookie_id;
}
/**
* Get the [product_id] column value.
*
* @return int
*/
public function getProductId()
{
return $this->product_id;
}
/**
* Get the [sf_guard_user_id] column value.
*
* @return int
*/
public function getSfGuardUserId()
{
return $this->sf_guard_user_id;
}
/**
* Get the [product_order] column value.
*
* @return int
*/
public function getProductOrder()
{
return $this->product_order;
}
/**
* Set the value of [id] column.
*
* @param int $v new value
* @return void
*/
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = stProductObservePeer::ID;
}
} // setId()
/**
* Set the value of [cookie_id] column.
*
* @param string $v new value
* @return void
*/
public function setCookieId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->cookie_id !== $v) {
$this->cookie_id = $v;
$this->modifiedColumns[] = stProductObservePeer::COOKIE_ID;
}
} // setCookieId()
/**
* Set the value of [product_id] column.
*
* @param int $v new value
* @return void
*/
public function setProductId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->product_id !== $v) {
$this->product_id = $v;
$this->modifiedColumns[] = stProductObservePeer::PRODUCT_ID;
}
if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
$this->aProduct = null;
}
} // setProductId()
/**
* Set the value of [sf_guard_user_id] column.
*
* @param int $v new value
* @return void
*/
public function setSfGuardUserId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->sf_guard_user_id !== $v) {
$this->sf_guard_user_id = $v;
$this->modifiedColumns[] = stProductObservePeer::SF_GUARD_USER_ID;
}
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
$this->asfGuardUser = null;
}
} // setSfGuardUserId()
/**
* Set the value of [product_order] column.
*
* @param int $v new value
* @return void
*/
public function setProductOrder($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->product_order !== $v) {
$this->product_order = $v;
$this->modifiedColumns[] = stProductObservePeer::PRODUCT_ORDER;
}
} // setProductOrder()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
if ($this->getDispatcher()->getListeners('stProductObserve.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'stProductObserve.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->id = $rs->getInt($startcol + 0);
$this->cookie_id = $rs->getString($startcol + 1);
$this->product_id = $rs->getInt($startcol + 2);
$this->sf_guard_user_id = $rs->getInt($startcol + 3);
$this->product_order = $rs->getInt($startcol + 4);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('stProductObserve.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'stProductObserve.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 5)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 5; // 5 = stProductObservePeer::NUM_COLUMNS - stProductObservePeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating stProductObserve object", $e);
}
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param Connection $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($this->getDispatcher()->getListeners('stProductObserve.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'stProductObserve.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BasestProductObserve:delete:pre'))
{
foreach (sfMixer::getCallables('BasestProductObserve:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(stProductObservePeer::DATABASE_NAME);
}
try {
$con->begin();
stProductObservePeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('stProductObserve.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'stProductObserve.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BasestProductObserve:delete:post'))
{
foreach (sfMixer::getCallables('BasestProductObserve:delete:post') as $callable)
{
call_user_func($callable, $this, $con);
}
}
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('stProductObserve.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'stProductObserve.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BasestProductObserve:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(stProductObservePeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('stProductObserve.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'stProductObserve.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BasestProductObserve:save:post') as $callable)
{
call_user_func($callable, $this, $con, $affectedRows);
}
}
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave($con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aProduct !== null) {
if ($this->aProduct->isModified() || $this->aProduct->getCurrentProductI18n()->isModified()) {
$affectedRows += $this->aProduct->save($con);
}
$this->setProduct($this->aProduct);
}
if ($this->asfGuardUser !== null) {
if ($this->asfGuardUser->isModified()) {
$affectedRows += $this->asfGuardUser->save($con);
}
$this->setsfGuardUser($this->asfGuardUser);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = stProductObservePeer::doInsert($this, $con);
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setId($pk); //[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += stProductObservePeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aProduct !== null) {
if (!$this->aProduct->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
}
}
if ($this->asfGuardUser !== null) {
if (!$this->asfGuardUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
}
}
if (($retval = stProductObservePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = stProductObservePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getCookieId();
break;
case 2:
return $this->getProductId();
break;
case 3:
return $this->getSfGuardUserId();
break;
case 4:
return $this->getProductOrder();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = stProductObservePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCookieId(),
$keys[2] => $this->getProductId(),
$keys[3] => $this->getSfGuardUserId(),
$keys[4] => $this->getProductOrder(),
);
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = stProductObservePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setCookieId($value);
break;
case 2:
$this->setProductId($value);
break;
case 3:
$this->setSfGuardUserId($value);
break;
case 4:
$this->setProductOrder($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = stProductObservePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCookieId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setSfGuardUserId($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setProductOrder($arr[$keys[4]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(stProductObservePeer::DATABASE_NAME);
if ($this->isColumnModified(stProductObservePeer::ID)) $criteria->add(stProductObservePeer::ID, $this->id);
if ($this->isColumnModified(stProductObservePeer::COOKIE_ID)) $criteria->add(stProductObservePeer::COOKIE_ID, $this->cookie_id);
if ($this->isColumnModified(stProductObservePeer::PRODUCT_ID)) $criteria->add(stProductObservePeer::PRODUCT_ID, $this->product_id);
if ($this->isColumnModified(stProductObservePeer::SF_GUARD_USER_ID)) $criteria->add(stProductObservePeer::SF_GUARD_USER_ID, $this->sf_guard_user_id);
if ($this->isColumnModified(stProductObservePeer::PRODUCT_ORDER)) $criteria->add(stProductObservePeer::PRODUCT_ORDER, $this->product_order);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(stProductObservePeer::DATABASE_NAME);
$criteria->add(stProductObservePeer::ID, $this->id);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return int
*/
public function getPrimaryKey()
{
return $this->getId();
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(stProductObservePeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
}
/**
* Generic method to set the primary key (id column).
*
* @param int $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setId($key);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of stProductObserve (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setCookieId($this->cookie_id);
$copyObj->setProductId($this->product_id);
$copyObj->setSfGuardUserId($this->sf_guard_user_id);
$copyObj->setProductOrder($this->product_order);
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return stProductObserve Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* @return string Peer class name
*/
public function getPeer()
{
return 'stProductObservePeer';
}
/**
* Declares an association between this object and a Product object.
*
* @param Product $v
* @return void
* @throws PropelException
*/
public function setProduct($v)
{
if ($v === null) {
$this->setProductId(NULL);
} else {
$this->setProductId($v->getId());
}
$this->aProduct = $v;
}
/**
* Get the associated Product object
*
* @param Connection Optional Connection object.
* @return Product The associated Product object.
* @throws PropelException
*/
public function getProduct($con = null)
{
if ($this->aProduct === null && ($this->product_id !== null)) {
// include the related Peer class
$this->aProduct = ProductPeer::retrieveByPK($this->product_id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = ProductPeer::retrieveByPK($this->product_id, $con);
$obj->addProducts($this);
*/
}
return $this->aProduct;
}
/**
* Declares an association between this object and a sfGuardUser object.
*
* @param sfGuardUser $v
* @return void
* @throws PropelException
*/
public function setsfGuardUser($v)
{
if ($v === null) {
$this->setSfGuardUserId(NULL);
} else {
$this->setSfGuardUserId($v->getId());
}
$this->asfGuardUser = $v;
}
/**
* Get the associated sfGuardUser object
*
* @param Connection Optional Connection object.
* @return sfGuardUser The associated sfGuardUser object.
* @throws PropelException
*/
public function getsfGuardUser($con = null)
{
if ($this->asfGuardUser === null && ($this->sf_guard_user_id !== null)) {
// include the related Peer class
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id, $con);
$obj->addsfGuardUsers($this);
*/
}
return $this->asfGuardUser;
}
public function getDispatcher()
{
if (null === self::$dispatcher)
{
self::$dispatcher = stEventDispatcher::getInstance();
}
return self::$dispatcher;
}
public function __call($method, $arguments)
{
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'stProductObserve.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BasestProductObserve:'.$method))
{
throw new sfException(sprintf('Call to undefined method BasestProductObserve::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BasestProductObserve

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for representing a row from the 'st_product_observe' table.
*
*
*
* @package plugins.stProductObservePlugin.lib.model
*/
class stProductObserve extends BasestProductObserve
{
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_product_observe' table.
*
*
*
* @package plugins.stProductObservePlugin.lib.model
*/
class stProductObservePeer extends BasestProductObservePeer
{
}

View File

@@ -0,0 +1,252 @@
<?php
/**
* @package stProductObservePlugin */
class stProductObservePluginListener
{
public static function append(sfEvent $event, $components)
{
switch ($event['slot']) {
case 'base-header':
$components[] = $event->getSubject()->createComponent('stProductObserveFrontend', 'productObserve');
break;
}
return $components;
}
public static function addObserveProduct($id)
{
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
$limit_products = $config->get('product_show');
$utd_cookie = stUserTrackerLevelInterface::getUTDCookie();
$productId = $id;
$utd_update = array();
if(isset($utd_cookie['product_observe']))
{
// Sprawdź, czy ID produktu istnieje w tablicy
if (($key = array_search($productId, $utd_cookie['product_observe'])) !== false) {
// Usuń element o tym kluczu
unset($utd_cookie['product_observe'][$key]);
}
$utd_update['product_observe'] = $utd_cookie['product_observe'];
// Dodaj ID produktu na końcu tablicy
$utd_update['product_observe'][] = $productId;
// Sprawdź, czy przekroczyliśmy limit produktów
while (count($utd_update['product_observe']) > $limit_products) {
// Usuń pierwszy element tablicy
stProductObservePluginListener::delObserveProductDataBase($utd_update['product_observe'][0]);
array_shift($utd_update['product_observe']);
}
} else {
// Jeśli tablica 'product_view_recently' nie istnieje, utwórz ją i dodaj produkt
$utd_update['product_observe'] = array($productId);
}
stUserTrackerLevelInterface::updateUTDCookie($utd_update);
$productOrder = array_search($productId, $utd_update['product_observe']);
stProductObservePluginListener::addObserveProductDataBase($productId, $productOrder);
}
public static function delObserveProduct($id)
{
$utd_cookie = stUserTrackerLevelInterface::getUTDCookie();
if(isset($utd_cookie['product_observe']))
{
$products = $utd_cookie['product_observe'];
if(($remove = array_search($id, $products)) !== false) {
unset($products[$remove]);;
$utd_update['product_observe'] = $products;
stUserTrackerLevelInterface::updateUTDCookie($utd_update);
stProductObservePluginListener::delObserveProductDataBase($id);
}
}
}
public static function removeAll()
{
$utd_cookie = stUserTrackerLevelInterface::getUTDCookie();
if(isset($utd_cookie['product_observe']))
{
$utd_update['product_observe'] = array();
stUserTrackerLevelInterface::updateUTDCookie($utd_update);
stProductObservePluginListener::removeAllDataBase();
}
}
public static function isObserveProduct($id)
{
$utd_cookie = stUserTrackerLevelInterface::getUTDCookie();
if(isset($utd_cookie['product_observe']))
{
$products = $utd_cookie['product_observe'];
if(($remove = array_search($id, $products)) !== false) {
return true;
}
}
return false;
}
public static function getObserveProducts()
{
$utd_cookie = stUserTrackerLevelInterface::getUTDCookie();
if(isset($utd_cookie['product_observe']))
{
$ids = $utd_cookie['product_observe'];
$ids = array_reverse($ids);
$products = ProductPeer::retrieveByPks($ids);
usort($products, function($a, $b) use ($ids) {
return array_search($a->getId(), $ids) - array_search($b->getId(), $ids);
});
return $products;
}
else
{
return false;
}
}
public static function getObserveProductsIds()
{
$utd_cookie = stUserTrackerLevelInterface::getUTDCookie();
if(isset($utd_cookie['product_observe']))
{
$ids = $utd_cookie['product_observe'];
return $ids;
}
else
{
return false;
}
}
public static function addObserveProductDataBase($productId, $productOrder)
{
$productObserve = new stProductObserve();
$productObserve->setCookieId(stUserTrackerLevelInterface::getUTLId());
$productObserve->setProductId($productId);
$productObserve->setProductOrder($productOrder);
if(sfContext::getInstance()->getUser()->isAuthenticated())
{
$productObserve->setSfGuardUserId(sfContext::getInstance()->getUser()->getGuardUser()->getId());
}
$productObserve->save();
}
public static function delObserveProductDataBase($id)
{
$c = new Criteria();
$c->add(stProductObservePeer::COOKIE_ID, stUserTrackerLevelInterface::getUTLId());
$c->add(stProductObservePeer::PRODUCT_ID, $id);
stProductObservePeer::doDelete($c);
}
public static function removeAllDataBase()
{
$c = new Criteria();
$c->add(stProductObservePeer::COOKIE_ID, stUserTrackerLevelInterface::getUTLId());
stProductObservePeer::doDelete($c);
}
public static function getObserveProductsIdsDataBaseByUserId()
{
$c = new Criteria();
$c->add(stProductObservePeer::SF_GUARD_USER_ID, sfContext::getInstance()->getUser()->getGuardUser()->getId());
$c->addAscendingOrderByColumn('product_order');
$products_observe = stProductObservePeer::doSelect($c);
if($products_observe)
{
$ids = array();
foreach( $products_observe as $product_observe)
{
$ids[] = $product_observe->getProductId();
}
return $ids;
}
else
{
return false;
}
}
public static function updateObserveProductDataBase()
{
$observe_product_from_cookies = stProductObservePluginListener::getObserveProductsIds();
$observe_product_from_database = stProductObservePluginListener::getObserveProductsIdsDataBaseByUserId();
$result = [];
// Sprawdź, czy tablice różnią się od siebie
// $difference = array_diff($observe_product_from_cookies, $observe_product_from_database);
//if (!empty($difference) || empty($observe_product_from_cookies)) {
// Dodaj elementy z $observe_product_from_database do wynikowej tablicy
foreach ($observe_product_from_database as $value) {
if (!in_array($value, $result)) {
$result[] = $value;
}
}
// Następnie dodaj elementy z $observe_product_from_cookies, które nie są już w wynikowej tablicy
foreach ($observe_product_from_cookies as $value) {
if (!in_array($value, $result)) {
$result[] = $value;
}
}
stProductObservePluginListener::removeAll();
$c = new Criteria();
$c->add(stProductObservePeer::SF_GUARD_USER_ID, sfContext::getInstance()->getUser()->getGuardUser()->getId());
stProductObservePeer::doDelete($c);
foreach($result as $product_id){
stProductObservePluginListener::addObserveProduct($product_id);
}
//}
}
}

View File

@@ -0,0 +1,14 @@
<?php
class stProductObserveBackendActions extends autoStProductObserveBackendActions
{
protected function saveConfig()
{
parent::saveConfig();
ProductPeer::clearCache();
stFastCacheManager::clearCache();
}
}

View File

@@ -0,0 +1,7 @@
<?php
class stProductObserveBackendComponents extends autoStProductObserveBackendComponents
{
}

View File

@@ -0,0 +1,31 @@
generator:
param:
model_class: stProductObserve
title: "Obserwowane produkty"
route: "@stProductObserveBackend"
icon: "stProductObservePlugin"
documentation:
pl: "https://www.sote.pl/docs/obserwowane-produkty"
en: "https://www.soteshop.com/docs/obserwowane-produkty"
config:
display:
"NONE": [enabled, product_show]
fields:
enabled: {name: "Włącz", checked: false, type: checkbox}
product_show:
name: Ilość obserwowanych
type: select
display: [3, 4, 6, 8, 9, 12]
options:
3: {name: 3, value: 3}
4: {name: 4, value: 4}
6: {name: 6, value: 6}
8: {name: 8, value: 8}
9: {name: 9, value: 9}
12: {name: 12, value: 12}
selected: 6
actions:
_save: {name: "Zapisz"}

View File

@@ -0,0 +1,5 @@
<?php
class stProductObserveBackendBreadcrumbsBuilder extends autoStProductObserveBackendBreadcrumbsBuilder
{
}

View File

@@ -0,0 +1,88 @@
<?php
class stProductObserveFrontendActions extends stActions
{
public function executeAddToObserve()
{
$product_id = $this->getRequestParameter('product_id');
stProductObservePluginListener::addObserveProduct($product_id);
//return sfView::NONE;
return $this->renderText("true");
}
public function executeRemoveFromObserve()
{
$product_id = $this->getRequestParameter('product_id');
stProductObservePluginListener::delObserveProduct($product_id);
//return sfView::NONE;
return $this->renderText("true");
}
public function executeRemoveAll()
{
stProductObservePluginListener::removeAll();
//return sfView::NONE;
return $this->renderText("true");
}
public function executeShowProductsSidebar()
{
$this->smarty = new stSmarty('stProductObserveFrontend');
$config_observe = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
if($config_observe->get('enabled')!=1){
return sfView::NONE;
}
$i18n = $this->getContext()->getI18n();
if(stProductObservePluginListener::getObserveProducts()){
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
$this->products = stProductObservePluginListener::getObserveProducts();
}else{
return $this->renderText("<p>".$i18n->__('W tym miejscu pojawią się obserwowane produkty.')."</p>");
}
}
public function executeObserveProductsIds()
{
$products = stProductObservePluginListener::getObserveProductsIds();
return $this->renderJSON($products);
}
public function executeListShowProducts()
{
$this->smarty = new stSmarty('stProductObserveFrontend');
$config_observe = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
if(stProductObservePluginListener::getObserveProducts()){
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
$this->products = stProductObservePluginListener::getObserveProducts();
}
}
}

View File

@@ -0,0 +1,44 @@
<?php
class stProductObserveFrontendComponents extends sfComponents
{
public function executeProductObserve()
{
$this->smarty = new stSmarty('stProductObserveFrontend');
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
if($config->get('enabled')!=1){
return sfView::NONE;
}
}
public function executeObserveProductsSidebar()
{
$this->smarty = new stSmarty('stProductObserveFrontend');
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
if($config->get('enabled')!=1){
return sfView::NONE;
}
}
public function executeListProductObserve()
{
$this->smarty = new stSmarty('stProductObserveFrontend');
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
if($config->get('enabled')!=1){
return sfView::NONE;
}
}
}

View File

@@ -0,0 +1,3 @@
<?php
$smarty->display('list_product_observe.html');

View File

@@ -0,0 +1,3 @@
<?php
$smarty->display('observe_products_sidebar.html');

View File

@@ -0,0 +1,3 @@
<?php
$smarty->display('product_observe.html');

View File

@@ -0,0 +1,140 @@
<?php
use_helper('stCurrency', 'stText', 'stProductImage', 'stUrl', 'stAvailability');
sfLoader::loadHelpers('stProduct','stProduct');
st_theme_use_stylesheet('stProduct.css');
$results = array();
$smarty->assign("show_name", $config->get('show_name_other'));
$smarty->assign("show_image", $config->get('show_image_other'));
$smarty->assign("show_price", $config->get('show_price_other'));
$smarty->assign("show_old_price", $config->get('show_old_price_other'));
$smarty->assign("show_discount", $config->get('show_discount_other'));
$smarty->assign("show_basket", $config->get('show_basket_long'));
$smarty->assign("price_view", $config->get('price_view_other'));
$smarty->assign('button_type', $config->get('button_type_long'));
$photo_max_height = st_asset_thumbnail_setting('height', 'thumb');
$photo_max_width = st_asset_thumbnail_setting('width', 'small');
$cut_name = $config->get('cut_name_other');
$max_name_length = $config->get('cut_name_num_other');
foreach ($products as $index => $product)
{
$product_url = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
$product_name = $product->getName();
$results[$index]['instance'] = $product;
if ($cut_name && st_check_strlen($product_name) > $max_name_length)
{
$results[$index]['name'] = '<span title="'.$product_name.'" class="hint">' . content_tag('a', st_truncate_text($product_name, $max_name_length, '...'), array('href' => $product_url, 'class' => 'product_name')) . "</span>";
}
else
{
$results[$index]['name'] = content_tag('a', $product_name, array('href' => $product_url, 'class' => 'product_name'));
}
$results[$index]['id'] = $product->getId();
$results[$index]['photo'] = content_tag('a', st_product_image_tag($product, 'thumb'), array('href' => $product_url));
$results[$index]['photo_small'] = content_tag('a', st_product_image_tag($product, 'small'), array('href' => $product_url));
$results[$index]['photo_max_height'] = $photo_max_height;
// $results[$index]['uom'] = st_product_uom($product);
$results[$index]['stock'] = $product->getStock();
if ($product->isPriceVisible())
{
if ($config->get('show_uom_other') && $product->getUom())
{
$uom = " / ".$results[$index]['uom'];
}else{
$uom = "";
}
$results[$index]['price'] = st_currency_format($product->getPriceBrutto(true)).$uom;
$results[$index]['price_net'] = st_currency_format($product->getPriceNetto(true)).$uom;
$results[$index]['price_brutto_pure'] = $product->getPriceBrutto(true).$uom;
$results[$index]['price_netto_pure'] = $product->getPriceNetto(true).$uom;
$currency = stCurrency::getInstance(sfContext::getInstance());
if ($currency->getFrontSymbol())
{
$results[$index]['currency'] = $currency->getFrontSymbol();
}
else
{
$results[$index]['currency'] = $currency->getBackSymbol();
}
$old_price_brutto = $product->getOldPriceBrutto(true);
$results[$index]['check_old_price'] = $old_price_brutto != 0;
$results[$index]['old_price'] = st_currency_format($old_price_brutto);
$results[$index]['old_price_net'] = st_currency_format($product->getOldPriceNetto(true));
$results[$index]['discount'] = $product->getDiscountInPercent();
$results[$index]['basket'] = st_get_component('stBasket', 'add', array('product' => $product));
$results[$index]['check_price'] = false;
if ($config->get('show_basic_price_long') && $product->hasBasicPrice() && $product->getBasicPriceBrutto()!=0)
{
$results[$index]['basic_price'] = array(
'netto' => st_currency_format($product->getBasicPriceNetto(true)),
'brutto' => st_currency_format($product->getBasicPriceBrutto(true)),
'quantity' => st_product_basic_price_quantity($product),
'for_quantity' => st_product_basic_price_for_quantity($product),
);
}
}
else
{
$results[$index]['check_price'] = true;
}
$results[$index]['is_observe'] = stProductObservePluginListener::isObserveProduct($product->getId());
$results[$index]['name_without_link'] = $product_name;
$results[$index]['link'] = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
$results[$index]['availability'] = st_availability_show($product);
}
$smarty->assign('show_stock', $config->get('show_depository_long'));
$smarty->assign('show_availability', $config->get('show_availability_long'));
$smarty->assign('results', $results);
$config_observe = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
$smarty->assign('is_observe_enabled', $config_observe->get('enabled'));
$smarty->display('list_show_products.html');

View File

@@ -0,0 +1,134 @@
<?php
use_helper('stCurrency', 'stText', 'stProductImage', 'stUrl', 'stAvailability');
sfLoader::loadHelpers('stProduct','stProduct');
st_theme_use_stylesheet('stProduct.css');
$results = array();
$smarty->assign("show_name", $config->get('show_name_other'));
$smarty->assign("show_image", $config->get('show_image_other'));
$smarty->assign("show_price", $config->get('show_price_other'));
$smarty->assign("show_old_price", $config->get('show_old_price_other'));
$smarty->assign("show_discount", $config->get('show_discount_other'));
$smarty->assign("show_basket", $config->get('show_basket_long'));
$smarty->assign("price_view", $config->get('price_view_other'));
$smarty->assign('button_type', $config->get('button_type_long'));
$photo_max_height = st_asset_thumbnail_setting('height', 'thumb');
$photo_max_width = st_asset_thumbnail_setting('width', 'small');
$cut_name = $config->get('cut_name_other');
$max_name_length = $config->get('cut_name_num_other');
foreach ($products as $index => $product)
{
$product_url = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
$product_name = $product->getName();
$results[$index]['instance'] = $product;
if ($cut_name && st_check_strlen($product_name) > $max_name_length)
{
$results[$index]['name'] = '<span title="'.$product_name.'" class="hint">' . content_tag('a', st_truncate_text($product_name, $max_name_length, '...'), array('href' => $product_url, 'class' => 'product_name')) . "</span>";
}
else
{
$results[$index]['name'] = content_tag('a', $product_name, array('href' => $product_url, 'class' => 'product_name'));
}
$results[$index]['id'] = $product->getId();
$results[$index]['photo'] = content_tag('a', st_product_image_tag($product, 'thumb'), array('href' => $product_url));
$results[$index]['photo_small'] = content_tag('a', st_product_image_tag($product, 'small'), array('href' => $product_url));
$results[$index]['photo_max_height'] = $photo_max_height;
// $results[$index]['uom'] = st_product_uom($product);
$results[$index]['stock'] = $product->getStock();
if ($product->isPriceVisible())
{
if ($config->get('show_uom_other') && $product->getUom())
{
$uom = " / ".$results[$index]['uom'];
}else{
$uom = "";
}
$results[$index]['price'] = st_currency_format($product->getPriceBrutto(true)).$uom;
$results[$index]['price_net'] = st_currency_format($product->getPriceNetto(true)).$uom;
$results[$index]['price_brutto_pure'] = $product->getPriceBrutto(true).$uom;
$results[$index]['price_netto_pure'] = $product->getPriceNetto(true).$uom;
$currency = stCurrency::getInstance(sfContext::getInstance());
if ($currency->getFrontSymbol())
{
$results[$index]['currency'] = $currency->getFrontSymbol();
}
else
{
$results[$index]['currency'] = $currency->getBackSymbol();
}
$old_price_brutto = $product->getOldPriceBrutto(true);
$results[$index]['check_old_price'] = $old_price_brutto != 0;
$results[$index]['old_price'] = st_currency_format($old_price_brutto);
$results[$index]['old_price_net'] = st_currency_format($product->getOldPriceNetto(true));
$results[$index]['discount'] = $product->getDiscountInPercent();
$results[$index]['basket'] = st_get_component('stBasket', 'add', array('product' => $product));
$results[$index]['check_price'] = false;
if ($config->get('show_basic_price_long') && $product->hasBasicPrice() && $product->getBasicPriceBrutto()!=0)
{
$results[$index]['basic_price'] = array(
'netto' => st_currency_format($product->getBasicPriceNetto(true)),
'brutto' => st_currency_format($product->getBasicPriceBrutto(true)),
'quantity' => st_product_basic_price_quantity($product),
'for_quantity' => st_product_basic_price_for_quantity($product),
);
}
}
else
{
$results[$index]['check_price'] = true;
}
$results[$index]['name_without_link'] = $product_name;
$results[$index]['link'] = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
$results[$index]['availability'] = st_availability_show($product);
}
$smarty->assign('show_stock', $config->get('show_depository_long'));
$smarty->assign('show_availability', $config->get('show_availability_long'));
$smarty->assign('results', $results);
$smarty->display('show_products_sidebar.html');

View File

@@ -0,0 +1,30 @@
<ul class="nav nav-tabs">
<li class="active">
<a rel="nofollow">{__ text="Obserwowane produkty"}</a>
</li>
</ul>
</br>
<div id="product-tab-observe">
</div>
{literal}
<script type="text/javascript">
//<![CDATA[
jQuery(function($){
$(document).ready(function() {
$.get('{/literal}{url_for internal=stProductObserveFrontend/listShowProducts}{literal}', function(html)
{
setTimeout(function() {
$('#product-tab-observe').html(html);
}, 200); // 500 milisekund = 0,5 sekundy
});
});
});
//]]>
</script>
{/literal}

View File

@@ -0,0 +1,96 @@
<section id="product-observe-list" class="full-list product-list" >
<div class="row" data-equalizer>
{foreach key=row item=product from=$results}
<div class="product col-xs-4 col-sm-4 col-md-3 col-lg-3">
<div class="thumbnail clearfix view-img">
{if $is_observe_enabled }
<div class="product-observe {if $product.is_observe}observe-yes{else}observe-no{/if}" data-product-observe="{$product.id}">
<svg width="23" height="21" viewBox="0 0 23 21" xmlns="http://www.w3.org/2000/svg">
<path d="M6.4592 1C3.44417 1 1 3.81598 1 7.28966C1 7.97227 1.09438 8.62947 1.26893 9.2449C1.71875 10.8309 2.96968 12.0161 4.1733 13.1426L11.5 20L18.8267 13.1426C20.0303 12.0161 21.2813 10.8309 21.7311 9.2449C21.9056 8.62947 22 7.97227 22 7.28966C22 3.81598 19.5558 1 16.5408 1C14.2698 1 12.3227 2.59762 11.5 4.87056C10.6773 2.59762 8.73018 1 6.4592 1Z" stroke-width="2" stroke-linejoin="round"/>
</svg>
</div>
{/if}
{if $show_image==1}<div data-equalizer-watch="image"><div class="image">{$product.photo_small}</div></div>{/if}
<div class="text-center caption clearfix" data-equalizer-watch="info">
<p class="name">{if $show_name==1}{$product.name}{/if}</p>
{if $show_availability}
<div class="product-availability text-center">
{$product.availability}
{if $show_stock}
({$product.stock} {$product.uom})
{/if}
</div>
{elseif $show_stock}
<div class="product-availability text-center">
{__ text="Dostępność" langCatalogue="stAvailabilityFrontend"}: {$product.stock} {$product.uom}
</div>
{/if}
{if $show_price==1 && $product.check_price!=1}
{if $price_view=='net_gross'}
<div class="double_price price">
<span class="nowrap">{$product.price_net}</span>
<div class="minor_price nowrap">({$product.price})</div>
</div>
{elseif $price_view=='only_gross'}
<div class="price nowrap">{$product.price}</div>
{elseif $price_view=='only_net'}
<div class="price nowrap">{$product.price_net}</div>
{elseif $price_view=='gross_net'}
<div class="double_price price">
<span class="nowrap">{$product.price}</span>
<div class="minor_price nowrap">({$product.price_net})</div>
</div>
{/if}
{if $product.basic_price}
<div class="text-muted basic_price text-center"><i>{$product.basic_price.quantity} ( {$product.basic_price.brutto} {__ text="za"} {$product.basic_price.for_quantity} )</i></div>
{/if}
{/if}
<div class="discount-old_price">
{if $show_discount==1 && $product.discount!=0 && $product.check_price!=1}
<div class="discount">{__ text="Rabat"}: <span class="nowrap">{$product.discount} %</span></div>
{elseif ($show_old_price==1 && $product.check_price!=1)}
{if $product.check_old_price==1}
<div class="old_price price nowrap">
{if ($price_view=='net_gross' || $price_view=='only_net')}
{$product.old_price_net}
{else}
{$product.old_price}
{/if}
</div>
{/if}
{/if}
</div>
<div class="product-shopping-cart">
{if $button_type == 'basket'}
{if $show_price==1 && $show_basket==1}
{basket_add_link product=$product.instance namespace="product_recommend_card"}
{/if}
{else}
<a class="btn btn-shopping-cart" href="{$product.link}">{__ text="Sprawdź"}</a>
{/if}
</div>
</div>
</div>
</div>
{/foreach}
</div>
</section>
{literal}
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
$('#product-observe-list [data-equalizer]').equalizer({ use_tallest: true });
});
});
</script>
{/literal}

View File

@@ -0,0 +1,69 @@
<div class="sidebar-header">
<div class="sidebar-header-icon">
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15.8139 27.6322L16.5 28.2793L17.1861 27.6322L25.1499 20.1218L25.1923 20.0817C26.4535 18.8925 28.0132 17.4219 28.5833 15.3963L28.5834 15.3962C28.7978 14.634 28.913 13.8231 28.913 12.9839C28.913 8.77231 25.9434 5.09521 21.9791 5.09521C19.7063 5.09521 17.747 6.32102 16.5 8.1472C15.253 6.32102 13.2937 5.09521 11.0209 5.09521C7.05656 5.09521 4.08694 8.77232 4.08694 12.9839C4.08694 13.8231 4.2021 14.634 4.41667 15.3963C4.98685 17.422 6.5466 18.8927 7.80789 20.082L7.85009 20.1218L7.85009 20.1218L15.8139 27.6322Z" stroke="#5B5B5B" stroke-width="2"/>
</svg>
</div>
{__ text="Obserwowane produkty"}
<div id="remove-all-observe-container" style="float:right;"></div>
</div>
<div id="product-tab-observe-sidebar">
</div>
{literal}
<script type="text/javascript">
//<![CDATA[
jQuery(function($){
$(document).ready(function() {
showProductsSidebar();
$(document).on('click', '#remove-all-observe', function() {
$.get('{/literal}{url_for internal=stProductObserveFrontend/removeAll}{literal}', function(html)
{
setTimeout(function() {
showProductsSidebar();
setObserveToNo();
}, 200); // 500 milisekund = 0,5 sekundy
});
});
function showProductsSidebar()
{
$.get('{/literal}{url_for internal=stProductObserveFrontend/showProductsSidebar}{literal}', function(html)
{
setTimeout(function() {
$('#product-tab-observe-sidebar').html(html);
}, 200); // 500 milisekund = 0,5 sekundy
});
}
function setObserveToNo() {
var elements = $('.product-observe');
elements.each(function() {
var $element = $(this);
if ($element.hasClass('observe-yes')) {
$element.removeClass('observe-yes').addClass('observe-no');
}
});
}
});
});
//]]>
</script>
{/literal}

View File

@@ -0,0 +1,162 @@
{literal}
<script type="text/javascript">
//<![CDATA[
jQuery(function($){
$(document).ready(function() {
$(document).on('click', '.product-observe', function() {
let productValue = $(this).data('product-observe');
let div = $(this).closest('div');
if(div.hasClass('observe-no')){
$.get('{/literal}{url_for internal=stProductObserveFrontend/addToObserve}{literal}', { 'product_id':productValue}, function(data)
{
setTimeout(function() {
blinkInGreen();
setObserveYesForProduct(productValue);
showProductsSidebar();
}, 200); // 500 milisekund = 0,5 sekundy
});
}
if(div.hasClass('observe-yes')){
$.get('{/literal}{url_for internal=stProductObserveFrontend/removeFromObserve}{literal}', { 'product_id':productValue}, function(data)
{
setTimeout(function() {
blinkInRed();
setObserveNoForProduct(productValue);
showProductsSidebar();
}, 200); // 500 milisekund = 0,5 sekundy
});
}
});
function setObserveNoForProduct(id) {
var elements = $('div[data-product-observe="' + id + '"]');
elements.each(function() {
var $element = $(this);
if ($element.hasClass('observe-yes')) {
$element.removeClass('observe-yes').addClass('observe-no');
}
});
}
function setObserveYesForProduct(id) {
var elements = $('div[data-product-observe="' + id + '"]');
elements.each(function() {
var $element = $(this);
if ($element.hasClass('observe-no')) {
$element.removeClass('observe-no').addClass('observe-yes');
}
});
}
function showProductsSidebar() {
$.get('{/literal}{url_for internal=stProductObserveFrontend/showProductsSidebar}{literal}', function(html)
{
setTimeout(function() {
$('#product-tab-observe-sidebar').html(html);
}, 200); // 500 milisekund = 0,5 sekundy
});
}
function blinkInRed() {
$('#sidebar-handle').animate({
'dummy': 1
}, {
step: function(now, fx) {
$(this).css('background-color', '#eee');
$(this).find('.glyphicon-list').removeClass('glyphicon-list').addClass('glyphicon-trash');
},
complete: function() {
$(this).animate({
'dummy': 1
}, {
step: function(now, fx) {
$(this).css('background-color', ''); // Przywróć pierwotny kolor tła
$(this).find('.glyphicon-trash').removeClass('glyphicon-trash').addClass('glyphicon-list');
}
});
},
duration: 2000 // czas trwania animacji, możesz dostosować według potrzeb
});
}
function blinkInGreen() {
$('#sidebar-handle').animate({
'dummy': 1
}, {
step: function(now, fx) {
$(this).css('background-color', '#eee');
$(this).find('.glyphicon-list').removeClass('glyphicon-list').addClass('glyphicon-heart');
},
complete: function() {
$(this).animate({
'dummy': 1
}, {
step: function(now, fx) {
$(this).css('background-color', ''); // Przywróć pierwotny kolor tła
$(this).find('.glyphicon-heart').removeClass('glyphicon-heart').addClass('glyphicon-list');
}
});
},
duration: 2000 // czas trwania animacji, możesz dostosować według potrzeb
});
}
$(document).on('click', '.product-observe', function() {
var $clone = $(this).clone();
var pos = $(this).offset();
var targetPos = $("#sidebar-handle").offset();
if (!targetPos) {
console.error("Element .sidebar-handle not found.");
return;
}
$clone.css({
position: "absolute",
top: pos.top,
left: pos.left,
zIndex: 9999
});
$("body").append($clone);
$clone.animate({
top: targetPos.top,
left: targetPos.left
}, 1000, function() {
$clone.remove();
});
});
});
});
//]]>
</script>
{/literal}

View File

@@ -0,0 +1,177 @@
<section id="product-observe-sidebar" class="product-list">
{foreach key=row item=product from=$results}
<div class="row">
<div class="col-sm-2 item-image-col">
<div class="image">{$product.photo_small}</div>
</div>
<div class="col-sm-10">
<a class="close-icon" data-product="{$product.id}" style="float:right;"></a>
<div class="observe-full" style="float:right; padding: 5px 10px;">
<svg style="width: 18px; height: 15px;" width="23" height="21" viewBox="0 0 23 21" xmlns="http://www.w3.org/2000/svg">
<path d="M6.4592 1C3.44417 1 1 3.81598 1 7.28966C1 7.97227 1.09438 8.62947 1.26893 9.2449C1.71875 10.8309 2.96968 12.0161 4.1733 13.1426L11.5 20L18.8267 13.1426C20.0303 12.0161 21.2813 10.8309 21.7311 9.2449C21.9056 8.62947 22 7.97227 22 7.28966C22 3.81598 19.5558 1 16.5408 1C14.2698 1 12.3227 2.59762 11.5 4.87056C10.6773 2.59762 8.73018 1 6.4592 1Z" stroke-width="2" stroke-linejoin="round"/>
</svg>
</div>
{$product.name}
{if $show_price==1 && $product.check_price!=1}
{if $price_view=='net_gross'}
<div class="double_price price">
<span class="nowrap">{$product.price_net}</span>
<div class="minor_price nowrap">({$product.price})</div>
</div>
{elseif $price_view=='only_gross'}
<div class="price nowrap">{$product.price}</div>
{elseif $price_view=='only_net'}
<div class="price nowrap">{$product.price_net}</div>
{elseif $price_view=='gross_net'}
<div class="double_price price">
<span class="nowrap">{$product.price}</span>
<div class="minor_price nowrap">({$product.price_net})</div>
</div>
{/if}
{if $product.basic_price}
<div class="text-muted basic_price text-center"><i>{$product.basic_price.quantity} ( {$product.basic_price.brutto} {__ text="za"} {$product.basic_price.for_quantity} )</i></div>
{/if}
{/if}
<div class="discount-old_price">
{if $show_discount==1 && $product.discount!=0 && $product.check_price!=1}
<div class="discount">{__ text="Rabat"}: <span class="nowrap">{$product.discount} %</span></div>
{elseif ($show_old_price==1 && $product.check_price!=1)}
{if $product.check_old_price==1}
<div class="old_price price nowrap">
{if ($price_view=='net_gross' || $price_view=='only_net')}
{$product.old_price_net}
{else}
{$product.old_price}
{/if}
</div>
{/if}
{/if}
</div>
</div>
</div>
{/foreach}
{if $results|@count >= 2}
<div class="row">
<div class="col-sm-12">
<div id="remove-all-observe" class="sidebar-header-trash">
{__ text="Usuń wszystko"} <span class="glyphicon glyphicon-trash"></span>
</div>
</div>
</div>
{/if}
</section>
{literal}
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
checkObserveProduct();
$('#product-observe-sidebar .close-icon').on('click', function(e){
e.preventDefault(); // Zapobiega domyślnej akcji (nawigacji do strony linka)
let productValue = $(this).data('product');
let row = $(this).closest('.row');
$.get('{/literal}{url_for internal=stProductObserveFrontend/removeFromObserve}{literal}', { 'product_id':productValue}, function(data)
{
setTimeout(function() {
row.remove();
setObserveNoForProduct(productValue);
$.get('{/literal}{url_for internal=stProductObserveFrontend/showProductsSidebar}{literal}', function(html)
{
setTimeout(function() {
$('#product-tab-observe-sidebar').html(html);
}, 200); // 500 milisekund = 0,5 sekundy
});
}, 200); // 500 milisekund = 0,5 sekundy
});
});
function setObserveNoForProduct(id) {
var elements = $('div[data-product-observe="' + id + '"]');
elements.each(function() {
var $element = $(this);
if ($element.hasClass('observe-yes')) {
$element.removeClass('observe-yes').addClass('observe-no');
}
});
}
function setObserveYesForProduct(id) {
var elements = $('div[data-product-observe="' + id + '"]');
elements.each(function() {
var $element = $(this);
if ($element.hasClass('observe-no')) {
$element.removeClass('observe-no').addClass('observe-yes');
}
});
}
function checkObserveProduct()
{
$.get('{/literal}{url_for internal=stProductObserveFrontend/observeProductsIds}{literal}', function(html)
{
setTimeout(function() {
resetObserve();
let products_observe = html;
for (var key in products_observe) {
if (products_observe.hasOwnProperty(key)) {
//console.log(products_observe[key]);
setObserveYesForProduct(products_observe[key])
}
}
}, 200); // 500 milisekund = 0,5 sekundy
});
}
function resetObserve() {
var elements = $('.product-observe');
elements.each(function() {
var $element = $(this);
if ($element.hasClass('observe-yes')) {
$element.removeClass('observe-yes').addClass('observe-no');
}
});
}
});
});
</script>
{/literal}