コード例 #1
0
echo $date_to;
?>
" />

<!--<input type="hidden" name="business" value="*****@*****.**">-->
                        <input type="hidden" name="business" value="*****@*****.**">
                        <input type="hidden" name="cmd" value="_xclick">
                        <input type="hidden" name="item_name" value="<?php 
echo $account_detail['plan'];
?>
 (<?php 
echo $account_detail['total_years'];
?>
)">
                        <input type="hidden" name="item_number" value="<?php 
echo generate_invoice_number();
?>
">
                        <input type="hidden" name="quantity" value="<?php 
echo $account_detail['months_in_years'];
?>
">
                        <input type="hidden" name="amount" value="<?php 
echo $account_detail['month'];
?>
">
                        <input type="hidden" name="no_shipping" value="1">
                        <input type="hidden" name="currency_code" value="USD">
                        <input type="hidden" name="handling" value="0">
                        <input type='hidden' name='rm' value='2'>
                        <input type="hidden" name="cancel_return" value="<?php 
コード例 #2
0
function cron_tpl_merge_process($tpls, $entry, $type = "", $invoice_number = "")
{
    echo "inside merge process.<br/>";
    require_once "D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\classes\\TransformDocAdv.inc";
    require_once "D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\classes\\CreateDocx.inc";
    $final_doc_url = "";
    $formdetail = RGFormsModel::get_form($entry["form_id"]);
    $new_xml = array();
    $unique_number = date('ymdhis') . "-" . $entry["id"];
    $n = str_replace('+', '_', urlencode($formdetail->title)) . ($type != "" ? "_" . $type : "") . "_" . $unique_number . '-cron.docx';
    if ($type == "Invoice" && $invoice_number == "") {
        $invoice_number = generate_invoice_number();
    }
    $i = 1;
    foreach ($tpls as $tpl) {
        $file = $tpl['file'];
        $value = $tpl['values'];
        $value["Invoice_number"] = $invoice_number;
        if (!empty($file['dir_path']) && !empty($file['filepath'])) {
            $cookie_file_path = $file['filepath'];
            /*echo '<br/>Cookie path: '.$cookie_file_path;
            		if (!file_exists($cookie_file_path)) {
                           echo 'file does not exist';
                       }
                       else {
                       	echo 'file exists';
                       }*/
            //Create PHPDocx object using the template file defined above.
            $docx = new CreateDocxFromTemplate($cookie_file_path);
            $variables = array();
            $variables_html = array();
            foreach ($value as $k => $v) {
                $k_val = explode("-", $k);
                $e_val = array("SIGNED", "PRESENCE", "LengthContent");
                if (count($k_val) > 1 && in_array($k_val[1], $e_val)) {
                    $variables_html[$k] = $v;
                } else {
                    $variables[$k] = $v;
                }
            }
            //Load the array into the PHPDocx object so that the variable values are inserted into the document template.
            $docx->replaceVariableByText($variables);
            if (!empty($variables_html)) {
                foreach ($variables_html as $hk => $hv) {
                    if (!empty($hv)) {
                        $docx->replaceVariableByHTML($hk, 'inline', $hv, array());
                    } else {
                        $docx->replaceVariableByText(array($hk => ""));
                    }
                }
            }
            //echo '<br/>About to check if file exists...';
            if (!file_exists($file['dir_path'] . '/doc/temps/cron/')) {
                mkdir($file['dir_path'] . '/doc/temps/cron/', 0777, true);
            }
            //Define the output location and name of the document to be saved (e.g. Saves in 'Output' folder relative to the location
            //Of this script, and the name of the file will be 'testDeed'.
            $outputWordFileNameAndPath = $file['dir_path'] . '/doc/temps/cron/' . date('ymdhis') . $i . '-cron';
            $newfile = $outputWordFileNameAndPath . ".docx";
            $newfile_pdf = $outputWordFileNameAndPath . ".pdf";
            //Define the base directory
            $baseDirectory = '';
            //Create the document and save it.
            $docx->createDocx($outputWordFileNameAndPath);
            //Conver the document to PDF and save.
            $docx->transformDocxUsingMSWord($baseDirectory . $outputWordFileNameAndPath . '.docx', $baseDirectory . $outputWordFileNameAndPath . '.pdf');
            if (file_exists($newfile_pdf)) {
                //chmod($newfile_pdf, 0777);
                $new_xml['temp_file'][] = $newfile_pdf;
                //chmod($newfile_pdf, 0777);
            }
        }
        $i++;
    }
    $c = count($new_xml['temp_file']);
    if (!file_exists($file['dir_path'] . '/doc/cron/')) {
        mkdir($file['dir_path'] . '/doc/cron/', 0777, true);
    }
    $final_doc = $file['dir_path'] . '/doc/cron/' . $n;
    $final_doc = str_replace('.docx', '.pdf', $final_doc);
    $final_doc = str_replace("/", "\\", $final_doc);
    $final_doc = str_replace("\\", "\\\\", $final_doc);
    $final_doc_url = $file['dir_url'] . '/doc/cron/' . $n;
    $final_doc_url = str_replace('.docx', '.pdf', $final_doc_url);
    if ($c > 1) {
        $alldoc = $new_xml['temp_file'];
        cron_mergerAllPdf($alldoc, $final_doc);
    } else {
        copy($new_xml['temp_file'][0], $final_doc);
    }
    if (file_exists($final_doc)) {
        chmod($final_doc, 0777);
        foreach ($new_xml['temp_file'] as $y) {
            if (file_exists(ConvertDirectoryPath($y))) {
                chmod(ConvertDirectoryPath($y), 0777);
            }
            @unlink(ConvertDirectoryPath($y));
            $y = str_replace(".pdf", ".docx", $y);
            @unlink(ConvertDirectoryPath($y));
        }
        cron_SaveToDB($final_doc_url, $final_doc, $entry["id"], $type, $invoice_number);
        return $final_doc_url;
    }
    foreach ($new_xml['temp_file'] as $y) {
        if (file_exists(ConvertDirectoryPath($y))) {
            chmod(ConvertDirectoryPath($y), 0777);
        }
        @unlink(ConvertDirectoryPath($y));
        $y = str_replace(".pdf", ".docx", $y);
        @unlink(ConvertDirectoryPath($y));
    }
    return "";
}
コード例 #3
0
 function generate_invoice_number($params = "")
 {
     $a = 1;
     if (get_option('invoice_increment') !== false) {
         $a = get_option('invoice_increment');
         $a = $a + 1;
         update_option('invoice_increment', $a);
     } else {
         add_option('invoice_increment', 1);
     }
     if (strlen($a) < 4) {
         $a = str_pad($a, 4, "0", STR_PAD_LEFT);
     }
     /*$a="";
                     for ($i = 0; $i<10; $i++) 
     		{
     			$a .= mt_rand(0,9);
     		}*/
     $return = date("y") . "-" . $a;
     $where = 'invoice_number ="' . $retrun . '"';
     $parameters = array('where' => $where);
     $list = TemplateData::getDocumentsList($parameters);
     if (count($list)) {
         $return = generate_invoice_number($params);
     }
     return $return;
 }