Beispiel #1
0
 function getOptionsPreus()
 {
     echo json_encode(J::getOption(J::CONF_PREUS));
 }
Beispiel #2
0
 public function validaRecaptcha()
 {
     $R = $this->getAjaxData();
     $C = J::loadJsonConfigFile('config.json', true);
     $captcha = $R['captcha'];
     //Captcha response send by client
     $data = array('secret' => $C['RECAPTCHA_PRIVATE_KEY'], 'response' => $captcha, 'remoteip' => rawurlencode($_SERVER['REMOTE_ADDR']));
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
     // receive server response ...
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $server_output = curl_exec($ch);
     curl_close($ch);
     $response = json_decode($server_output, true);
     if ($response['success'] === false) {
         throw new MyException("No he pogut validar que siguis una persona.");
     }
 }
Beispiel #3
0
 /**
  * Funció que em retorna el document de tancament
  **/
 public static function generaDocumentTancament($idSessio)
 {
     \PhpOffice\PhpWord\Settings::setTempDir(BASEURL . 'tmp/');
     $phpword = new \PhpOffice\PhpWord\PhpWord();
     $T = $phpword->loadTemplate(BASEURL . '/Data/Documents/InformeTancamentLaGorga.docx');
     $EM = new EspectaclesModel();
     $LlistatLocalitats = $EM->getLocalitatsForDocument($idSessio);
     if (sizeof($LlistatLocalitats) == 0) {
         throw new MyException('No he trobat cap seient ocupat.');
     }
     $RECAPTAT = array('TOTALS' => array('M' => array('PERSONES' => 0, 'PREU' => 0), 'T' => array('PERSONES' => 0, 'PREU' => 0), 'D' => array('PERSONES' => 0, 'PREU' => 0), 'TOTAL' => 0, 'PERSONES' => 0), 'TIPUS_ENTRADA' => array());
     $LC = $LlistatLocalitats['COMANDES'];
     $LS = $LlistatLocalitats['SESSIO'];
     $LE = $LlistatLocalitats['ESPECTACLE'];
     foreach ($LlistatLocalitats['LOCALITATS'] as $K => $LTO) {
         $OP = $LTO->getPreu();
         $idComanda = $LTO->localitat['l_idComanda'];
         $TipusPagament = $LC[$idComanda]->comanda['co_TipusPagament'];
         $NomPreu = $OP->preu['nom'];
         $Import = $OP->preu['import'];
         if ($LTO->localitat['l_estat'] == 'O') {
             if (!isset($RECAPTAT['TOTALS'][$TipusPagament])) {
                 $RECAPTAT['TOTALS'][$TipusPagament] = array('PERSONES' => 0, 'PREU' => 0);
             }
             //Sumem import al recaptat per tipus pagament
             $RECAPTAT['TOTALS'][$TipusPagament]['PREU'] += $Import;
             $RECAPTAT['TOTALS'][$TipusPagament]['PERSONES'] += 1;
             //Sumem import al total recaptat
             $RECAPTAT['TOTALS']['TOTAL'] += $Import;
             //Sumem l'import a la persona
             $RECAPTAT['TOTALS']['PERSONES'] += 1;
             //Sumem import al tipus de preu
             if (!isset($RECAPTAT['TIPUS_ENTRADA'][$NomPreu])) {
                 $RECAPTAT['TIPUS_ENTRADA'][$NomPreu] = array('TOTAL' => 0, 'PERSONES' => 0, 'PREU' => $Import);
             }
             //Sumem import al total per tipus de preu
             $RECAPTAT['TIPUS_ENTRADA'][$NomPreu]['TOTAL'] += $Import;
             //Sumem persona al tipus de preu
             $RECAPTAT['TIPUS_ENTRADA'][$NomPreu]['PERSONES'] += 1;
         } else {
             //Sumem import al tipus de preu
             if (!isset($RECAPTAT['TIPUS_ENTRADA']['Reserves'])) {
                 $RECAPTAT['TIPUS_ENTRADA']['Reserves'] = array('TOTAL' => 0, 'PERSONES' => 0, 'PREU' => 0);
             }
             //Sumem import al total per tipus de preu
             $RECAPTAT['TIPUS_ENTRADA']['Reserves']['TOTAL'] = 0;
             //Sumem persona al tipus de preu
             $RECAPTAT['TIPUS_ENTRADA']['Reserves']['PERSONES'] += 1;
         }
     }
     $T->setValue('Espectacle', htmlspecialchars($LE->espectacle['e_Titol']));
     $T->setValue('Dia', htmlspecialchars($LS->sessio['tmp_Dia']));
     $T->setValue('Hora', htmlspecialchars($LS->sessio['tmp_Hora']));
     $T->setValue('Organitzador', htmlspecialchars($LE->espectacle['e_OrganitzadorNom']));
     $T->setValue('Cif', htmlspecialchars($LE->espectacle['e_OrganitzadorCif']));
     $T->setValue('Recaptat', $RECAPTAT['TOTALS']['TOTAL']);
     $T->setValue('Online', $RECAPTAT['TOTALS']['T']['PREU']);
     $T->setValue('Datafon', $RECAPTAT['TOTALS']['D']['PREU']);
     $T->setValue('Metalic', $RECAPTAT['TOTALS']['M']['PREU']);
     $T->setValue('NOnline', $RECAPTAT['TOTALS']['T']['PERSONES']);
     $T->setValue('NDatafon', $RECAPTAT['TOTALS']['D']['PERSONES']);
     $T->setValue('NMetalic', $RECAPTAT['TOTALS']['M']['PERSONES']);
     $T->setValue('Persones', $RECAPTAT['TOTALS']['PERSONES']);
     $T->cloneRow('rowValue', sizeof($RECAPTAT['TIPUS_ENTRADA']));
     $i = 1;
     foreach ($RECAPTAT['TIPUS_ENTRADA'] as $K => $V) {
         $T->setValue('rowValue#' . strval($i), htmlspecialchars($K));
         $T->setValue('rowQuantitat#' . strval($i), $V['PERSONES']);
         $T->setValue('rowPreu#' . strval($i), $V['PREU']);
         $T->setValue('rowImport#' . strval($i), $V['TOTAL']);
         $i++;
     }
     $T->setValue('Total', $RECAPTAT['TOTALS']['TOTAL']);
     $config = J::loadJsonConfigFile("config.json");
     $importTaxa1Dia = floatval($config['TAXA_OCUPACIO']);
     $importTaxa = $RECAPTAT['TOTALS']['TOTAL'] * 25 / 100;
     if ($importTaxa > $importTaxa1Dia) {
         $importTaxa = $importTaxa1Dia * 0.3;
     }
     $T->setValue('ImportTaxa', $importTaxa);
     $T->saveAs(BASEURL . 'Data/Documents/S' . $idSessio . '.docx');
     return true;
 }
Beispiel #4
0
 public static function validaPagamentTPV($Ds_SignatureVersion, $Ds_MerchantParameters, $Ds_Signature, $getTPV = false)
 {
     //Creem objecte
     $RedSysTmp = new RS();
     //Aquest el creem per carregar les dades inicials
     $RedSys = new RS();
     //Aquest tindrà les dades tant si entrem per tpv com si no hi entrem
     $Config = Json::loadJsonConfigFile('config.json');
     $CTO = new ComandaTableObject();
     //Descodifiquem i passem a array els paràmetres
     $decode = $RedSysTmp->decodeMerchantParameters($Ds_MerchantParameters);
     $RedSysTmp->stringToArray($decode);
     //Si entrem sense haver passat pel TPV ( o sigui, metàl·lic o reserva o 0 euros )
     $Par = array('Error' => "");
     if (isset($RedSysTmp->vars_pay['Ds_Merchant_MerchantData'])) {
         foreach ($RedSysTmp->vars_pay as $K => $V) {
             $tmp = str_replace("_Merchant_", "_", $K);
             $RedSys->setParameter($tmp, $V);
         }
         $RedSys->setParameter('Ds_Response', '0000');
         $RedSys->setParameter('Ds_Order', '0');
         $RedSys->setParameter('Ds_AuthorisationCode', '0');
     } else {
         //No cal fer cap canvi, simplement ho passo tot junt
         $RedSys = $RedSysTmp;
     }
     //Carreguem la id de l'entrada i comencem el procés
     $tmp = explode('-', $RedSys->getParameter('Ds_MerchantData'));
     if (!isset($tmp[1])) {
         $Par['Error'] = "ENTRADA";
     } else {
         $Par['idComanda'] = intval($tmp[1]);
         $idComanda = $Par['idComanda'];
         $CTO->loadComanda($tmp[1]);
         if ($CTO->getComandaId() > 0) {
             //Generem la signatura
             $signatura_rebuda = $Ds_Signature;
             //Només generem la signatura si entrem per TPV sinó la validem automàticament
             $signatura_generada = $signatura_rebuda;
             if (!isset($RedSysTmp->vars_pay['Ds_Merchant_MerchantData'])) {
                 $signatura_generada = $RedSys->createMerchantSignatureNotif($Config['TPV_ENT_PASSWORD'], $Ds_MerchantParameters);
             }
             //Si la signatura és correcta i no ha donat error, marquem la matrícula com a pagada
             if ($signatura_rebuda != $signatura_generada) {
                 $Par['Error'] = "SIGNATURA";
             } elseif ($RedSys->getParameter('Ds_Response') != '0000') {
                 $Par['Error'] = "RESPONSE";
             } else {
                 //Si estem a la crida automàtica del GetTPV fem les tasques que toquen
                 if ($getTPV) {
                     $CTO->comanda['co_estat'] = ComandaTableObject::TIPUS_ESTAT_PAGAT;
                     $CTO->comanda['co_TpvCode'] = $RedSys->getParameter('Ds_AuthorisationCode');
                     $CTO->comanda['co_TpvOrder'] = $RedSys->getParameter('Ds_Order');
                     $CTO->doSave();
                     //Guardem les dades de la targeta
                     $CTO->doMarcarPagatsOK();
                     //Tots els seients en estat P, passen a O
                     //Actualitzem les places lliures
                     foreach (array_keys($CTO->getLlistatLocalitats()) as $idSessio) {
                         //Carreguem les sessions de la comanda i actualitzem
                         $STO = new SessioTableObject(null, SessioTableObject::FROM_EMPTY);
                         $STO->loadById($idSessio);
                         //Carrego els seients lliures i els guardo
                         $STO->updateLocalitatsLliures();
                     }
                     //Només enviem el correu amb entrades si és una venda i existeix el correu.
                     self::sendEmailComanda($CTO);
                 }
             }
         } else {
             $Par['Error'] = 'COMANDA';
         }
     }
     $Par['Ds_Response'] = $RedSys->getParameter('Ds_Response');
     $Par['Ds_MerchantData'] = $RedSys->getParameter('Ds_MerchantData');
     $Par['CTO'] = $CTO;
     return $Par;
 }