Note the following relationships:
$$tan(\theta)=\frac{F_{v}}{F_{h}} \quad\rightarrow\quad F_{h}=\frac{F_{v}}{tan(\theta)}$$
$$F_{1}=\mu N_{1}=\mu m_{1}g$$
$$F_{2}=\mu N_{2} \quad where \quad m_{2}g=N_{2}+F_{v}$$
$$F_{h}=F_{d}+F_{1}+F_{2}$$
Making the appropriate substitutions give:
$$\frac{F_{v}}{tan(\theta)}=(m_{1}+m_{2})\cdot \overline{a}+\mu m_{1}g+\mu (m_{2}g-F_{v})$$
After some algebraic rearrangement, we arrive at:
$$F_{v}=\frac{tan(\theta)}{1+\mu tan(\theta)}\bigg[ m_{1}+m_{2}(\mu g + \overline{a}) \bigg]$$
Hence, $P=\frac{F_{v}}{sin(\theta)}=\frac{tan(\theta)}{sin(\theta)[1+\mu tan(\theta)]}\bigg[ m_{1}+m_{2}(\mu g + \overline{a}) \bigg]$