first commit
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
class stPaczkomatyFrontendActions extends stActions
|
||||
{
|
||||
public function executeChooseDeliveryPoint()
|
||||
{
|
||||
$delivery_id = $this->getRequestParameter('delivery_id');
|
||||
|
||||
$points = $this->getUser()->getAttribute('delivery_point', array(), 'soteshop/stPaczkomatyPlugin');
|
||||
|
||||
$points[$delivery_id] = $this->getRequestParameter('point');
|
||||
|
||||
$this->getUser()->setAttribute('delivery_point', $points, 'soteshop/stPaczkomatyPlugin');
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
public function executeShowMap() {
|
||||
$this->smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
$this->setLayout(false);
|
||||
$this->config = stConfig::getInstance('stPaczkomatyBackend');
|
||||
|
||||
$this->cities = stPaczkomatyCites::getListofCities();
|
||||
|
||||
$delivery = DeliveryPeer::retrieveByPK($this->getRequestParameter('deliveryId'));
|
||||
|
||||
if (is_object($delivery))
|
||||
$this->machinesNamespace = $delivery->getPaczkomatyType();
|
||||
}
|
||||
|
||||
public function executeGetMachines() {
|
||||
$i18n = $this->getContext()->getI18n();
|
||||
|
||||
if ($this->getRequestParameter('machinesNamespace', 'ALL') == 'COD') {
|
||||
$data = stPaczkomatyMachines::getListOfCodMachines();
|
||||
} else {
|
||||
$data = stPaczkomatyMachines::getListOfMachines();
|
||||
}
|
||||
|
||||
return $this->renderJSON($data);
|
||||
}
|
||||
|
||||
public function executeGetMachine() {
|
||||
|
||||
return $this->renderJSON(stPaczkomatyMachines::getMachine($this->getRequestParameter('number')));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeGetMachineByPostCode() {
|
||||
|
||||
return $this->renderJSON(stPaczkomatyMachines::getMachineByPostCode($this->getRequestParameter('post_code')));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeGetMachinesByPostCode()
|
||||
{
|
||||
return $this->renderJSON(stPaczkomatyMachines::getMachinesByPostCode($this->getRequestParameter('post_code'), $this->getRequestParameter('limit')));
|
||||
}
|
||||
|
||||
public function executeGet3MachinesByPostCode() {
|
||||
|
||||
return $this->renderJSON(stPaczkomatyMachines::get3MachinesByPostCode($this->getRequestParameter('post_code')));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeEasyPackShow()
|
||||
{
|
||||
$config = stConfig::getInstance('stPaczkomatyBackend');
|
||||
$pickupPoint = stDeliveryTypePickupPoint::createFromJson($this->getRequestParameter('pickup_point'));
|
||||
|
||||
$smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
$smarty->assign('sandbox', $config->get('sandbox'));
|
||||
$smarty->assign('delivery_id', $this->getRequestParameter('delivery_id'));
|
||||
$smarty->assign('pickup_point_name', null !== $pickupPoint ? $pickupPoint->getName() : null);
|
||||
|
||||
if (!$config->get('sandbox'))
|
||||
{
|
||||
$smarty->assign('api_endpoint', 'https://api-pl-points.easypack24.net/v1');
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty->assign('api_endpoint', 'https://stage-api-pl-points.easypack24.net/v1');
|
||||
}
|
||||
|
||||
sfConfig::set('sf_web_debug', false);
|
||||
|
||||
return $this->renderText($smarty->fetch('easy_pack_show.html'));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class stPaczkomatyFrontendComponents extends sfComponents {
|
||||
|
||||
public function executeBasketTerms() {
|
||||
if(stPaczkomaty::isActive() == false)
|
||||
return sfView::NONE;
|
||||
|
||||
|
||||
$this->smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
$this->number = htmlspecialchars($this->getRequestParameter('user_data_billing[paczkomaty_machine_number]'));
|
||||
}
|
||||
|
||||
public function executeDeliveryOnBasketList() {
|
||||
if(stPaczkomaty::isActive() == false || !$this->delivery->getPaczkomatyType() || $this->delivery->getPaczkomatyType() == 'NONE')
|
||||
return sfView::NONE;
|
||||
|
||||
$this->smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
|
||||
$point = json_decode($this->getRequestParameter('user_data_billing[paczkomaty_machine_number]'), true);
|
||||
|
||||
$this->smarty->assign('point', $point);
|
||||
|
||||
$this->smarty->assign('id', $this->delivery->getId());
|
||||
}
|
||||
|
||||
public function executeHelper()
|
||||
{
|
||||
if ($this->getModuleName() != 'stBasket')
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
|
||||
$ids = [];
|
||||
$smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
|
||||
foreach (PaymentTypePeer::doSelectCached() as $payment)
|
||||
{
|
||||
if ($payment->getIsCod())
|
||||
{
|
||||
$ids[] = $payment->getId();
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign('payments', json_encode($ids));
|
||||
$smarty->assign('endpoint', stInPostApi::getInstance()->getEndpoint());
|
||||
|
||||
return $smarty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user