';
$out['text'] = sprintf("%s\n\n", '');
if ($type == 'photo') {
$out['html'].= <<
{$lang_photoshop['item_id_checkout']} |
{$lang_photoshop['type_chckout']} |
{$lang_photoshop['amount_checkout']} |
{$lang_photoshop['total_checkout']} |
EOT;
$out['text'].= sprintf("%10.10s\t", $lang_photoshop['item_id_checkout']).
sprintf("%30.30s\t", $lang_photoshop['item_name_checkout']).
sprintf("%15.15s\t",$lang_photoshop['type_chckout']).
sprintf("%10.10s\t",$lang_photoshop['amount_checkout']).
sprintf("%15.15s\n",$lang_photoshop['total_checkout']);
} elseif(($type == 'cd') && (photoshop_in_array_multi("CD", $shop_array_photos))) {
$out['html'].= <<
{$lang_photoshop['item_id_checkout']} |
{$lang_photoshop['type_chckout']} |
|
|
EOT;
$out['text'].= sprintf("%10.10s\t", $lang_photoshop['item_id_checkout']).sprintf("%15.15s\n",$lang_photoshop['type_chckout']);
}
foreach ($shop_array_photos as $key => $item_id) {
$select_columns = 'filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, title, aid';
$result = cpg_db_query("SELECT $select_columns from {$CONFIG['TABLE_PICTURES']} WHERE pid='{$item_id['pid']}' LIMIT 1");
$row = mysql_fetch_array($result);
$price = $SHOP_CONFIG[$item_id['id']]['price'];
//price override
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$row['aid']}");
while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);
//here we check if the price is set to -1 (that's a free item, and we set price for display reasons back to 0.00)
//do the same in cart and calc total an in function item_price, pricelist, photoshop_add_data
if ($price < 0) {
$price = "0.00";
}
//html resize thumb
if ($CONFIG['enable_mini_thumbs'] == '1') { // if you use the modpack and have enabled mini thumbs -> these get used instead of html resized thumbs
$thumb_url = get_pic_url($row, 'mini');
$destWidth = $CONFIG['mini_thumb_width'];
$destHeight = $CONFIG['mini_thumb_height'];
} else {
$thumb_url = get_pic_url($row, 'thumb');
$new_size = 60;
$ratio = max($row['pwidth'], $row['pheight']) / $new_size;
$ratio = max($ratio, 1.0);
$destWidth = (int)($row['pwidth'] / $ratio);
$destHeight = (int)($row['pheight'] / $ratio);
}
if ($item_id['id'] == 'CD') {
$out['html'].= <<
|
{$item_id['id']} text |
|
|
EOT;
$out['text'].= sprintf("%10.10s\t", $item_id['pid']).sprintf("%15.15s\n",$item_id['id']);
} else {
$price = number_format($price*$item_id['amount'],2);
$out['html'].= <<
|
{$SHOP_CONFIG[$item_id['id']]['name']} |
{$item_id['amount']} |
{$price} {$CONFIG['photo_shop_currency']} |
EOT;
$out['text'].= sprintf("%10.10s\t", $item_id['pid']).
sprintf("%30.30s\t",$row['filename']).
sprintf("%15.15s\t", $SHOP_CONFIG[$item_id['id']]['name']).
sprintf("%10.10s\t", $item_id['amount']).
sprintf("%15.15s\n",$CONFIG['photo_shop_currency'].' '.$price);
}
}
$out['html'] .= " ";
return $out[$template];
}
function photoshop_add_data($shop_data, $order_id, &$free_item){
global $CONFIG, $SHOP_CONFIG, $cd_price, $cd_counter, $discount_calc, $shipping_price_calc;
$otime = localised_timestamp();
$picture_total = 0;
foreach ($shop_data as $key => $item_id) {
$pid = $item_id['pid'];
$amount = $item_id['amount'];
$size2 = $SHOP_CONFIG[$item_id['id']]['size'];
if ($item_id['id']=="CD") {
$size = "CD";
$price = $cd_price[1];
$free_order = false; // this is not a free order
// without paid status
$sql = "INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `pid`, `quantity`, `size`, `size2`, `price`, `otime`) VALUES ('$order_id', '".USER_ID."', '$pid', '$amount', '$size', '$size2','$price', '$otime')";
} else {
$size = $SHOP_CONFIG[$item_id['id']]['name'];
$price = $SHOP_CONFIG[$item_id['id']]['price'];
//price override
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");
while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);
//here we check if the price is set to -1 (that's a free item, and we set price for display reasons back to 0.00)
//do the same in cart and calc total an in function item_price, pricelist, photoshop_add_data
if ($price == -1) {
$price = "0.00";
if(!isset($free_order)) $free_order = true; //this is a free order, only set if there hasn't been a paid item before
$free_item = true; // always set
// add status paid to sql
$sql = "INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `pid`, `quantity`, `size`, `size2`, `price`, `otime`, `status`) VALUES ('$order_id', '".USER_ID."', '$pid', '$amount', '$size', '$size2','$price', '$otime', '2')";
} else {
// without status set to paod -> no free item
$sql = "INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `pid`, `quantity`, `size`, `size2`, `price`, `otime`) VALUES ('$order_id', '".USER_ID."', '$pid', '$amount', '$size', '$size2','$price', '$otime')";
$free_order = false; //this is not a free order
}
$picture_total = ($picture_total+$price*$amount);
}
//add single item
$results = cpg_db_query ($sql);
}
//add order total
if ($free_order === true) { //this is a free order, the total order is set paid
$sql2 = "INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `cd`, `quantity`, `price`, `otime`, `status`) VALUES ('$order_id', '".USER_ID."', '1', '".($cd_counter['cd']+$cd_counter['photo'])."', '".($picture_total+$cd_price[1]+$shipping_price_calc-$discount_calc)."', '$otime', '2')";
}
else //this is a paid order, status unpaid
{
$sql2 = "INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `cd`, `quantity`, `price`, `otime`) VALUES ('$order_id', '".USER_ID."', '1', '".($cd_counter['cd']+$cd_counter['photo'])."', '".($picture_total+$cd_price[1]+$shipping_price_calc-$discount_calc)."', '$otime')";
}
$results2 = cpg_db_query ($sql2);
return $results2;
}
function photoshop_email_the_user($message, $subject, $admin = '')
{
global $CONFIG, $SHOP_CONFIG, $lang_photoshop, $cd_price, $order_id, $discount, $shipping_price;
$user_info = photoshop_user_details(USER_ID);
$email = $user_info['user_email'];
if ($admin) {
$user_info['user_email']='admin';
}
$template_vars = array(
'{ORDER_ID}' => $order_id,
'{SITE_NAME}' => $CONFIG['gallery_name'],
'{PRICE}' => number_format(($cd_price[0]+$cd_price[1]+$shipping_price-$discount),2),
'{USER_NAME}' => (USER_NAME),
'{USER_EMAIL}' => $email,
'{ADMIN}' => $CONFIG['gallery_name'],
'{LINK}' => $CONFIG['ecards_more_pic_target'],
'{USER_PROFILE1}' => $user_info['user_profile1'],
'{USER_PROFILE2}' => $user_info['user_profile2'],
'{USER_PROFILE3}' => $user_info['user_profile3'],
'{USER_PROFILE4}' => $user_info['user_profile4'],
'{USER_PROFILE5}' => $user_info['user_profile5'],
'{USER_PROFILE6}' => $user_info['user_profile6'],
);
$mail_body=nl2br(strtr($message, $template_vars));
if(cpg_mail($user_info['user_email'], $subject, $mail_body, 'text/plain', $CONFIG['gallery_name'], $CONFIG['gallery_admin_email'] )) {
return true;
}
return false;
}
function photoshop_add_field(&$form_fields, $field, $value) {
$form_fields["$field"] = $value;
}
?> |