Beispiel #1
0
    function select_or_insert_where() {
        global $auth_session;
        global $db;
        
	$domain_id = domain_id::get($this->domain_id);

        if($this->filter == "date")
        {
            $where = "and ap.ac_date between '$this->start_date' and '$this->end_date'";
        }

        $sql = "SELECT 
                    pt_id,
		            count(DISTINCT pt_id) as count
                from 
                    ".TB_PREFIX."payment_types 
                WHERE 
                    pt_description = :pt_description
		        AND 
		            domain_id = :domain_id
                GROUP BY
                    pt_id;";
        
        $sth = $db->query($sql,':pt_description',$this->type,':domain_id',$domain_id);
	$pt = $sth->fetch();
	
	if($pt['count'] =="1")
	{
		return $pt['pt_id'];
	}
	//add new payment type if no Paypal type
	if($pt =="")
	{
        $SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes();
        
        $new_payment_type_data = array(
            'pt_description'    => $this->type,
            'pt_enabled'        => 1
        );
		$SI_PAYMENT_TYPES->insert($new_payment_type_data);

		$payment_type = new payment_type();
		$payment_type->type = $this->type;
		$payment_type->domain_id = $domain_id;
		return $payment_type->select_or_insert_where();
	}
    }
            'ac_notes'          => $paypal_data,
            'ac_date'           => date( 'Y-m-d', strtotime($p->ipn_data['payment_date'])),
            'online_payment_id' => $p->ipn_data['txn_id']
        );

			$payment_type = new payment_type();
			$payment_type->type = "Paypal";
			$payment_type->domain_id = $domain_id;
            
        $payment_type_data = array(
            'type'  => 'Paypal'
        );

        $db_payment_type = $SI_PAYMENT_TYPES->findByName($payment_type_data['type']);
        if (!$db_payment_type) {
            $SI_PAYMENT_TYPES->insert($payment_type_data);
            $db_payment_type = $SI_PAYMENT_TYPES->findByName($payment_type_data['type']);
        }
        $payment_data['ac_payment_type'] = $db_payment_type['pt_id'];
        
		$logger->log('Paypal - payment_type='.$payment_data['ac_payment_type'], Zend_Log::INFO);
		
        // Insert the payment
        $SI_PAYMENTS->insert($payment_data);

		$invoice = invoice::select($p->ipn_data['invoice']);
		#$invoice = invoice::select($_POST['invoice']);
		$biller = $SI_BILLER->getBiller($invoice['biller_id']);

		//send email
		$body =  "A Paypal instant payment notification was successfully recieved into Simple Invoices\n";