Example #1
0
function returnquote($address,$weight,$vol,$settings,$items) { 
     
   $quotes = getQuotes($address,$weight,$vol,$settings,$items);

   if (!isset($quotes['error'])) {
   
		 		foreach ($quotes as $quote) {
	            
	                    if ($quote['cost'] > 0) {
	                                        
	                        $postmethod = strtolower($quote['type']);
	
	                        $quote_data['startrack_' . $postmethod] = array(
	                            'code' => 'startrack.startrack_' . $postmethod,
	                            'title' => $quote['description'],
	                            'cost' => $quote['cost'],
	                            'tax_class_id' => '',
	                            'text' => ''
	                        );
	                        	                        
	                    }
	                }
	            
	} else {
	
		$error = $quotes['error'];
				
	}
      		
	return $quote_data;

}
Example #2
0
                $query = mysqli_query($con, $sql) or trigger_error("Query Failed: " . mysqli_error($con));
                // remove existing tags
                $sql = "DELETE FROM quote_tags WHERE qid=" . $qid;
                $query = mysqli_query($con, $sql) or trigger_error("Query Failed: " . mysqli_error($con));
                insertTags($qid, $_POST['tags']);
            } else {
                if ($isAdmin && strpos($_POST['form_id'], 'delete-') === 0) {
                    error_log($_POST['form_id'] . ' called');
                    $qid = (int) mysqli_real_escape_string($con, substr($_POST['form_id'], 7));
                    error_log($qid . ' quote');
                    $sql = "DELETE FROM quotes WHERE id=" . $qid;
                    $query = mysqli_query($con, $sql) or trigger_error("Query Failed: " . mysqli_error($con));
                    // remove tag relationships
                    $sql = "DELETE FROM quote_tags WHERE qid=" . $qid;
                    $query = mysqli_query($con, $sql) or trigger_error("Query Failed: " . mysqli_error($con));
                    // remove orphan tags
                    $sql = "DELETE FROM tags WHERE id NOT IN (SELECT tid FROM quote_tags)";
                    $query = mysqli_query($con, $sql) or trigger_error("Query Failed: " . mysqli_error($con));
                } else {
                    if ($_POST['form_id'] == 'getquotes') {
                        $data['quotes'] = getQuotes();
                    }
                }
            }
        }
    }
    $data['tags'] = getTags();
    $data['total'] = getQuoteNumber();
}
$json = json_encode($data);
echo $json;