Files
bilety.brzezovka.pl/custom.php
2025-04-30 23:59:49 +02:00

75 lines
2.3 KiB
PHP

<?php
include 'libraries/medoo/medoo.php';
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => 'martins_bilety',
'server' => 'localhost',
'username' => 'martins_bilety',
'password' => 'fnT1G)-cOJA6x[-v',
'charset' => 'utf8'
] );
// $results = $mdb->select('orders', '*', ['payment_status' => 1]);
// $results = $mdb->select('orders', '*', [
// 'AND' => [
// 'payment_status' => 1,
// 'id' => 171
// ]
// ]);
// foreach ( $results as $order ) {
// $order['tickets'] = $mdb -> select( 'order_tickets', '*', [ 'order_id' => $order['id'] ] );
// $api = array();
// $api["api_id"] = "9fa7772af97ab35b6d8a1cd05ac9e1b5";
// $api["api_zadanie"] = "1";
// $api["dokument_rodzaj"] = "20";
// $api["dokument_dostep"] = "1";
// $api["dokument_miejsce"] = "Brzezovka sklep internetowy";
// $api["dokument_data_w"] = date("d-m-Y", strtotime($order['date_added']));
// $api["dokument_data_s"] = date("d-m-Y", strtotime($order['payment_date']));
// $api["nabywca_imie"] = $order['name'];
// $api["nabywca_nazwisko"] = $order['surname'];
// $api["nabywca_email"] = $order['email'];
// if($order['city']){
// $api["nabywca_miasto"] = $order['city'];
// }
// if($order['zip_code']){
// $api["nabywca_kod"] = $order['zip_code'];
// }
// if($order['street']){
// $api["nabywca_ulica"] = $order['street'];
// }
// foreach ($order['tickets'] as $key => $value)
// {
// $key += 1;
// $api["produkt_nazwa_$key"] = $value['name'];
// $api["produkt_ilosc_$key"] = $value['quantity'];
// $api["produkt_jm_$key"] = "2";
// $api["produkt_stawka_vat_$key"] = "23";
// $api["produkt_wartosc_brutto_$key"] = $value['price'] * $value['quantity'];
// }
// $curl = curl_init();
// curl_setopt($curl, CURLOPT_URL, "https://www.fakturowo.pl/api");
// curl_setopt($curl, CURLOPT_POST, 1);
// curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 300);
// curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($curl, CURLOPT_POSTFIELDS, $api);
// $result = curl_exec($curl);
// curl_close($curl);
// $result = explode("\n", $result);
// if($result[0] == 1) {
// $mdb -> update( 'orders', ['invoice_url' => $result[2]], ['id' => $order['id']] );
// }
// echo '<pre>';
// print_r($result);
// echo '<br/>---<br/></pre>';
// }