Jump to content

FooKelvin

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by FooKelvin

  1. Hi All, Have look with this codes $tableHeads = "<tr><th>" . join('</th><th>', $names) . "</th></tr>\n"; if i echo $tableHeads, the data can be echo out. my question is there any way to echo it out without the .join. statement? instead of tr,th.. i need them to me input. Thank you
  2. Hello, I try to use this codes, but i didn't receive any email or appointment. // How to create outlook meeting request with PHP // If you don't use exchange server, the message arrives as ics attachment. <?php $to = 'kelvinfoodumb@gmail.com'; $subject = "Millennium Falcon"; $organizer = 'Darth Vader'; $organizer_email = 'darthvader@arturito.net'; $participant_name_1 = 'Kelvin'; $participant_email_1= 'kelvinfoodumb@gmail.com'; $location = "Stardestroyer-013"; $date = '20151215'; $startTime = '0800'; $endTime = '0900'; $subject = 'Millennium Falcon'; $desc = 'The purpose of the meeting is to discuss the capture of Millennium Falcon and its crew.'; $headers = 'Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;\r\n'; $headers .= "Content-Type: text/plain;charset=\"utf-8\"\r\n"; #EDIT: TYPO $message = "BEGIN:VCALENDAR\r\n VERSION:2.0\r\n PRODID:-//Deathstar-mailer//theforce/NONSGML v1.0//EN\r\n METHOD:REQUEST\r\n BEGIN:VEVENT\r\n UID:" . md5(uniqid(mt_rand(), true)) . "example.com\r\n DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z\r\n DTSTART:".$date."T".$startTime."00Z\r\n DTEND:".$date."T".$endTime."00Z\r\n SUMMARY:".$subject."\r\n ORGANIZER;CN=".$organizer.":mailto:".$organizer_email."\r\n LOCATION:".$location."\r\n DESCRIPTION:".$desc."\r\n ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_1.";X-NUM-GUESTS=0:MAILTO:".$participant_email_1."\r\n END:VEVENT\r\n END:VCALENDAR\r\n"; $headers .= $message; mail($to, $subject, $message, $headers); ?> The Original post is here.
  3. Hi, I know php can send email with mailer function. I'm not sure is there no fucntion to send out invitation to Outlook with time,venue, topic and etc? Set the status to free or busy. Last time when I using vbscript is possible to do that.
  4. This is because i'm using SQL Agent to help me schedule the email trigger. I need the email to be send everyday automatically.
  5. Hi, I have a Procedures ready to auto send email to employee when the reminder date equal today. Let me show you what is inside my employee database. As you can see, there is two records for employee 1001. This is because this employee short notice for 2 months. [sdate] There is also a shortNotice which is in December is 4 day, in January is 18 days. So, the consist days is 18+4=22 Days This is my procedure code, it's working, this procedure will trigger out email if meet the criteria. ***REMEMBER TO CHANGE THE SERVER NAME & PORT NUMBER*** USE [RSA] GO /****** Object: StoredProcedure [dbo].[sp_send_cdosysmail] Script Date: 12/10/2015 3:55:00 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_send_cdosysmail] @From varchar(100)="notification@mail.com", @Subject varchar(100)="A Reminder for you", @body varchar(4000)=" ", @attachments varchar(4000)=NULL AS DECLARE @out_desc VARCHAR(1000), @out_mesg VARCHAR(10) DECLARE @empid nvarchar(255), @Name nvarchar(255), @Email nvarchar(255), @reminderDate datetime, @lastDay datetime, @shortNotice int, @consistsDays int, @sdate datetime Declare C1 CURSOR READ_ONLY FOR SELECT DISTINCT [empid],[Name],[Email],[reminderDate],[lastDay],[shortNotice],[consistsDays],[sdate] FROM [resigntblView] Declare @iMsg int Declare @hr int Declare @source varchar(255) Declare @description varchar(500) Declare @output varchar(1000) Declare @files table(fileid int identity(1,1),[file] varchar(255)) OPEN C1 FETCH NEXT FROM C1 INTO @empid,@Name, @Email, @reminderDate, @lastDay,@shortNotice,@consistsDays,@sdate WHILE @@FETCH_STATUS = 0 BEGIN IF DATEPART(DAY,@reminderDate) = DATEPART(DAY,GETDATE()) AND DATEPART(MONTH,@reminderDate) = DATEPART(MONTH,GETDATE()) AND DATEPART(YEAR,@reminderDate) = DATEPART(YEAR,GETDATE()) BEGIN SET @body = '<b>Hi ' + @Name + '</b><br />This is a reminder' + '<br /><br />Thank You' --************* Create the CDO.Message Object ************************ EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT --***************Configuring the Message Object ****************** -- This is to configure a remote SMTP server. -- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_configuration_sendusing.asp EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields ("http://schemas.microsoft.com/cdo/configuration/sendusing"). Value','2' -- This is to configure the Server Name or IP address. -- Replace MailServerName by the name or IP of your SMTP Server. EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver"). Value', '#######' --PUT YOUR SERVER HERE -- Save the configurations to the message object. EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null -- Set the e-mail parameters. EXEC @hr = sp_OASetProperty @iMsg, 'To', @Email EXEC @hr = sp_OASetProperty @iMsg, 'From', @From EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject -- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'. EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @body EXEC @hr = sp_OAMethod @iMsg, 'Send' -- Do some error handling after each step if you need to. -- Clean up the objects created. EXEC @hr = sp_OADestroy @iMsg END FETCH NEXT FROM C1 INTO @empid,@Name, @Email, @reminderDate,@lastDay,@shortNotice,@consistsDays,@sdate END CLOSE C1 DEALLOCATE C1 Once the Procedures is execute, this is the OUTPUT that i received in my inbox: Hi Foo, Kelvin This is a reminder Thank You This Email will Trigger two times since there is a two column of data. My question is, how to merge some of the data in one, and send the email only once. Expected Output: Hi Foo, Kelvin, You are required to compensate USD 100 to the Company in view of your 22 days of short notice. The 1 month of your notice period consist of 22 working days, (01-12-2015 - 31-12-2015), 4 Days The 2 month of your notice period consist of 22 working days, (01-01-2016 - 31-01-2016), 18 Days Thank You. Thanks for your big help.
  6. Hi, i have to created two pages. index.php search.php The field from index.php will call search.php. search.php is handling all the database and return back to index.php. For now, i able to call listed the items, just when i want to select one of the listed iteam, and reflect for other fields, it no response. <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/> <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css"/> <form action="" method="post"> <input type="text" placeholder="Name" id="customerAutocomplte" class="ui-autocomplete-input" autocomplete="off" /> <input type="text" id="Name"> </form> <script type="text/javascript"> $("#customerAutocomplte").autocomplete({ source: function( request, response ) { $.ajax({ url: "search.php", data: {term: request.term}, dataType: "json", success: function( data ) { response( $.map( data.myData, function( item ) { return { label: item.Name, value: item.id } })); }, select: function(event,ui){ $("#Name").val(ui.item.Name); } }); } }); </script> <?php //connect to your database require 'databaseConnection.php'; $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends $sql = "SELECT Name,[Employee ID] As id FROM headcount WHERE [Employee ID] LIKE '%".$term."%'"; $stmt = sqlsrv_query($conn, $sql); $options = array(); while (list($name, $empid) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { $options['myData'][] = array( 'Name' => $row_id['Name']=$name, 'id' => $row_id['id']=$empid ); } echo json_encode($options);//format the array into json data ?>
  7. Hi Guys, I have created a calendar view with this plug in. http://fullcalendar.io/ The calendar view will show calendar view by Start Date and End Date. So I have some problem with some of the event, the start date is from 01-January-2015 until 15-Jan-2015, but in between actually there is a break. For example, 01-January-2015 until 03-January-2015 13-January-2015 until 15-January-2015 So, because of the start date and the end date is so long, so in the calendar view, it block the calendar from 01/Jan until 15/Jan. Its look weird. Actually i have actual dates column in my database column in this format: 01-01-2015,02-01-2015,03-01-2015,13-01-2015,14-01-2015,15-01-2015Start Date column 01-01-2015 End Date column 15-01-2015So, i was wondering is there any script to detect each of date to separate the break in between the start date and end date. Thank You
  8. Hi Guys, I have to some scheduling export to excel like pull every week or daily. i found there is one solution for this is using MS SQL Server Agent. I guest i able to save the query. But the problem is the query result save in SERVER instead of the shared drive. Anyone have face this problem before? or maybe you have a better solution for that? The C:/ drive actually is from server side.
  9. Thanks Barand. I have change the line of code as above. it's working! if ($sd){ $item = date_format(($sd), 'm/d/y'); //m/d/y } if ($ed){ $item .= '-' . date_format(($ed), 'm/d/y'); //m/d/y $data[$cid]['events'][$m][] = $item; //<--- Move to this line }
  10. I added a line end date after the start date. if ($sd){ $data[$cid]['events'][$m][] = date_format(($sd), 'm/d/y'); //m/d/y } if ($ed){ $data[$cid]['events'][$m][] = date_format(($ed), 'm/d/y'); //m/d/y }
  11. after i add the css, the date like merging together.
  12. Hi Barand, Sorry for disturbing you. I put in end date to make the table more details. but the layout seem to be incorrect. The attachment included 2 start date end 2 end date, but they are like combine it together. 11/03/15-11/04/15 <- is a complete start and end 11/23/15-11/24/15 <- is a complete start and end
  13. Can i have select all query inside the IN statement? WHERE Name in() // Select all data in bracket
  14. I'm not planning to have any cases. mean when click to generate the report, it will generate exactly what i had attach. thank you.
  15. The show the form once and sum up the form score for each. The exact output:
  16. I repeating the empDB is because i would like to get the name of the avaluator aka, addedby column.
  17. Oops.. Sorry.. i think i accidentally uploaded the second attachment. This one. Here is my Database Structure. This is the table view query: SELECT dbo.FormTbl.FormID, dbo.FormTbl.FormName, dbo.CategoryTbl.CatName, dbo.QuestionTbl.questions, dbo.FormQuestionTbl.Points, dbo.FormQuestionTbl.Yes_No, dbo.empDB.EmployeeID AS EmpID, dbo.empDB.Name AS EmpName, dbo.[evaluation[Submit]]].Position, dbo.[evaluation[Submit]]].Scoring, dbo.FormQuestionTbl.tplID, dbo.grouptbl.mainGroupID, dbo.grouptbl.groupName, dbo.subgrouptbl.subgroupID, dbo.subgrouptbl.subgroupName, dbo.QuestionTbl.qID, dbo.FormTbl.startDate, dbo.FormTbl.endDate, dbo.grouptbl.id AS gid, dbo.FormTbl.fiscalYear, dbo.QuestionTbl.sltGroup, dbo.EmployeeDetails.submissionStatus, dbo.FormTbl.quarter, dbo.FormTbl.quarterTo, empDB_1.Name AS addedBy, dbo.empDB.type FROM dbo.[evaluation[Submit]]] INNER JOIN dbo.empDB ON dbo.[evaluation[Submit]]].EmpID = dbo.empDB.EmployeeID INNER JOIN dbo.FormTbl ON dbo.[evaluation[Submit]]].FormID = dbo.FormTbl.FormID INNER JOIN dbo.QuestionTbl ON dbo.[evaluation[Submit]]].Question = dbo.QuestionTbl.qID INNER JOIN dbo.FormQuestionTbl ON dbo.QuestionTbl.qID = dbo.FormQuestionTbl.sqID AND dbo.FormTbl.tplID = dbo.FormQuestionTbl.tplID INNER JOIN dbo.CategoryTbl ON dbo.QuestionTbl.catID = dbo.CategoryTbl.CatID INNER JOIN dbo.grouptbl ON dbo.[evaluation[Submit]]].gid = dbo.grouptbl.id INNER JOIN dbo.subgrouptbl ON dbo.grouptbl.mainGroupID = dbo.subgrouptbl.maingroupID AND dbo.[evaluation[Submit]]].subGroup = dbo.subgrouptbl.subgroupID INNER JOIN dbo.EmployeeDetails ON dbo.[evaluation[Submit]]].EmpID = dbo.EmployeeDetails.EmpID AND dbo.[evaluation[Submit]]].subGroup = dbo.EmployeeDetails.subGroupID AND dbo.[evaluation[Submit]]].FormID = dbo.EmployeeDetails.formID INNER JOIN dbo.empDB AS empDB_1 ON dbo.FormTbl.addedBy = empDB_1.EmployeeID WHERE (dbo.FormQuestionTbl.Yes_No = 'Yes') ORDER BY dbo.subgrouptbl.subgroupName Thank You.
  18. Hello, Is there any Distinct function for php? an employee can have more than 1 form an employee have one and only one position in a form 1 form have only one and only one Evaluator 1 form include more than 1 questions (in this topic have 4 questions for each form) in this case, the forms, position,score and evaluator repeat 4 times due to there is 4 questions is a form. How to Distinct in to show only one time for forms, position,score and evaluator? Output: $sql = "SELECT EmpID,EmpName,FormName,Scoring,Position,addedBy FROM [Advisory_BoardDB].[dbo].[masterView] WHERE submissionStatus <> 'Draft' ORDER BY EmpName ASC,FormName ASC"; $stmt = sqlsrv_query($conn, $sql); $data = array(); while (list($eid, $ename, $fname,$score,$pos,$ab) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$eid])) { // initialize array for employee $data[$eid] = array('emp' => $ename, 'total' => 0, 'items' => array()); } // accumulate item data $data[$eid]['items'][] = array('form' => $fname,'score' => $score,'position'=>$pos,'addby'=>$ab); $data[$eid]['total'] += $score; } $pcent20 = ceil(count($data)*20/100); //$pcent20 = ceil(count($data)*$finalPercentage); //uasort($data, function($a,$b){return $b['total']-$a['total'];}); uasort($data, function($a, $b) { $emp = $b['total'] - $a['total']; if($emp === 0) { return strcmp($a['emp'], $b['emp']); } return $emp; }); $data = array_slice($data, 0, $pcent20, true); //echo '<pre>',print_r($data, true),'</pre>'; // // Now output the array // echo <<<TABLE <table border="1" id="example"> <thead> <tr> <th>Employee ID</th> <th>Employee Name</th> <th>Grand Total</th> <th>Form</th> <th>Score</th> <th>Position</th> <th>Evaluator</th> </tr> <thead> TABLE; echo "<tbody>"; foreach ($data as $eid => $edata) { // how many items $numItems = count($edata['items']); echo "<tr> <td rowspan='$numItems'>$eid</td> <td rowspan='$numItems'>{$edata['emp']}</td> <td rowspan='$numItems'>{$edata['total']}</td>"; foreach ($edata['items'] as $k => $idata) { if ($k > 0) { echo "<tr class='hover-row'>"; } echo "<td>{$idata['form']}</td><td>{$idata['score']}</td><td>{$idata['position']}</td><td>{$idata['addby']}</td></tr>"; } } echo"</tbody>"; echo "</table>"; ?>
  19. oh.. it use me few hours to figure out. Thanks Barand!
  20. But the problem is, when I hard code the query with WHERE FiscalYear ='FY16' The table will only show the course name, if there is an event happen in FY16. Meaning it will not show the full list of courses. =(
  21. I think i found a solution $trows .= "<td class='dt'><div class='dateWrapper'><a>". join('<a>',$dates) .'</div>'.
  22. Hi Barand, in this line of code, i try to wrap the each dates in the wrapper, the reason i do that is i wanted to use jquery to check those dates, if the dates is from previous year, the jquery will set it to display:none. But no matter how i change the $date cannot be wrapped in the <div>. or the multiple date wrap in the same <div> $trows .= "<td class='dt'><div class='dateWrapper'>". join('<br>', $dates) ."</div>";
  23. Hi Everyone, After several round of review, I has been rejected. The output that preferred is: I'm not sure it's possible to do it and how to do it. As you can see, the header of program supported,Position,Evaluator will be increase base on the employee records. It's very flexible header, it's depends on number of form that employee supported. Employee can submit more than one form (differently). Each form contain of more than 1 question. The grand total is a sum of all of the form for individual employee. Each form have an evaluator/ position Actually, i have a different type of output previously. The output is more details : $sql = "SELECT EmpID,EmpName,FormName,questions,Scoring,Position,addedBy FROM [Advisory_BoardDB].[dbo].[masterView] WHERE submissionStatus <> 'Draft' ORDER BY EmpName ASC,FormName ASC"; $stmt = sqlsrv_query($conn, $sql); $data = array(); while (list($eid, $ename, $fname, $q,$score,$pos,$ab) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$eid])) { // initialize array for employee $data[$eid] = array('emp' => $ename, 'total' => 0, 'items' => array()); } // accumulate item data $data[$eid]['items'][] = array('form' => $fname,'questions'=> $q,'score' => $score,'position'=>$pos,'addby'=>$ab); $data[$eid]['total'] += $score; } $pcent20 = ceil(count($data)*20/100); //$pcent20 = ceil(count($data)*$finalPercentage); //uasort($data, function($a,$b){return $b['total']-$a['total'];}); uasort($data, function($a, $b) { $emp = $b['total'] - $a['total']; if($emp === 0) { return strcmp($a['emp'], $b['emp']); } return $emp; }); $data = array_slice($data, 0, $pcent20, true); //echo '<pre>',print_r($data, true),'</pre>'; // // Now output the array // echo <<<TABLE <table border="1" id="example"> <thead> <tr> <th>Employee ID</th> <th>Employee Name</th> <th>Grand Total</th> <th>Form</th> <th>Score</th> <th>Position</th> <th>Evaluator</th> </tr> <thead> TABLE; echo "<tbody>"; foreach ($data as $eid => $edata) { // how many items $numItems = count($edata['items']); echo "<tr> <td rowspan='$numItems'>$eid</td> <td rowspan='$numItems'>{$edata['emp']}</td> <td rowspan='$numItems'>{$edata['total']}</td>"; foreach ($edata['items'] as $k => $idata) { if ($k > 0) { echo "<tr class='hover-row'>"; } echo "<td>{$idata['form']} - {$idata['questions']}</td><td>{$idata['score']}</td><td>{$idata['position']}</td><td>{$idata['addby']}</td></tr>"; } } echo"</tbody>"; echo "</table>"; ?> For More details: http://forums.phpfreaks.com/topic/298608-sql-group-view-to-get-grand-total-and-details/ Million Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.