Example #1
0
 public function gerateBilling()
 {
     $order = null;
     $customers = $this->getUserID();
     $structJsonArray = array();
     foreach ($customers as $customer) {
         $structJson = new Json();
         $structJson->setCustomerId($customer['zoho_books_contact_id']);
         $structJson->setDate(date('d-m-Y'));
         $invoices_per_costumer = $this->getUserInvoice($customer['zoho_books_contact_id']);
         //var_dump($invoices_per_costumer);
         foreach ($invoices_per_costumer as $invoice_each) {
             $item = new Item();
             $order++;
             $item->setItemId("460000000027017");
             $item->setProjectId("");
             $item->setExpenseId("");
             $item->setName("Print Services");
             $item->setDescription($invoice_each['description']);
             $item->setItemOrder($order);
             $item->setRate($invoice_each['rate']);
             $item->setUnit("Nos");
             $item->setQuantity(1.0);
             $item->setDiscount(0.0);
             $item->setTaxId("460000000027005");
             $structJson->setLineItems($item);
             $item = null;
         }
         $structJson->setNotes("Thanks for your business.");
         $order = null;
         $structJsonArray[] = $structJson;
         $structJson = null;
     }
     return $structJsonArray;
 }
Example #2
0
 function autoMail()
 {
     global $database;
     //$itemsArr = array();
     $today = date("Y-m-d");
     $this->query = "select * from  items where BidEndOn ='{$today}' AND highest_bid!=0";
     $result = mysql_query($this->query);
     while ($row = mysql_fetch_array($result)) {
         $item = new Item();
         $item->setItemId($row["ItemID"]);
         $item->setTitle($row["Title"]);
         $item->setMinPrice($row["min_price"]);
         $item->setCategory($row["Category"]);
         $item->setOwnerId($row["OwnerID"]);
         $ad = date("Y-m-d H:i:s", strtotime($row['addedOn']));
         $item->setHighestBid($row["highest_bid"]);
         $item->setAddedOn($ad);
         $item->setBiddingEndOn($row["BidEndOn"]);
         $item->setDesc($row["Description"]);
         $item->setStatus($row["Status"]);
         $this->query = "SELECT PicDate,PicPath FROM itempics WHERE OwnId = " . $item->ownerId . " AND PicDate = '" . $ad . "'";
         $res = mysql_query($this->query);
         $r = mysql_fetch_array($res);
         $item->setPicPath($r['PicPath']);
         $this->query = "select email from user where UserID={$item->ownerId}";
         $res = mysql_query($this->query);
         $r = mysql_fetch_row($res);
         $OwnerEmail = $r[0];
         $this->query = "select bids.BidderID from items INNER JOIN bids ON items.highest_bid=bids.amount where items.ItemID ={$item->itemId}";
         $res = mysql_query($this->query);
         $r = mysql_fetch_row($res);
         $bidderId = $r[0];
         $this->query = "select email from user where UserID={$bidderId}";
         $res = mysql_query($this->query);
         $r = mysql_fetch_row($res);
         $WinnerEmail = $r[0];
         echo "\nOwner email:" . $OwnerEmail . "\n";
         echo "\nWinner email:" . $WinnerEmail . "\n";
         $this->query = "update account set balance=balance+{$item->highestBid} where UserID={$item->ownerId}";
         mysql_query($this->query);
         $this->query = "delete from bids where ItemID={$item->itemId}";
         mysql_query($this->query);
         $this->query = "update items set OwnerId ={$bidderId}, status='sold' where ItemID={$item->itemId}";
         mysql_query($this->query);
         $this->query = "insert into WonItems (winnerId,ownerId) values ({$bidderId}, {$item->ownerId} )";
         mailForOwner($OwnerEmail, $item);
         mailForWinner($WinnerEmail, $item);
     }
 }
Example #3
0
 function getItem($id)
 {
     global $database;
     $item = new Item();
     $this->query = "select * from items where ItemID='{$id}'";
     $result = mysql_query($this->query);
     if (mysql_num_rows($result) > 0) {
         $row = mysql_fetch_row($result);
         $item->setItemId($row[0]);
         $item->setTitle($row[1]);
         $item->setMinPrice($row[2]);
         $item->setHighestBid($row[3]);
         $item->setCategory($row[4]);
         $item->setOwnerId($row[5]);
         $item->setAddedOn($row[6]);
         $item->setBiddingEndOn($row[7]);
         $item->setDesc($row[8]);
         $item->setStatus($row[9]);
     }
     return $item;
 }
Example #4
0
    function autoMail()
    {
        global $database;
        //$itemsArr = array();
        $today = date("Y-m-d");
        $this->query = "select * from  items where BidEndOn ='{$today}' AND highest_bid!=0 AND status != 'sold'";
        $result = mysql_query($this->query);
        while ($row = mysql_fetch_array($result)) {
            $item = new Item();
            $item->setItemId($row["ItemID"]);
            $item->setTitle($row["Title"]);
            $item->setMinPrice($row["min_price"]);
            $item->setCategory($row["Category"]);
            $item->setOwnerId($row["OwnerID"]);
            $ad = date("Y-m-d H:i:s", strtotime($row['addedOn']));
            $item->setHighestBid($row["highest_bid"]);
            $item->setAddedOn($ad);
            $item->setBiddingEndOn($row["BidEndOn"]);
            $item->setDesc($row["Description"]);
            $item->setStatus($row["Status"]);
            print_r($item);
            $this->query = "SELECT PicDate,PicPath FROM itempics WHERE OwnId = " . $item->ownerId . " AND PicDate = '" . $ad . "'";
            $res = mysql_query($this->query);
            $r = mysql_fetch_array($res);
            $item->setPicPath($r['PicPath']);
            $this->query = "select email from user where UserID={$item->ownerId}";
            $res = mysql_query($this->query);
            $r = mysql_fetch_row($res);
            $OwnerEmail = $r[0];
            $ul = new UserLogic();
            $ownuser = $ul->getUser($item->ownerId);
            $this->query = "select bids.BidderID from items INNER JOIN bids ON items.highest_bid=bids.amount where bids.ItemID ={$item->itemId}";
            $res = mysql_query($this->query);
            $r = mysql_fetch_row($res);
            $bidderId = $r[0];
            echo $bidderId;
            $winuser = $ul->getUser($r[0]);
            $this->query = "select email from user where UserID={$bidderId}";
            $res = mysql_query($this->query);
            $r = mysql_fetch_row($res);
            $WinnerEmail = $r[0];
            echo "\nOwner email:" . $OwnerEmail . "\n";
            echo "\nWinner email:" . $WinnerEmail . "\n";
            require "fbmain.php";
            if ($facebook) {
                if ($ownuser->fb_id) {
                    try {
                        $wallpostpage = $facebook->api('/' . $ownuser->fb_id . '/feed', 'post', array('message' => 'Your item ' . $item->title . '. has been sold at price ' . $item->highestBid . '$. ', 'picture' => 'http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs1324.snc4/161996_166764056682774_6216247_q.jpg

', 'link' => 'http://www.facebook.com/apps/application.php?id=166764056682774', 'name' => 'eVeiling.com', 'cb' => ''));
                    } catch (FacebookApiException $e) {
                        print_r($o);
                    }
                }
                if ($winuser->fb_id) {
                    try {
                        $wallpostpage = $facebook->api('/' . $winuser->fb_id . '/feed', 'post', array('message' => 'You have won the auction of ' . $item->title . ' at ' . $item->highestBid . '$.', 'picture' => 'http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs1324.snc4/161996_166764056682774_6216247_q.jpg

', 'link' => 'http://www.facebook.com/apps/application.php?id=166764056682774', 'name' => 'eVeiling.com', 'cb' => ''));
                    } catch (FacebookApiException $e) {
                        print_r($o);
                    }
                }
            }
            $this->query = "update account set balance=balance+{$item->highestBid} where UserID={$item->ownerId}";
            mysql_query($this->query);
            $this->query = "delete from bids where ItemID={$item->itemId}";
            mysql_query($this->query);
            $this->query = "update items set OwnerId ={$bidderId}, status='sold' where ItemID={$item->itemId}";
            mysql_query($this->query);
            $this->query = "insert into WonItems (winnerId,ownerId,ItemId) values ({$bidderId}, {$item->ownerId},{$item->itemId} )";
            mysql_query($this->query);
            mailForOwner($OwnerEmail, $item);
            mailForWinner($WinnerEmail, $item);
        }
    }
Example #5
0
 function getPostedItems($id)
 {
     global $database;
     $itemsArr = array();
     $this->query = "select * from items where ownerid={$id}";
     $result = mysql_query($this->query);
     if ($result) {
         while ($row = mysql_fetch_array($result)) {
             $item = new Item();
             $item->setItemId($row["ItemID"]);
             $item->setTitle($row["Title"]);
             $item->setMinPrice($row["min_price"]);
             $item->setCategory($row["Category"]);
             $item->setOwnerId($row["OwnerID"]);
             $ad = date("Y-m-d H:i:s", strtotime($row['addedOn']));
             $item->setHighestBid($row["highest_bid"]);
             $item->setAddedOn($ad);
             $item->setBiddingEndOn($row["BidEndOn"]);
             $item->setDesc($row["Description"]);
             $item->setStatus($row["Status"]);
             $this->query = "SELECT PicDate,PicPath FROM itempics WHERE OwnId = " . $item->ownerId . " AND PicDate = '" . $ad . "'";
             $res = mysql_query($this->query);
             $r = mysql_fetch_array($res);
             $item->setPicPath($r['PicPath']);
             array_push($itemsArr, $item);
         }
         return $itemsArr;
     }
 }